1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-06 15:44:12 +01:00

Add named groups (a la Python) to util.regexp.

This commit is contained in:
Kris Maglione
2011-01-12 12:25:46 -05:00
parent d6e22872d3
commit c3a90cf2b3
10 changed files with 68 additions and 51 deletions

View File

@@ -1049,18 +1049,16 @@ var Commands = Module("commands", {
validName: Class.memoize(function () RegExp("^" + this.nameRegexp.source + "$")),
CommandMatch: Struct("match", "spec", "prespace", "count", "cmd", "bang", "space", "args"),
commandRegexp: Class.memoize(function () util.regexp(<![CDATA[
^
(
([:\s]*)
( (?:\d+ | %)? )
( (?:<name> | !)? )
(!?)
(\s*)
(?P<spec>
(?P<prespace> [:\s]*)
(?P<count> (?:\d+ | %)? )
(?P<cmd> (?:<name> | !)? )
(?P<bang> !?)
(?P<space> \s*)
)
(
(?P<args>
(?:. | \n)*?
)?
$
@@ -1229,7 +1227,6 @@ var Commands = Module("commands", {
let match = commands.commandRegexp.exec(args.commandString);
if (!match)
return;
match = commands.CommandMatch.apply(null, match);
context.advance(match.prespace.length + match.count.length);
if (!(match.bang || match.space)) {

View File

@@ -51,7 +51,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
autocommands.trigger("Leave", {});
},
observe: {
observers: {
"dactyl-cleanup": function () {
let modules = dactyl.modules;

View File

@@ -126,7 +126,7 @@ var Marks = Module("marks", {
let items = array(util.range(0, sh.count));
let a = items.slice(0, sh.index).reverse();
let b = items.slice(sh.index, sh.count);
let b = items.slice(sh.index);
a.length = b.length = Math.max(a.length, b.length);
items = array(a).zip(b).flatten().compact();

View File

@@ -38,13 +38,13 @@ var StatusLine = Module("statusline", {
let prepend = <e4x xmlns={XUL} xmlns:dactyl={NS}>
<statusbar id="status-bar" highlight="StatusLine">
<!-- insertbefore="dactyl.statusBefore;" insertafter="dactyl.statusAfter;" -->
<hbox key="container" hidden="false" align="center" flex="1">
<stack orient="horizontal" align="stretch" flex="1" class="dactyl-container" highlight="CmdLine StatusCmdLine">
<hbox class="dactyl-container" highlight="CmdLine StatusCmdLine">
<label key="mode" crop="end" class="plain" collapsed="true"/>
<stack flex="1" class="dactyl-container" highlight="CmdLine StatusCmdLine">
<textbox key="url" crop="end" flex="1" class="plain dactyl-status-field-url" readonly="true"/>
<textbox key="message" crop="end" flex="1" class="plain" highlight="Normal StatusNormal" readonly="true"/>
<hbox key="container" hidden="false" align="center" flex="1">
<stack orient="horizontal" align="stretch" flex="1" highlight="CmdLine StatusCmdLine" class="dactyl-container">
<hbox highlight="CmdLine StatusCmdLine" class="dactyl-container">
<label key="mode" crop="end" class="plain" collapsed="true"/>
<stack flex="1" highlight="CmdLine StatusCmdLine" class="dactyl-container">
<textbox key="url" crop="end" flex="1" class="plain dactyl-status-field-url" readonly="true"/>
<textbox key="message" crop="end" flex="1" highlight="Normal StatusNormal" class="plain" readonly="true"/>
</stack>
</hbox>