diff --git a/Makefile b/Makefile index 8089e761..de747cb9 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ ZIP = zip # find the vimperator chrome dir FIREFOX_DEFAULT = $(wildcard ${HOME}/.mozilla/firefox/*.default) -VIMPERATOR_CHROME = $(wildcard ${FIREFOX_DEFAULT}/extensions/vimperator@mozdev.org/chrome/) +VIMPERATOR_CHROME = ${FIREFOX_DEFAULT}/extensions/vimperator@mozdev.org/chrome/ # specify V=1 on make line to see more verbose output Q=$(if ${V},,@) @@ -48,6 +48,8 @@ info: @echo "vimperator chrome ${VIMPERATOR_CHROME}" needs_chrome_dir: + @echo "Checking chrome dir..." + -${Q}mkdir -p "${VIMPERATOR_CHROME}" ${Q}test -d "${VIMPERATOR_CHROME}" xpi: ${RELEASE} diff --git a/TODO b/TODO index f0fc8133..bc2543dd 100644 --- a/TODO +++ b/TODO @@ -31,6 +31,7 @@ FEATURES: 6 autocommands (BrowserStart, BrowserQuit, TabClose, TabOpen, TabChanged, PageLoaded, any more?) 6 vim like mappings for caret mode and textboxes (i to start caret mode?) 6 pipe selected text/link/website to an external command +6 it would be nice to have :undo w/ tab completion support 6 macros (qq) 6 support firefox search engines, or at least make our search enginges user configurable 6 gf = view source? diff --git a/vimperatorrc.example b/vimperatorrc.example index 10fe3f62..4e880f51 100644 --- a/vimperatorrc.example +++ b/vimperatorrc.example @@ -9,4 +9,68 @@ hello = function(name) { alert("Hello world: " + name); } + +//Checks if a mapping is already defined and returnes the index in g_mappings, +//where it is defined, or -1 +find_map = function(tofind) +{ + for (var i in g_mappings) + { + // each internal mapping can have multiple keys + for (var j in g_mappings[i][0]) + { + var mapping = g_mappings[i][0][j]; + if(mapping == tofind) { + //alert("Mapping '"+tofind+"' found"); + return i; + } + } + } +// alert("Mapping '"+tofind+"' not found"); + return -1; +} + +//(re)define a mapping map, with usage, helptext by function func +//see examples below +//Current problem: Doesn't remove helptext, when a mapping is unassigned +define_map = function(map, usage, helptext, func) { + //check if mapping exists: + var i=find_map(map); + var newmap = [[map],[usage],helptext,func]; + if(i>=0) + { + //unassign map + var changed_maps=new Array(); + for(j in g_mappings[i][0]) { + if(g_mappings[i][0][j]!=map) + changed_maps.push(g_mappings[i][0][j]); + } + g_mappings[i][0]=changed_maps; + } + //add new map + g_mappings.push(newmap); + alert("Mapping '"+map+"' added."); +} +print_maps = function (toPrint) { +var doc = gBrowser.contentDocument; +doc.open(); +var text=""; +for( i in g_mappings) { + var curmaps = ""; + for (j in g_mappings[i][0]) + curmaps += g_mappings[i][0][j].replace("<","≤").replace(">","&ge")+", "; + text +="

["+curmaps+"]"; +} +doc.write(text); + +doc.close(); +} + EOF + + +" use functions to define maps for h and l +javascript define_map("h","h","previous tab",function(){tab_go(-1);}); +javascript define_map("l","l","next tab",function(){tab_go(0);}); + +" vim: set syntax=javascript :