Snippets code from my daily experience

March 27, 2008

KomodoEdit and smart tab switch

Filed under: eclipse, extension, komodo — dafi @ 9:10 pm

Today I’ve discovered again (and again) other programmers have my same needs.

I do intensive use of tab switcher during my editing sessions, Control-Tab is my preferred key sequence.

When I need to use Eclipse I love the ability to access to the buffer list using the little arrow placed at buffer tabs end.

You can type buffer title to quickly focus the buffer or use arrows keys, very cool.

KomodoEdit offers very poor ways to move between views so I wrote my TabSwitcher to mimic Eclipse feature.

Today I’ve read a post on ActiveState’s forum where another user has my same needs and I’ve decided to share my bonsai extension with the community, I hope the community appreciates my work.

Maybe I should create a website page for TabSwitcher but I’m so lazy and maybe user feedback can be very low.

March 23, 2008

Central extensions repositories

Filed under: extension, firefox, flock, komodo, songbird — dafi @ 10:21 pm

I spend my time to created extensions based on Gecko expecially for

  • Firefox, Thunderbird and SeaMonkey (all under Mozilla umbrella)
  • Songbird
  • Flock
  • KomodoEdit/KomodoIDE

Every product has its own developer website where you can upload your extensions (Komodo hasn’t a dedicated upload zone).

From a visitor/user feedback’s point of view Flock is the best.

Flock addons site is cool I love it, extension informations are very complete, you can see also the locales supported by extensions.

Songbird has a cool addons site simple and very quick, extension informations are complete.

Mozilla with AMO is the most important but is also the worst.

The outsider KomodoEdit addons site not yet really exists, registered users can’t upload their extensions.
I hope Komodo guys take a look at Flock addons site if they decide to create a similar place.

From a developer feedback’s point of view Songbird is the best.
After signup you can immediately upload and publish extension on Songbird site, the upload process is easy and publication policy very developer friendly.

AMO upload mechanism is simple but publication mechanism is awful. I don’t like its approval mechanism based on sandbox, my RichFeedButton waits approval for an year.

Flock allows to upload extensions immediately after signup but publication waits approval, after a couple of days I’m yet waiting ;)

The most mature and important addons site AMO, has IMHO the worst user/developer experience.

I don’t like so much Flock but it has a great develope/user website

March 22, 2008

Get HTML code from nsISelection in XUL

Filed under: firefox, flock, nsISelection, selection, xul — dafi @ 9:56 am

Recently after a discussion with my friend bard we realized how it is easy to obtain HTML source code associated to the current browser (eg Firefox, Flock) selection.

It’s too simple to discuss the snippet, leave the code speaks itself

function selectionToHTMLSource()  {
    var sel = document.commandDispatcher.focusedWindow.getSelection();
    if (sel.rangeCount < 1) {
        return "";
    }

    var node = sel.getRangeAt(0).cloneContents();
    var xmlStr = new XMLSerializer().serializeToString(node);
    return xmlStr;
}

The code handles single selection, if you need to work with multiple selections like tables rows/cells take a look at Table2Clipboard


March 15, 2008

Komodo and readonly behavior

Filed under: extension, komodo, morekomodo, mozilla, openkomodo, scintilla — dafi @ 12:30 pm

Komodo editor handles read-only in a incomplete manner, at least for me.

The truly question is “what read-only means?” A file can be read-only but also an editor buffer can be read-only.

Komodo handles read-only files is a smart way, it opens file and shows a little lock on editor tab but user can edit the text buffer, it isn’t marked as read-only.

If user tries to save a warning message pops up allowing to choose if saving must be forced or cancelled.

Cool sure but I want to mark editor buffer as temporary read-only irrespective to file flag, this feature is missing on Komodo but scintilla has a readonly property.

I’ve added to MoreKomodo the ability to mark editor buffers as “edit locked”.

I think “edit locked” sounds good then “buffer read-only”.

The code is straightforward, simply sent the scintilla readonly property as shown below

     onToogleLockEdit : function() {
        var view = ko.views.manager.currentView;
        view.scintilla.scimoz.readOnly = !view.scintilla.scimoz.readOnly;
    }

March 11, 2008

XBL, CSS selectors priority and Firefox 3

Filed under: css, firefox, gecko, mozilla, xbl, xul — dafi @ 8:58 pm

