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

[+-] support for settings

This commit is contained in:
Martin Stubenschrott
2007-04-18 11:06:35 +00:00
parent 67aa5305e8
commit 415a9119cc
4 changed files with 28 additions and 9 deletions

View File

@@ -2,6 +2,7 @@
date: date:
* version 0.4 * version 0.4
* added :edit, :e and :tabedit aliases for :open, :tabopen * added :edit, :e and :tabedit aliases for :open, :tabopen
* settings can now be changed with += and -= like in vim (patch from Виктор Кожухаров)
* :open without argument reloads current page, :tabopen opens an empty tab * :open without argument reloads current page, :tabopen opens an empty tab
* added 'n' and 'N' to repeat a search * added 'n' and 'N' to repeat a search

1
TODO
View File

@@ -7,6 +7,7 @@ BUGS:
- hints are not placed correctly when zoom is used - hints are not placed correctly when zoom is used
- flashing frame is not perfect - flashing frame is not perfect
- The RSS feed button in the address bar no longer works. - The RSS feed button in the address bar no longer works.
- autoupdate does not work
FEATURES: FEATURES:
9 marks of a Location (also should work with directories), [m a-zA-Z] to set it, [' a-zA-Z] to go there 9 marks of a Location (also should work with directories), [m a-zA-Z] to set it, [' a-zA-Z] to go there

View File

@@ -31,8 +31,8 @@ the terms of any one of the MPL, the GPL or the LGPL.
* [ * [
* 0: [all names of this command], * 0: [all names of this command],
* 1: description, * 1: description,
* 2: function (arguments in this order: args, special, count) * 2: helptext
* 3: helptext * 3: function (arguments in this order: args, special, count)
* 4: completefunc * 4: completefunc
* ] * ]
*/ */
@@ -231,7 +231,7 @@ var g_commands = [/*{{{*/
"Boolean options must be set with <code>:set option</code> and <code>:set nooption</code>.<br>"+ "Boolean options must be set with <code>:set option</code> and <code>:set nooption</code>.<br>"+
"<code>:set</code> without an argument opens <code>about:config</code> in a new tab to change advanced Firefox options.<br>"+ "<code>:set</code> without an argument opens <code>about:config</code> in a new tab to change advanced Firefox options.<br>"+
"<code>:set!</code> opens the GUI preference panel from Firefox in a new tab.<br>"+ "<code>:set!</code> opens the GUI preference panel from Firefox in a new tab.<br>"+
"<code>:set option?</code> shows the current value of the option.<br>"+ "<code>:set option?</code> or <code>:set option</code> shows the current value of the option.<br>"+
"<code>:set option+=foo</code> and <code>:set option-=foo</code> WILL add/remove foo from list options.<br>", "<code>:set option+=foo</code> and <code>:set option-=foo</code> WILL add/remove foo from list options.<br>",
function(args, special) { set(args, special); }, function(args, special) { set(args, special); },
function(filter) { return get_settings_completions(filter); } function(filter) { return get_settings_completions(filter); }
@@ -296,7 +296,7 @@ var g_commands = [/*{{{*/
["version", "ve"], ["version", "ve"],
"Show version information", "Show version information",
null, null,
function () { echo("Vimperator version: 0.2.0.1"); }, function () { echo("Vimperator version: " + g_vimperator_version); },
null null
], ],
[ [
@@ -1340,7 +1340,7 @@ function set(args, special)
} }
else else
{ {
var matches = args.match(/^\s*(no)?([a-z]+)(\?)?(=(.*))?/); var matches = args.match(/^\s*(no)?([a-z]+)(\?)?(([+-])?=(.*))?/);
if (!matches) if (!matches)
{ {
echoerr("E518: Unknown option: " + args); echoerr("E518: Unknown option: " + args);
@@ -1349,9 +1349,6 @@ function set(args, special)
var no = true; if (matches[1] == undefined) no = false; var no = true; if (matches[1] == undefined) no = false;
var opt = matches[2]; var opt = matches[2];
var get = false; if (matches[3] != undefined) get = true;
var val = matches[5]; if (val == undefined) val = "";
var setting = get_setting(opt); var setting = get_setting(opt);
if (!setting) if (!setting)
{ {
@@ -1359,6 +1356,11 @@ function set(args, special)
return; return;
} }
var get = false; if (matches[3] != undefined ||
(setting[5] != 'boolean' && matches[4] == undefined)) get = true;
var oper = matches[5];
var val = matches[6]; if (val == undefined) val = "";
// read access // read access
if (get) if (get)
{ {
@@ -1380,6 +1382,9 @@ function set(args, special)
echoerr("Invalid argument type to option " + setting[0][0] + ": Expects number"); echoerr("Invalid argument type to option " + setting[0][0] + ": Expects number");
else else
{ {
var cur_val = setting[4].call(this);
if (oper == '+') num = cur_val + num;
if (oper == '-') num = cur_val - num;
if (setting[7] != null && setting[7].call(this, num) == false) if (setting[7] != null && setting[7].call(this, num) == false)
echoerr("Invalid argument to option " + setting[0][0] + ": Check help for more details"); echoerr("Invalid argument to option " + setting[0][0] + ": Check help for more details");
else // all checks passed, execute option handler else // all checks passed, execute option handler
@@ -1388,7 +1393,17 @@ function set(args, special)
} }
else if (type == "charlist" || type == "stringlist" || type == "string") else if (type == "charlist" || type == "stringlist" || type == "string")
{ {
if (setting[7] != null && setting[7].call(this, num) == false) var cur_val = setting[4].call(this);
if (type == "charlist" || type == "string") {
if (oper == '+' && !cur_val.match(val))
val = cur_val + val;
if (oper == '-') val = cur_val.replace(val, '');
} else {
if (oper == '+' && !cur_val.match(val))
val = cur_val + ',' + val;
if (oper == '-') val = cur_val.replace(new RegExp(',?' + val), '');
}
if (setting[7] != null && setting[7].call(this, val) == false)
echoerr("Invalid argument to option " + setting[0][0] + ": Check help for more details"); echoerr("Invalid argument to option " + setting[0][0] + ": Check help for more details");
else // all checks passed, execute option handler else // all checks passed, execute option handler
setting[3].call(this, val); setting[3].call(this, val);

View File

@@ -26,6 +26,8 @@ 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.3";
const MODE_NORMAL = 1; const MODE_NORMAL = 1;
const MODE_INSERT = 2; const MODE_INSERT = 2;
const MODE_VISUAL = 4; const MODE_VISUAL = 4;