1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-22 00:17:58 +01:00

major code cleanup by using constants instead of indices, small bugs still may occur due to this change

This commit is contained in:
Martin Stubenschrott
2007-04-28 01:56:19 +00:00
parent c21df11e92
commit 4cc50bf40e
6 changed files with 301 additions and 236 deletions

View File

@@ -1,6 +1,9 @@
<pre> <pre>
date: date:
* version 0.4 * version 0.4
* support for 'wildmode' completion setting
* changed regexp search to normal text search for completion -> massive speedup, but limited functionality
* support for :open ./ , :open .. and :open ... (patch from Lee Hinman)
* Esc now doesn't stop loading the webpage, use Ctrl-c instead, :stop command added * Esc now doesn't stop loading the webpage, use Ctrl-c instead, :stop command added
* changed hinttags to work with dict.leo.org and hintstyle to work with digg.com * changed hinttags to work with dict.leo.org and hintstyle to work with digg.com
* :back! goes to beginning of history now * :back! goes to beginning of history now

File diff suppressed because it is too large Load Diff

View File

@@ -482,7 +482,7 @@ function get_help_completions(filter)/*{{{*/
help_array = help_array.concat(get_settings_completions(filter, true)); help_array = help_array.concat(get_settings_completions(filter, true));
help_array = help_array.concat(g_mappings); help_array = help_array.concat(g_mappings);
if (!filter) return help_array.map(function($_) { if (!filter) return help_array.map(function($_) {
return [$_[0][0], $_[1]]; return [$_[COMMANDS][0], $_[SHORTHELP]];
}); });
return build_longest_common_substring(help_array, filter); return build_longest_common_substring(help_array, filter);
}/*}}}*/ }/*}}}*/
@@ -492,7 +492,7 @@ function get_command_completions(filter)/*{{{*/
g_completions = []; g_completions = [];
g_substrings = []; g_substrings = [];
if (!filter) return g_completions = g_commands.map(function($_) { if (!filter) return g_completions = g_commands.map(function($_) {
return [$_[0][0], $_[1]]; return [$_[COMMANDS][0], $_[SHORTHELP]];
}); });
return g_completions = build_longest_starting_substring(g_commands, filter); return g_completions = build_longest_starting_substring(g_commands, filter);
}/*}}}*/ }/*}}}*/
@@ -508,16 +508,16 @@ function get_settings_completions(filter, unfiltered)/*{{{*/
filter = filter.substr(2); filter = filter.substr(2);
} }
if (unfiltered) return g_settings.filter(function($_) { if (unfiltered) return g_settings.filter(function($_) {
if (no_mode && $_[5] != "boolean") return false; if (no_mode && $_[TYPE] != "boolean") return false;
else return true; else return true;
}).map(function($_) { }).map(function($_) {
return [$_[0], $_[1]]; return [$_[COMMANDS], $_[SHORTHELP]];
}); });
if (!filter) return g_settings.filter(function($_) { if (!filter) return g_settings.filter(function($_) {
if (no_mode && $_[5] != "boolean") return false; if (no_mode && $_[TYPE] != "boolean") return false;
else return true; else return true;
}).map(function($_) { }).map(function($_) {
return [$_[0][0], $_[1]]; return [$_[COMMANDS][0], $_[SHORTHELP]];
}); });
@@ -527,11 +527,11 @@ function get_settings_completions(filter, unfiltered)/*{{{*/
filter = filter.substr(0, filter.length-1); filter = filter.substr(0, filter.length-1);
for(var i=0; i<g_settings.length; i++) for(var i=0; i<g_settings.length; i++)
{ {
for(var j=0; j<g_settings[i][0].length; j++) for(var j=0; j<g_settings[i][COMMANDS].length; j++)
{ {
if (g_settings[i][0][j] == filter) if (g_settings[i][COMMANDS][j] == filter)
{ {
settings_completions.push([filter + "=" + g_settings[i][4].call(this), ""]); settings_completions.push([filter + "=" + g_settings[i][GETFUNC].call(this), ""]);
return settings_completions; return settings_completions;
} }
} }
@@ -543,26 +543,26 @@ function get_settings_completions(filter, unfiltered)/*{{{*/
var filter_length = filter.length; var filter_length = filter.length;
for (var i = 0; i < g_settings.length; i++) for (var i = 0; i < g_settings.length; i++)
{ {
if (no_mode && g_settings[i][5] != "boolean") if (no_mode && g_settings[i][TYPE] != "boolean")
continue; continue;
var prefix = no_mode ? 'no' : ''; var prefix = no_mode ? 'no' : '';
for (var j = 0; j < g_settings[i][0].length; j++) for (var j = 0; j < g_settings[i][COMMANDS].length; j++)
{ {
if (g_settings[i][0][j].indexOf(filter) != 0) continue; if (g_settings[i][COMMANDS][j].indexOf(filter) != 0) continue;
if (g_substrings.length == 0) if (g_substrings.length == 0)
{ {
var length = g_settings[i][0][j].length; var length = g_settings[i][COMMANDS][j].length;
for (var k = filter_length; k <= length; k++) for (var k = filter_length; k <= length; k++)
g_substrings.push(prefix + g_settings[i][0][j].substring(0, k)); g_substrings.push(prefix + g_settings[i][COMMANDS][j].substring(0, k));
} }
else else
{ {
g_substrings = g_substrings.filter(function($_) { g_substrings = g_substrings.filter(function($_) {
return g_settings[i][0][j].indexOf($_) == 0; return g_settings[i][COMMANDS][j].indexOf($_) == 0;
}); });
} }
settings_completions.push([prefix + g_settings[i][0][j], g_settings[i][1]]); settings_completions.push([prefix + g_settings[i][COMMANDS][j], g_settings[i][SHORTHELP]]);
break; break;
} }
} }

View File

@@ -137,7 +137,7 @@ table.settings th {\
* color = used for background of the table * color = used for background of the table
* beg = string which is printed before the commmand/setting/mapping name * beg = string which is printed before the commmand/setting/mapping name
* end = string which is printed after the commmand/setting/mapping name * end = string which is printed after the commmand/setting/mapping name
* func = called with 'commands' array and result which is a sring is prepended to the help text * func = called with 'command', result is a string is prepended to the help text
*/ */
function makeHelpString(commands, color, beg, end, func) function makeHelpString(commands, color, beg, end, func)
{ {
@@ -145,17 +145,17 @@ table.settings th {\
for (var i=0; i < commands.length; i++) for (var i=0; i < commands.length; i++)
{ {
ret += '<tr class="tag"><td colspan="2">'; ret += '<tr class="tag"><td colspan="2">';
for (var j=0; j < commands[i][0].length; j++) for (var j=0; j < commands[i][COMMANDS].length; j++)
{ {
var cmd_name = commands[i][0][j]; var cmd_name = commands[i][COMMANDS][j];
cmd_name = cmd_name.replace(/</g, "&lt;"); cmd_name = cmd_name.replace(/</g, "&lt;");
cmd_name = cmd_name.replace(/>/g, "&gt;"); cmd_name = cmd_name.replace(/>/g, "&gt;");
ret += "<code id='" + commands[i][0][j] + "'>" +beg+ cmd_name +end+ '</code>'; ret += "<code id='" + commands[i][COMMANDS][j] + "'>" +beg+ cmd_name +end+ '</code>';
} }
ret += '</td></tr><tr class="description"><td class="usage">'; ret += '</td></tr><tr class="description"><td class="usage">';
for (var j=0; j < commands[i][1].length; j++) for (var j=0; j < commands[i][USAGE].length; j++)
{ {
var usage = commands[i][1][j]; var usage = commands[i][USAGE][j];
usage = usage.replace(/<(?!br\/>)/g, "&lt;"); usage = usage.replace(/<(?!br\/>)/g, "&lt;");
usage = usage.replace(/[^b][^r][^\/]>/g, "&gt;"); usage = usage.replace(/[^b][^r][^\/]>/g, "&gt;");
@@ -164,12 +164,18 @@ table.settings th {\
ret += '</td><td>'; ret += '</td><td>';
if (func) if (func)
ret += func.call(this, commands[i]); ret += func.call(this, commands[i]);
if (commands[i][2]) if (commands[i][SHORTHELP])
{ {
if(func) if(func)
ret += "<br/>" ret += "<br/>";
ret += commands[i][2]; // the help description ret += "<b>";
ret += commands[i][SHORTHELP]; // the help description
ret += "</b><br>";
if (commands[i][HELP])
ret += commands[i][HELP]; // the help description
} }
else
ret += "Sorry, no help available";
ret += '</td></tr>'; ret += '</td></tr>';
} }
return ret; return ret;
@@ -177,20 +183,20 @@ table.settings th {\
function makeSettingsHelpString(command) function makeSettingsHelpString(command)
{ {
var ret = ""; var ret = "";
ret = command[5] + " (default: <code>"; ret = command[TYPE] + " (default: <code>";
if (command[5] == "boolean") if (command[TYPE] == "boolean")
{ {
if(command[6] == true) if(command[DEFAULT] == true)
ret += "on"; ret += "on";
else else
ret += "off"; ret += "off";
} }
else else
{ {
if (typeof command[6] == 'string' && command[6].length == 0) if (typeof command[DEFAULT] == 'string' && command[DEFAULT].length == 0)
ret += "''"; ret += "''";
else else
ret += command[6]; ret += command[DEFAULT];
} }
ret += "</code>)<br/>"; ret += "</code>)<br/>";

View File

@@ -3,6 +3,13 @@
// handles all persistent storage of information // handles all persistent storage of information
// to and from the firefox registry // to and from the firefox registry
const TYPE = 4;
const SETFUNC = 6;
const GETFUNC = 7;
const DEFAULT = 8;
const CHECKFUNC = 9;
// the global handle to the root of the firefox settings // the global handle to the root of the firefox settings
var g_firefox_prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch); var g_firefox_prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
var g_vimperator_prefs = null; var g_vimperator_prefs = null;
@@ -16,214 +23,222 @@ var opt_fullscreen = false;
* [ * [
* 0: [all names of this setting], * 0: [all names of this setting],
* 1: usage, * 1: usage,
* 2: help text, * 2: shorthelp
* 3: set_function, * 3: help text,
* 4: get_function, * 4: type,
* 5: type, * 5: completefunc
* 6: default, * 6: set_function,
* 7: checkfunc, * 7: get_function,
* 8: completefunc * 8: default,
* 9: checkfunc,
* ] * ]
*/ */
var g_settings = [/*{{{*/ var g_settings = [/*{{{*/
[ [
["activate"], ["activate"],
["activate"], ["activate"],
"Define when tabs are automatically activated<br/>" + "Define when tabs are automatically activated",
"Not implemented yet", "Not implemented yet",
"stringlist",
null,
function(value) { set_pref("activate", value); }, function(value) { set_pref("activate", value); },
function() { return get_pref("activate"); }, function() { return get_pref("activate"); },
"stringlist",
"quickmark,tabopen,paste", "quickmark,tabopen,paste",
null,
null null
], ],
[ [
["beep", "nobeep"], ["beep", "nobeep"],
["beep"], ["beep"],
"Emit a pc speaker beep on certain errors", "Emit a pc speaker beep on certain errors",
null,
"boolean",
null,
function(value) { set_pref("beep", value); }, function(value) { set_pref("beep", value); },
function() { return get_pref("beep"); }, function() { return get_pref("beep"); },
"boolean",
true, true,
null,
null null
], ],
[ [
["complete", "cpt"], ["complete", "cpt"],
["complete", "cpt"], ["complete", "cpt"],
"Order and items which are completed at the :[tab]open prompt<br/>" + "Items which are completed at the :[tab]open prompt",
"Available items:<br>"+ "Available items:<br>"+
"<ul><li><b>s</b>: Search machines</li><li>"+ "<ul><li><b>s</b>: Search machines</li><li>"+
" <b>b</b>: Bookmarks</li><li>"+ " <b>b</b>: Bookmarks</li><li>"+
" <b>h</b>: History</li></ul>"+ " <b>h</b>: History</li></ul>"+
"The order is important, so <code class=command>:set complete=bs</code> would list bookmarks first, and then any available quick searches.", "The order is important, so <code class=command>:set complete=bs</code> would list bookmarks first, and then any available quick searches.<br/>"+
"Set the <code class=setting>'wildsort'</code> setting if you want all entries sorted.",
"charlist",
null,
function(value) { set_pref("complete", value); }, function(value) { set_pref("complete", value); },
function() { return get_pref("complete"); }, function() { return get_pref("complete"); },
"charlist",
"sbh", "sbh",
null,
null null
], ],
[ [
["extendedhinttags", "eht"], ["extendedhinttags", "eht"],
["extendedhinttags", "eht"], ["extendedhinttags", "eht"],
"XPath string of hintable elements activated by ';'<br/>", "XPath string of hintable elements activated by ';'",
null,
"string",
null,
function(value) { set_pref("extendedhinttags", value); }, function(value) { set_pref("extendedhinttags", value); },
function() { return get_pref("extendedhinttags"); }, function() { return get_pref("extendedhinttags"); },
"string",
"//*[@onclick or @onmouseover or @onmousedown or @onmouseup or @oncommand or @class='lk' or @class='s'] | //input[@type!='hidden' or not(boolean(@type))] | //a | //area | //iframe | //textarea | //button | //select", "//*[@onclick or @onmouseover or @onmousedown or @onmouseup or @oncommand or @class='lk' or @class='s'] | //input[@type!='hidden' or not(boolean(@type))] | //a | //area | //iframe | //textarea | //button | //select",
null,
null null
], ],
[ [
["focusedhintstyle", "fhs"], ["focusedhintstyle", "fhs"],
["focusedhintstyle", "fhs"], ["focusedhintstyle", "fhs"],
"CSS specification of focused hints appearance", "CSS specification of focused hints appearance",
"null",
"string",
null,
function(value) { set_pref("focusedhintstyle", value); }, function(value) { set_pref("focusedhintstyle", value); },
function() { return get_pref("focusedhintstyle"); }, function() { return get_pref("focusedhintstyle"); },
"string",
"z-index:5000;font-family:monospace;font-size:12px;color:ButtonText;background-color:ButtonShadow;border-color:ButtonShadow;border-width:1px;border-style:solid;padding:0px 1px 0px 1px;position:absolute;", "z-index:5000;font-family:monospace;font-size:12px;color:ButtonText;background-color:ButtonShadow;border-color:ButtonShadow;border-width:1px;border-style:solid;padding:0px 1px 0px 1px;position:absolute;",
null,
null null
], ],
[ [
["fullscreen", "fs", "nofullscreen", "nofs"], ["fullscreen", "fs", "nofullscreen", "nofs"],
["fullscreen", "fs"], ["fullscreen", "fs"],
"Shows the current window fullscreen", "Shows the current window fullscreen",
null,
"boolean",
null,
function(value) { opt_fullscreen = value; BrowserFullScreen(); }, function(value) { opt_fullscreen = value; BrowserFullScreen(); },
function() { return opt_fullscreen; }, function() { return opt_fullscreen; },
"boolean",
false, false,
null,
null null
], ],
[ [
["guioptions", "go"], ["guioptions", "go"],
["guioptions", "go"], ["guioptions", "go"],
"Shows or hides the menu, toolbar and scrollbars<br/>" + "Shows or hides the menu, toolbar and scrollbars",
"Supported characters:<br><ul><li><b>m</b>: menubar</li><li><b>T</b>: toolbar<li><b>b</b>: bookmark bar</li><li><b>s</b>: original Firefox statusbar</ul>", "Supported characters:<br><ul><li><b>m</b>: menubar</li><li><b>T</b>: toolbar<li><b>b</b>: bookmark bar</li><li><b>s</b>: original Firefox statusbar</ul>",
"charlist",
null,
function(value) { set_pref("guioptions", value); set_guioptions(value); }, function(value) { set_pref("guioptions", value); set_guioptions(value); },
function() { return get_pref("guioptions"); }, function() { return get_pref("guioptions"); },
"charlist",
"", "",
null,
null null
], ],
[ [
["hintchars", "hc"], ["hintchars", "hc"],
["hintchars", "hc"], ["hintchars", "hc"],
"String of single characters which can be used to follow hints", "String of single characters which can be used to follow hints",
"charlist",
null,
function(value) { set_pref("hintchars", value); }, function(value) { set_pref("hintchars", value); },
function() { return get_pref("hintchars"); }, function() { return get_pref("hintchars"); },
"charlist",
"hjklasdfgyuiopqwertnmzxcvb", "hjklasdfgyuiopqwertnmzxcvb",
null,
null null
], ],
[ [
["hintstyle", "hs"], ["hintstyle", "hs"],
["hintstyle", "hs"], ["hintstyle", "hs"],
"CSS specification of unfocused hints appearance", "CSS specification of unfocused hints appearance",
null,
"string",
null,
function(value) { set_pref("hintstyle", value); }, function(value) { set_pref("hintstyle", value); },
function() { return get_pref("hintstyle"); }, function() { return get_pref("hintstyle"); },
"string",
"z-index:5000;font-family:monospace;font-size:12px;color:black;background-color:yellow;border-color:ButtonShadow;border-width:0px;border-style:solid;padding:0px 1px 0px 1px;position:absolute;", "z-index:5000;font-family:monospace;font-size:12px;color:black;background-color:yellow;border-color:ButtonShadow;border-width:0px;border-style:solid;padding:0px 1px 0px 1px;position:absolute;",
null,
null null
], ],
[ [
["hinttags"], ["hinttags"],
["hinttags"], ["hinttags"],
"XPath string of hintable elements activated by 'f'", "XPath string of hintable elements activated by <code class=mapping>'f'</code> and <code class=mapping>'F'</code>",
null,
"string",
null,
function(value) { set_pref("hinttags", value); }, function(value) { set_pref("hinttags", value); },
function() { return get_pref("hinttags"); }, function() { return get_pref("hinttags"); },
"string",
"//*[@onclick or @onmouseover or @onmousedown or @onmouseup or @oncommand or @class='lk' or @class='s'] | //input[@type!='hidden'] | //a | //area | //iframe | //textarea | //button | //select", "//*[@onclick or @onmouseover or @onmousedown or @onmouseup or @oncommand or @class='lk' or @class='s'] | //input[@type!='hidden'] | //a | //area | //iframe | //textarea | //button | //select",
null,
null null
], ],
[ [
["maxhints", "mh"], ["maxhints", "mh"],
["maxhints", "mh"], ["maxhints", "mh"],
"Maximum of simultanously shown hints<br/>" + "Maximum number of simultanously shown hints",
"If you want to speed up display of hints, choose a smaller value", "If you want to speed up display of hints, choose a smaller value",
"number",
null,
function(value) { set_pref("maxhints", value); }, function(value) { set_pref("maxhints", value); },
function() { return get_pref("maxhints"); }, function() { return get_pref("maxhints"); },
"number",
250, 250,
function (value) { if (value>=1 && value <=1000) return true; else return false; }, function (value) { if (value>=1 && value <=1000) return true; else return false; }
null
], ],
[ [
["preload", "nopreload"], ["preload", "nopreload"],
["preload"], ["preload"],
"Speed up first time history/bookmark completion<br/>" + "Speed up first time history/bookmark completion",
"History access can be quite slow for a large history. Vimperator maintains a cache to speed it up significantly on subsequent access.<br>"+ "History access can be quite slow for a large history. Vimperator maintains a cache to speed it up significantly on subsequent access.<br>"+
"In order to also speed up first time access, it is cached at startup, if this option is set (recommended).", "In order to also speed up first time access, it is cached at startup, if this option is set (recommended).",
"boolean",
null,
function(value) { set_pref("preload", value); }, function(value) { set_pref("preload", value); },
function() { return get_pref("preload"); }, function() { return get_pref("preload"); },
"boolean",
true, true,
null,
null null
], ],
[ [
["previewheight", "pvh"], ["previewheight", "pvh"],
["previewheight", "pvh"], ["previewheight", "pvh"],
"Default height for preview window<br/>" + "Default height for preview window",
"Value must be between 1 and 50. If the value is too high, completions may cover the command-line. Close the preview window with <code class=command>:pclose</close>.", "Value must be between 1 and 50. If the value is too high, completions may cover the command-line. Close the preview window with <code class=command>:pclose</close>.",
"number",
null,
function(value) { set_pref("previewheight", value); }, function(value) { set_pref("previewheight", value); },
function() { return get_pref("previewheight"); }, function() { return get_pref("previewheight"); },
"number",
10, 10,
function (value) { if (value>=1 && value <=50) return true; else return false; }, function (value) { if (value>=1 && value <=50) return true; else return false; }
null
], ],
[ [
["showmode", "smd", "noshowmode", "nosmd"], ["showmode", "smd", "noshowmode", "nosmd"],
["showmode", "smd"], ["showmode", "smd"],
"Show the current mode in the command line", "Show the current mode in the command line",
null,
"boolean",
null,
function(value) { set_pref("showmode", value); }, function(value) { set_pref("showmode", value); },
function() { return get_pref("showmode"); }, function() { return get_pref("showmode"); },
"boolean",
true, true,
null,
null null
], ],
[ [
["showtabline", "stal"], ["showtabline", "stal"],
["showtabline", "stal"], ["showtabline", "stal"],
"Control when to show the tab bar of opened web pages<br/>" + "Control when to show the tab bar of opened web pages",
"Available items:<br>"+ "Available items:<br>"+
"<ul><li><b>0</b>: Never show tab bar</li><li>"+ "<ul><li><b>0</b>: Never show tab bar</li><li>"+
" <b>1</b>: Show tab bar only if more than one tab is open</li><li>"+ " <b>1</b>: Show tab bar only if more than one tab is open</li><li>"+
" <b>2</b>: Always show tab bar</li></ul>"+ " <b>2</b>: Always show tab bar</li></ul>"+
"Not implemented yet.", "Not implemented yet.",
"number",
null,
function(value) { set_pref("showtabline", value); set_showtabline(value); }, function(value) { set_pref("showtabline", value); set_showtabline(value); },
function() { return get_pref("showtabline"); }, function() { return get_pref("showtabline"); },
"number",
2, 2,
function (value) { if (value>=0 && value <=2) return true; else return false; }, function (value) { if (value>=0 && value <=2) return true; else return false; }
null
], ],
[ [
["usermode", "um", "nousermode", "noum"], ["usermode", "um", "nousermode", "noum"],
["usermode", "um"], ["usermode", "um"],
"Show current website with a minimal stylesheet to make it easily accessible<br/>" + "Show current website with a minimal stylesheet to make it easily accessible",
"Note that this is a local setting for now, later it may be split into a global and <code style=command>:setlocal</code> part", "Note that this is a local setting for now, later it may be split into a global and <code style=command>:setlocal</code> part",
"boolean",
null,
function(value) { opt_usermode = value; setStyleDisabled(value); }, function(value) { opt_usermode = value; setStyleDisabled(value); },
function() { return opt_usermode; }, function() { return opt_usermode; },
"boolean",
false, false,
null,
null null
], ],
[ [
["wildmode", "wim"], ["wildmode", "wim"],
["wildmode", "wim"], ["wildmode", "wim"],
"Defines how command line completion works<br/>" + "Define how command line completion works",
"It is a comma-separated list of parts, where each part specifies" + "It is a comma-separated list of parts, where each part specifies" +
"what to do for each consecutive use of the completion key. The first part" + "what to do for each consecutive use of the completion key. The first part" +
"specifies the behavior for the first use of the completion key, the second part" + "specifies the behavior for the first use of the completion key, the second part" +
@@ -238,43 +253,43 @@ var g_settings = [/*{{{*/
"<tr><td><b>'list:longest'</b></td><td>When more than one match, list all matches and complete till the longest common string.</td></tr>" + "<tr><td><b>'list:longest'</b></td><td>When more than one match, list all matches and complete till the longest common string.</td></tr>" +
"</tbody></table>" + "</tbody></table>" +
"When there is only a single match, it is fully completed regardless of the case.", "When there is only a single match, it is fully completed regardless of the case.",
"stringlist",
null,
function(value) { set_pref("wildmode", value); }, function(value) { set_pref("wildmode", value); },
function() { return get_pref("wildmode"); }, function() { return get_pref("wildmode"); },
"stringlist",
"list:full", "list:full",
null,
null null
], ],
[ [
["wildsort", "wis", "nowildsort", "nowis"], ["wildsort", "wis", "nowildsort", "nowis"],
["wildsort", "wis"], ["wildsort", "wis"],
"Defines whether command line completion is sorted<br/>" + "Define whether command line completion is sorted",
"If you don't want a sorted completion list, set this to false.", "If you don't want a sorted completion list, set this to false.",
"boolean",
null,
function(value) { set_pref("wildsort", value); }, function(value) { set_pref("wildsort", value); },
function() { return get_pref("wildsort"); }, function() { return get_pref("wildsort"); },
"boolean",
false, false,
null,
null null
] ]
]/*}}}*/ ]/*}}}*/
// return null, if the cmd cannot be found in our g_settings array, or // return null, if the cmd cannot be found in our g_settings array, or
// otherwise a refernce to our command // otherwise a refernce to our command
function get_setting(cmd) function get_setting(cmd)/*{{{*/
{ {
for (var i=0; i < g_settings.length; i++) for (var i=0; i < g_settings.length; i++)
{ {
for (var j=0; j < g_settings[i][0].length; j++) for (var j=0; j < g_settings[i][COMMANDS].length; j++)
{ {
if (g_settings[i][0][j] == cmd) if (g_settings[i][COMMANDS][j] == cmd)
{ {
return g_settings[i]; return g_settings[i];
} }
} }
} }
return null; return null;
} }/*}}}*/
///////////////////////////////////////////////// /////////////////////////////////////////////////
// preference getter functions ///////////// {{{1 // preference getter functions ///////////// {{{1
@@ -294,9 +309,9 @@ function get_pref(name, forced_default)
{ {
for (var i=0; i<g_settings.length; i++) for (var i=0; i<g_settings.length; i++)
{ {
if (g_settings[i][0][0] == name) // only first name is searched if (g_settings[i][COMMANDS][0] == name) // only first name is searched
{ {
default_value = g_settings[i][6]; default_value = g_settings[i][DEFAULT];
break; break;
} }
} }

View File

@@ -26,7 +26,7 @@ the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL. the terms of any one of the MPL, the GPL or the LGPL.
}}} ***** END LICENSE BLOCK *****/ }}} ***** END LICENSE BLOCK *****/
var g_vimperator_version = "0.4 (CVS) [new vimperator-guid]"; var g_vimperator_version = "0.4 (CVS) [>=28/04/2007]";
const MODE_NORMAL = 1; const MODE_NORMAL = 1;
const MODE_INSERT = 2; const MODE_INSERT = 2;
@@ -430,9 +430,9 @@ function onVimperatorKeypress(event)/*{{{*/
for (var i in g_mappings) for (var i in g_mappings)
{ {
// each internal mapping can have multiple keys // each internal mapping can have multiple keys
for (var j in g_mappings[i][0]) for (var j in g_mappings[i][COMMANDS])
{ {
var mapping = g_mappings[i][0][j]; var mapping = g_mappings[i][COMMANDS][j];
// alert("key: " + key +" - mapping: "+ mapping + " - g_input: " + g_inputbuffer); // alert("key: " + key +" - mapping: "+ mapping + " - g_input: " + g_inputbuffer);
if(count_str + mapping == g_inputbuffer + key) if(count_str + mapping == g_inputbuffer + key)
{ {
@@ -441,8 +441,8 @@ function onVimperatorKeypress(event)/*{{{*/
g_count = -1; g_count = -1;
// allow null (= no operation) mappings // allow null (= no operation) mappings
if(g_mappings[i][3] != null) if(g_mappings[i][FUNCTION] != null)
g_mappings[i][3].call(this, g_count); g_mappings[i][FUNCTION].call(this, g_count);
// command executed, reset input buffer // command executed, reset input buffer
g_inputbuffer = ""; g_inputbuffer = "";
@@ -576,18 +576,21 @@ function onCommandBarKeypress(evt)/*{{{*/
} }
else // dynamically get completions as specified in the g_commands array else // dynamically get completions as specified in the g_commands array
{ {
if (command && command[4]) if (command && command[COMPLETEFUNC])
{ {
g_completions = command[4].call(this, args); g_completions = command[COMPLETEFUNC].call(this, args);
// Sort the completion list // Sort the completion list
if (get_pref('wildsort')) if (get_pref('wildsort'))
{
g_completions.sort(function(a, b) { g_completions.sort(function(a, b) {
if (a[0] < b[0]) if (a[0] < b[0])
return -1; return -1;
else if (a[0] > b[0]) else if (a[0] > b[0])
return 1; return 1;
else return 0; else
return 0;
}); });
}
} }
} }
} }