I wrote a little XBL component to allow menuitems to have images centered, I added it to Firefox 2 browser context menu and worked fine immediately, after a while I installed component on Firefox 3 beta 4 and surprisingly the menuitem didn’t show the image :(

I’ve asked help on Mozilla IRC and after about an hour the mistery was revealed.

The innocent CSS declaration shown below works fine on Firefox 2

.menuitem-image-center {
-moz-binding: url(‘chrome://morekomodo/content/bindings/menu.xml#menuitemImageCenterBinding’);
}

but requires a little modification on Firefox 3 beta 5pre (at this time the latest available)

.menuitem-image-center {
-moz-binding: url(‘chrome://morekomodo/content/bindings/menu.xml#menuitemImageCenterBinding’)
!important;
}

You must notice the selector without !important attribute works on Firefox 3 when applied on menus different from browser context menu.

I suspect the browser context menu should have some special treatment on new Firefox…

Context menu

February 15, 2008

RichScrollbar sunset

Filed under: extension, richscrollbar, xbl — dafi @ 6:21 pm

RichScrollbar extension, RSB for friends, is quite simple and not intrusive but technically is a big compromise.
It is written as  XBL component and runs inside chrome context and  browser content context.

Under Firefox 3 beta1 and beta2 RSB after some fix worked like a charm, when beta3 arrived RSB was broken.

Mark Finkle helped me to understand why RSB didn’t work and we discover FF3 fixed a security bug on XBL.

Now it is impossible to make RSB functional on browser windows, it works only on chrome dialogs.

I surrend, period! I have not enough technical knowledge to dig for a workaround.

I consider terminated the RSB development, the XBL documentation is poor and all my help requests haven’t received reply except Mark.

Honestly I’m sad, I love RSB and I prefer it to Mouse Gestures, I’ll continue to search for a fix but it is very difficult to find.

Mark helped me and I would say thank to him, great people work at Mozilla.

February 14, 2008

Extend Firefox 2 Contest and other surprises

Filed under: firefox, mozilla, openkomodo, table2clipboard — dafi @ 9:06 pm

January and February are very important months for my programming activites.

In January ActiveState guys gave me a KomodoIDE license for my contribution to their OpenKomodo wiki, a great unexpected surprise, the first one.

A couple of days ago Mozilla published the Extend Firefox 2 Contest and I discovered my name on “Runners up” list, a great
unexpected surprise, the second one.
I can figure out ViewSourceWith is the winner, no! The winner is Table2Clipboard my outsider extension, a great unexpected surprise, the third one.

I’m happy that other people appreciates my work.

My feed reader alerts me, LifeHacker has new contents, I take a look and found they speak about Table2Clipboard, a great unexpected surprise, the fourth one.

ActivateState gave me a KomodoIDE license, EF2 prices contain a KomodoIDE license, now I have two KomodoIDE license, another surprise the fifth :D

Mumble mumble… may I sell the unused license?

January 8, 2008

Richscrollbar top ten download sorted by locale

Filed under: richscrollbar — dafi @ 7:58 pm

I’ve created statistics about Richscrollbar, I’m very proud to find Japan at 2nd place.

Place Download count Locale
1 138 en-US
2 78 ja
3 19 it
4 18 fr
5 17 en-GB
6 14 de
7 14 ru
8 12 es-ES
9 7 zh-TW
10 4 zh-CN

Italy, my country is 3th :-(

January 7, 2008

OpenKomodo namespace API

Filed under: komodo, openkomodo — dafi @ 7:30 pm

When you want to write extensions or macros for OpenKomodo you discover many new XPCOM interfaces to use, they are so much that you can be confused.

Komodo programmers fortunately have simplified XPCOM usage wrapping a bunch of them in easy-to-call functions.

These function are incapsulated in namespace as modern Javascript dictates, every namespace can contains several functions.

Table below shows OpenKomodo namespaces, good luck ;-)

Namespace Description
ko.browse Functions to launch browsers
ko.commands Functions to handling commands
ko.dragDrop Functions to handle drag&drop of files onto Komodo
ko.eggs Easter egg
ko.filepicker Functions to wrap nsIFilePicker
ko.help Functions to simplify launch help pages
ko.inputBuffer Functions to capture user input while a slow XUL window is loading
ko.interpolate Functions to easily use the KoIInterpolationService from JavaScript
ko.isearch Functions to handle incremental searches
ko.launch Functions to launch dialogs like Extension Manager, Watcher, Diff
ko.lint Functions to access lint from Javascript
ko.logging Functions to access the logging system from Javascript
ko.main Functions to hook Komodo startup/shutdown
ko.markers Scintilla image markers used in Komodo
ko.mru Functions to handle MRU
ko.open Functions to open buffer editors
ko.printing Functions to handle printer
ko.run.output Functions to handle run output window
ko.statusBar Functions to handle status bar
ko.stringutils Functions to work with strings
ko.uilayout Functions to handle various UI features
ko.uriparse Functions to convert/parse strings representing URLs
ko.window Functions to get window informations
ko.windowManager Functions to handle windows

December 27, 2007

Richscrollbar released

Filed under: extension, firefox, nsIStyleSheetService, richscrollbar — dafi @ 11:56 am

After ten months I’ve released a new Richscrollbar (RSB) version, starting from FF3 compatibility issues I’ve done some other work.

Finally standard OS themes aren’t offended by old ugly RSB scrollbars, now RSB integrates better with the native OS look&feel.

Now RSB simplifies integration with themes, a model based on supported themes repository allow me to quickly add css styles.

Finally users can decide to remove RSB scrollbars from listbox, tree and so on and have them only on main browser window.

Very strange is the reason RSB doesn’t work on FF3; The nsIStyleSheetService.USER_SHEET must be changed to nsIStyleSheetService.AGENT_SHEET

It’s always present the problem with disabled javascript due to bug 236839 that limits RSB usage for example with Thunderbird or when NoScript is installed

Initially I would make RSB compatible with Seamonkey but the current number of users is so little that this compatibility isn’t necessary

« Previous PageNext Page »

Blog at WordPress.com.