Snippets code from my daily experience

January 4, 2010

VisualDiffer 1.2 beta 1

I spent the Christmas holidays working on VisualDiffer, the Komodo visual folders/files comparison extension.

Now I want to migrate VisualDiffer from extension to standalone application using XULRunner because the folders comparison feature is mature and using it from an extension can be a bit complicated.

The migration requires some intermediate steps

  • Remove dependencies from Komodo code (especially the unified diff algorithm)
  • Remove dependencies from unified diff algorithm!!
  • Complete the file comparison feature allowing in-place editing using Bespin.
    Bespin can greatly simplify syntax highlight for different languages, search in file and so on
    Honestly I’m considering also to stay with Scintilla (actually used by Komodo) but I love Bespin
  • Use a cool graphic layout, especially toolbar icons
    I’m not a GIMP guru so if somebody would to help me he/she would be welcomed 🙂
  • Allow user defined fonts and colors (low priority task)

I hope to release the VisualDiffer V1.2 for Komodo in a couple of weeks but also not Komodo aficionados can take a look to it installing the beta version on Firefox 3.5.x (also 3.6b5) and SeaMonkey 2.x.

Under Firefox and SeaMonkey the “files differ” feature isn’t implemented (Komodo dependencies) but you can test the folders differ feature that is totally based on standard Gecko interfaces, you can find the VisualDiffer item under the Tools menu.

Obviously VisualDiffer on Firefox is a nonsense because it isn’t a browser oriented extension I distribute this version with Firefox support with the hope a larger community can try it and give me feedback before I jump on the XULRunner world.

The V1.2 beta 1 can be downloaded from here.

VisualDiffer is inspired by the fantastic Beyond Compare but this isn’t a mystery 😉

Advertisements

December 20, 2009

Contributions, now it’s my turn (Sunday Thought)

Thanks to the contribution platform available at AMO I bought one book and a couple of software licenses (not open sourced).

I can say that the AMO contribution feature is a great success for me, dozen of donors for two ‘not so famous‘ extensions like Table2Clipboard and ViewSourceWith.

Now I’ve a little budget to use to make contributions because NOW it’s my turn!

I’ll contribute to Firefox extensions without forget other open source projects especially the utilities, I love the little time saver applications 😛

I chosen low ‘Suggested Donation’ amount for my extensions but this has generated very expensive PayPal fees per transaction so I’ll make fewer contributions but all higher than 5$, I would the software authors take maximum profits from donations.

I hope in my country (Italy) PayPal made available micropayments very soon.

I would like to receive contributions also for my Komodo extensions, strangely the official dafizilla website doesn’t attract donors (I don’t like to fill it with banners and donations messages), I hope rumors about the Add-On Store will be confirmed and the store will host not only browser (i.e. Firefox) extensions and more important it will host also free/open source components.

November 8, 2009

Karmic Koala hides Firefox context menuitems icons

Filed under: bugzilla,firefox,karmic koala,ubuntu,viewsourcewith — dafi @ 11:27 am

This week I’ve received four times the same (i.e. duplicated) ViewSourceWith (VSW) bug report that sounds…

“ViewSourceWith stopped to show the icons on context menu, this regression is present on Karmic Koala (Ubuntu 9.10)”

I use Intrepid Ibex (Ubuntu 8.10) and all works fine, so I’ve burned a Karmic Koala ISO and tested it discovering the “regression” exists.

Debug -> Add logs -> Remove logs -> Clean Profile -> DOM Inspect -> MozRepl without find where the problem occurs.

Last resort -> Bugzilla -> Found!!!

The Bug 527253 unveils the mystery!

This isn’t a regression

ViewSourceWith isn’t the guilty, Firefox isn’t the guilty but… Gnome is the guilty 😛

Type the command shown below from command line and restart Firefox

gconftool-2 --type bool --set /desktop/gnome/interface/menus_have_icons true

EDIT Or use the UI to obtain same result (thanks to mzz) system -> preferences -> appearance -> interface -> show icons in menus

This worked for me and also for two bug submitters (the other two guys do not replayed to my hint)

So remember Bugzilla is your friend 😉

November 2, 2009

Little browsers grow

Filed under: fennec — dafi @ 8:06 pm

This is a non technical post


Read full story at ZooBorns

October 29, 2009

PluginChecker v0.2

Filed under: Uncategorized — dafi @ 6:46 pm

I’ve received great and unexpected feedback about PluginChecker on my previous post so I’ve decided to refactor its code and better integrate with the standard Extensions Manager.

The original ugly dialog has been removed and informations about the new installed plugins are shown directly onto the Extensions Manager.

PluginChecker

PluginChecker v0.2 can be downloaded from SourceForge and from AMO.

October 18, 2009

.NET Framework Assistant, automatic plugin installation and PluginChecker

Filed under: extension,plugins,xul — dafi @ 2:21 pm

In these days the net is populated by blog posts about the .NET Framework Assistant plugin for Firefox, its disabling and the fact Firefox does not warn user when a plugin installs itself without explicit permission.

Well, this is a old problem at least for me, indeed I discovered it some time ago when my Firefox crashed (apparently) without reason, discovering after a couple of days that Microsoft Office 2003 plugin fought with Foxit Reader and Google update plugins.

The problem was that I never installed Office plugin!

plugins

Disabling Office plugin Firefox stopped to crash.

After that experience I decided to write a simple (very simple) extension that at every Firefox startup checks if there are new plugins installed.

plugincheckerNothing so cool, only a quick and dirty solution implemented in a few of hours.

Waiting Mozilla implements a better solution than mine you can install PluginChecker.

If you expect to find PluginChecker innovative or the “I-can-live-without-it” extension you are on the wrong place, if you expect a not intrusive and simple solution to unattended plugins installation than you can take a look at it.

You can download PluginChecker from SourceForge.

October 9, 2009

You must Disable or Remove Adblock to visit this website, no Thanks!

Filed under: adblock — dafi @ 4:28 pm
Tags:

Today visiting a website that gives invites for Google Wave I received the message shown below

disable_adp

This is the first time I see a similar “invite”

Well, no thanks I prefer to move away from this website, period!

September 14, 2009

Table2Clipboard 1.0 now preserves styles

Filed under: excel,extension,firefox,openoffice,table2clipboard,xul — dafi @ 6:49 pm

Finally after almost a year I release a new version of Table2Clipboard, one of twelve extensions that won in 2008 the Firefox 2 Contest in the section Runners Up.

What’s new

Until now Table2Clipboard has pasted to clipboard the structure of HTML tables without the styles (colors, borders, fonts) but many users have asked me that the behavior was much more similar to that of Internet Explorer (IE) which indeed maintains many details.

Well, the version 1.0 preserves the styles and in certain cases the result is better than that obtained with IE.

IE inserts also the DOM elements declared “not visible”, for example the table shown in Figure 1  is pasted in Excel as shown in Figure 2.

ie

Figure 1

Table selection on Internet Explorer

excel-from-ie

Figure 2

Copy from Internet Explorer paste to Microsoft Excel

Table2Clipboard discards hidden DOM elements as shown in Figure 3, this makes more sense for me.

Paste from Firefox with Table2Clipboard to Microsoft Excel

Figure 3

Copy from Firefox with Table2Clipboard paste to Microsoft Excel

Other little improvements

Now web links are copied and user can choose to copy images (tag IMG), too.
All defaults settings can be modified from configuration dialog.

The copy of styles on OpenOffice doesn’t work as well as the one on Microsoft products.
The “Paste Special” feature available on OpenOffice doesn’t recognize CSS styles but only deprecated tags like FONT.

I will add support for OpenOffice soon but I prefer the “release early release often” (after a year??? :P) approach so this version has poor styles support on the popular open source office automation suite.

Compatibility issues with Thunderbird 3.x are now fixed.

Table2Clipboard can be installed from AMO or from the project site on dafizilla.

August 17, 2009

Experimenting with Bespin plugins

Filed under: bespin — dafi @ 11:38 am

code_square I’ve started to use Bespin intensively, long editing sessions to test how much it fits my needs.

Bespin is very good and I’m really satisfied to use it as general purpose collaboration editor but I’m a very lazy developer and I need many little features, not yet present on Bespin, making my coding life easier.

Bespin supports plugins allowing users to write Javascript code that is easily “plugged” into editor so I started to study its programming model.

There are hundred of APIs but I focused my attention to the specific sections shown below, discovering an excellent support.

  • General text handling (unicode support, cursor position and so on)
  • Text selection
  • Undo/Redo groups of text operations
  • Clipboard

More details about installing and using plugins are available at Bespin wiki

A brief survey of Bespin architecture

When plugins interact with the editor soon or later they must use some core components.

  • editor itself; It holds reference to all editor structures
  • edit session; The current file buffer user are editing
  • model; The most important component, it allows to access to text abstracting internal character representation (eg unicode), you see anything as rows and columns
  • actions; move cursor, handle history (undo/redo) and many other text actions

It is possible to access to components using the Bespin singletons

bespin.get('editor') // access to the editor component

or navigating the data structure (ok you must use always a starting singleton 😛 )

bespin.get('editSession').editor // access to the editor component starting from editSession

The “Comment Selection” plugin

To understand how Bespin APIs work I’ve written a stupid but useful (at least for me) plugin used to comment out a text selection based on file language, so CSS selected lines are commented using /* … */, HTML using <!– … –> and so on.

The “comment selection” is treated as a single text operation, if ten lines are commented and user makes undo all lines are undone, user doesn’t need to make ten times undo!
Grouping operations for undo/redo it is possible thanks to beginEdit()/endEdit() methods

    editor.ui.actions.beginEdit("commentSelection");
    ...
    editor.ui.actions.endEdit();

Stop blah blah blah, I want to read code!

The plugin code is very easy.

We get the selection info (not the text) and then use the model to insert characters, this allows to take benefits of history manager (undo/redo) and character internal representation.

exports.commentSelection = function(instruction) {
    var currPath = bespin.get('editSession').path;
    var extFile = bespin.util.path.fileType(currPath);
    var commentDelimiters = exports.getCommentDelimitersByLang(extFile);

    if (typeof (commentDelimiters) == "undefined") {
      return;
    }

    var selection = bespin.get('editor').getSelection();
    var model = bespin.get('editSession').editor.model;
    var editor = bespin.get('editSession').editor;

    var startRow;
    var endRow;
    if (selection) {
      startRow = selection.startModelPos.row;
      endRow = selection.endModelPos.row;
    } else {
      startRow = endRow = editor.getCursorPos().row;
    }
    instruction.addOutput(startRow + "," + endRow + " model" + model);
    editor.ui.actions.beginEdit("commentSelection");
    for (var r = startRow; r <= endRow; r++) {
      var modelPos = {row : r, col : 0};
      model.insertCharacters(modelPos, commentDelimiters.begin);
      modelPos.col = model.rows[r].length;
      model.insertCharacters(modelPos, commentDelimiters.end);
      }
    editor.ui.actions.endEdit();
}

You can view the full plugin code following me at bespin.mozilla.com, do login and from command line type

follow dafi

SVN aficionados can browse the code here

August 1, 2009

Table2Clipboard and clipboard application interoperability

Filed under: calc,clipboard,excel,extension,openoffice,table2clipboard,xul — dafi @ 10:35 am

calc_excel_t2cMany users asked to me to add to the extension Table2Clipboard (T2C for friends) the ability to preserve web links and maintain the styles during tables copy.

Preserving links and other HTML tags was a very easy task, I’ve written the code very quickly and both OpenOffice Calc and Microsoft Excel have handled correctly the pasted content.

When I started to support style preservation I discovered different and ugly results on the two popular office suites making harder to write cross platform XUL code.

Actually T2C pastes to clipboard inserting data in two different formats (flavors), unicode plain text and HTML format.
When users do “Paste Special” the HTML format is pasted and applications (Excel or Calc) render inside the data sheet.

Both Excel and Calc handle only the deprecated FONT tag and a subset of TABLE tag attributes and this represents a great limitation for style preservation from T2C.

If you try to paste from Microsoft Explorer to Microsoft Excel you discover everything is copied, the styles are totally preserved but if you paste from Explorer to OpenOffice Calc all style are lost!!!

Well, Explorer inserts to clipboard also RTF formatted text and Excel works very fine with the barely public RTF file format.

Clipboard application interoperability goes to hell, HTML is not fully supported by the “Paste Special” feature available on both suites, and as usual Microsoft uses semi proprietary data formats to exchange informations between applications.

I think at least OpenOffice should improve its “Paste” feature simply adding support for HTML style attribute.

T2C can preserve correctly styles only implementing platform specific code for OpenOffice and Microsoft Office and I really hate write specific platform.

I’m considering other alternatives but I see only the darkness of C++, OLE and core dump…

« Previous PageNext Page »

Blog at WordPress.com.