mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-06 14:35:46 +01:00
added new hint color options and a new hintmatching option (thanks Daniel)
This commit is contained in:
1
AUTHORS
1
AUTHORS
@@ -11,6 +11,7 @@ Inactive/former developers:
|
||||
* Viktor Kojouharov (Виктор Кожухаров)
|
||||
|
||||
Patches (in no special order):
|
||||
* Daniel Trstenjak (various things with hints)
|
||||
* M.Terada (suggest engines)
|
||||
* Muthu Kannan (ctrl-v support)
|
||||
* Lars Kindler (:buffer(s) functionality)
|
||||
|
||||
@@ -8,7 +8,7 @@ DOC_SRC_FILES = $(wildcard locale/*/*.txt)
|
||||
DOC_FILES = ${DOC_SRC_FILES:%.txt=%.html}
|
||||
|
||||
# TODO: specify source files manually?
|
||||
JAR_TXT_FILES = ${shell find content skin locale \
|
||||
JAR_TXT_FILES = ${shell find -L content skin locale \
|
||||
-type f \
|
||||
-a ! -path '*CVS*' \
|
||||
-a \( \
|
||||
|
||||
146
content/hints.js
146
content/hints.js
@@ -89,15 +89,7 @@ liberator.Hints = function () //{{{
|
||||
var scrollY = doc.defaultView.scrollY;
|
||||
|
||||
var baseNodeAbsolute = doc.createElementNS("http://www.w3.org/1999/xhtml", "span");
|
||||
baseNodeAbsolute.style.backgroundColor = "red";
|
||||
baseNodeAbsolute.style.color = "white";
|
||||
baseNodeAbsolute.style.position = "absolute";
|
||||
baseNodeAbsolute.style.fontSize = "10px";
|
||||
baseNodeAbsolute.style.fontWeight = "bold";
|
||||
baseNodeAbsolute.style.lineHeight = "10px";
|
||||
baseNodeAbsolute.style.padding = "0px 1px 0px 0px";
|
||||
baseNodeAbsolute.style.zIndex = "10000001";
|
||||
baseNodeAbsolute.style.display = "none";
|
||||
baseNodeAbsolute.style.cssText = liberator.options["hintstyle"];
|
||||
baseNodeAbsolute.className = "liberator-hint";
|
||||
|
||||
var elem, tagname, text, span, rect;
|
||||
@@ -155,11 +147,76 @@ liberator.Hints = function () //{{{
|
||||
{
|
||||
var oldElem = validHints[oldID - 1];
|
||||
if (oldElem)
|
||||
oldElem.style.backgroundColor = "yellow";
|
||||
oldElem.style.backgroundColor = liberator.options["linkbgcolor"];
|
||||
|
||||
var newElem = validHints[newID - 1];
|
||||
if (newElem)
|
||||
newElem.style.backgroundColor = "#88FF00";
|
||||
newElem.style.backgroundColor = liberator.options["activelinkbgcolor"];
|
||||
}
|
||||
|
||||
function containsTokensMatcher(hintString)
|
||||
{
|
||||
var tokens = hintString.split(/ +/);
|
||||
|
||||
function containsTokens(textOfLink)
|
||||
{
|
||||
for (var i = 0; i < tokens.length; i++)
|
||||
{
|
||||
if (textOfLink.indexOf(tokens[i]) < 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return containsTokens;
|
||||
}
|
||||
|
||||
function wordBoundaryMatcher(hintString)
|
||||
{
|
||||
var tokens = hintString.split(/ +/);
|
||||
var regexs = [];
|
||||
for (var i = 0; i < tokens.length; i++)
|
||||
regexs[i] = new RegExp((tokens[i] == "" ? ".*" : ("\\b" + tokens[i] + ".*")));
|
||||
|
||||
function wordBoundary(textOfLink)
|
||||
{
|
||||
for (var i = 0; i < tokens.length; i++)
|
||||
{
|
||||
if (! regexs[i].test(textOfLink))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return wordBoundary;
|
||||
}
|
||||
|
||||
function startsWithMatcher(hintString)
|
||||
{
|
||||
var regex = new RegExp((hintString == "" ? ".*" : ("^\\s*" + hintString + ".*")));
|
||||
|
||||
function startsWith(textOfLink)
|
||||
{
|
||||
return (regex.test(textOfLink));
|
||||
}
|
||||
|
||||
return startsWith;
|
||||
}
|
||||
|
||||
function hintMatcher(hintString)
|
||||
{
|
||||
var hintMatching = liberator.options["hintmatching"];
|
||||
switch (hintMatching)
|
||||
{
|
||||
case "contains": return containsTokensMatcher(hintString);
|
||||
case "startswith": return startsWithMatcher(hintString);
|
||||
case "wordboundary": return wordBoundaryMatcher(hintString);
|
||||
default:
|
||||
liberator.echoerr("Invalid hintmatching type: " + hintMatching);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function showHints()
|
||||
@@ -169,11 +226,16 @@ liberator.Hints = function () //{{{
|
||||
var height = win.innerHeight;
|
||||
var width = win.innerWidth;
|
||||
|
||||
liberator.log("Show hints matching: " + hintString, 7);
|
||||
liberator.log("Show hints matching: \"" + hintString + "\"", 7);
|
||||
|
||||
var linkfgcolor = liberator.options["linkfgcolor"];
|
||||
var linkbgcolor = liberator.options["linkbgcolor"];
|
||||
var activelinkfgcolor = liberator.options["activelinkfgcolor"];
|
||||
var activelinkbgcolor = liberator.options["activelinkbgcolor"];
|
||||
|
||||
var elem, tagname, text, rect, span, imgspan;
|
||||
var hintnum = 1;
|
||||
var findTokens = hintString.split(/ +/);
|
||||
var validHint = hintMatcher(hintString);
|
||||
var activeHint = hintNumber || 1;
|
||||
validHints = [];
|
||||
|
||||
@@ -193,19 +255,16 @@ liberator.Hints = function () //{{{
|
||||
span = hints[i][2];
|
||||
imgspan = hints[i][3];
|
||||
|
||||
for (var k = 0; k < findTokens.length; k++)
|
||||
if (! validHint(text))
|
||||
{
|
||||
if (text.indexOf(findTokens[k]) < 0)
|
||||
{
|
||||
span.style.display = "none";
|
||||
if (imgspan)
|
||||
imgspan.style.display = "none";
|
||||
span.style.display = "none";
|
||||
if (imgspan)
|
||||
imgspan.style.display = "none";
|
||||
|
||||
// reset background color
|
||||
elem.style.backgroundColor = hints[i][4];
|
||||
elem.style.color = hints[i][5];
|
||||
continue outer;
|
||||
}
|
||||
// reset background color
|
||||
elem.style.backgroundColor = hints[i][4];
|
||||
elem.style.color = hints[i][5];
|
||||
continue outer;
|
||||
}
|
||||
|
||||
if (text == "" && elem.firstChild && elem.firstChild.tagName == "IMG")
|
||||
@@ -228,13 +287,13 @@ liberator.Hints = function () //{{{
|
||||
hints[i][3] = imgspan;
|
||||
doc.body.appendChild(imgspan);
|
||||
}
|
||||
imgspan.style.backgroundColor = (activeHint == hintnum) ? "#88FF00" : "yellow";
|
||||
imgspan.style.backgroundColor = (activeHint == hintnum) ? activelinkbgcolor : linkbgcolor;
|
||||
imgspan.style.display = "inline";
|
||||
}
|
||||
|
||||
if (!imgspan)
|
||||
elem.style.backgroundColor = (activeHint == hintnum) ? "#88FF00" : "yellow";
|
||||
elem.style.color = "black";
|
||||
elem.style.backgroundColor = (activeHint == hintnum) ? activelinkbgcolor : linkbgcolor;
|
||||
elem.style.color = (activeHint == hintnum) ? activelinkfgcolor : linkfgcolor;
|
||||
span.textContent = "" + (hintnum++);
|
||||
span.style.display = "inline";
|
||||
validHints.push(elem);
|
||||
@@ -404,15 +463,15 @@ liberator.Hints = function () //{{{
|
||||
liberator.options.add(["extendedhinttags", "eht"],
|
||||
"XPath string of hintable elements activated by ';'",
|
||||
"string", DEFAULT_HINTTAGS);
|
||||
liberator.options.add(["focusedhintstyle", "fhs"],
|
||||
"CSS specification of focused hints",
|
||||
"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;");
|
||||
|
||||
liberator.options.add(["hintstyle", "hs"],
|
||||
"CSS specification of unfocused hints",
|
||||
"string", "z-index:5000; font-family:monospace; font-size:12px; color:white; background-color:red; border-color:ButtonShadow; border-width:0px; border-style:solid; padding:0px 1px 0px 1px; position:absolute;");
|
||||
"string", "z-index:5000; font-family:monospace; font-size:10px; font-weight: bold; color:white; background-color:red; border-color:ButtonShadow; border-width:0px; border-style:solid; padding:0px 1px 0px 1px; position:absolute;");
|
||||
|
||||
liberator.options.add(["hinttags", "ht"],
|
||||
"XPath string of hintable elements activated by 'f' and 'F'",
|
||||
"string", DEFAULT_HINTTAGS);
|
||||
|
||||
liberator.options.add(["hinttimeout", "hto"],
|
||||
"Automatically follow non unique numerical hint",
|
||||
"number", 0,
|
||||
@@ -420,7 +479,30 @@ liberator.Hints = function () //{{{
|
||||
validator: function (value) { return value >= 0; }
|
||||
});
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////}}}
|
||||
liberator.options.add(["linkfgcolor", "lfc"],
|
||||
"Foreground color of a link during hint mode",
|
||||
"string", "black");
|
||||
|
||||
liberator.options.add(["linkbgcolor", "lbc"],
|
||||
"Background color of a link during hint mode",
|
||||
"string", "yellow");
|
||||
|
||||
liberator.options.add(["activelinkfgcolor", "alfc"],
|
||||
"Foreground color of the current active link during hint mode",
|
||||
"string", "black");
|
||||
|
||||
liberator.options.add(["activelinkbgcolor", "albc"],
|
||||
"Background color of the current active link during hint mode",
|
||||
"string", "#88FF00");
|
||||
|
||||
liberator.options.add(["hintmatching", "lm"],
|
||||
"How links are matched",
|
||||
"string", "contains",
|
||||
{
|
||||
validator: function (value) { return /^startswith|contains|wordboundary$/.test(value); }
|
||||
});
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
|
||||
|
||||
@@ -202,9 +202,25 @@ liberator.Mail = function ()
|
||||
function () { goDoCommand("cmd_forwardInline"); });
|
||||
|
||||
|
||||
liberator.mappings.add(modes, ["r"],
|
||||
"Reply to sender",
|
||||
function () { goDoCommand("cmd_reply"); });
|
||||
// UNDO/REDO
|
||||
liberator.mappings.add(modes, ["u"],
|
||||
"Undo",
|
||||
function ()
|
||||
{
|
||||
if (messenger.canUndo())
|
||||
messenger.undo(msgWindow);
|
||||
else
|
||||
liberator.beep();
|
||||
});
|
||||
liberator.mappings.add(modes, ["<C-r>"],
|
||||
"Redo",
|
||||
function ()
|
||||
{
|
||||
if (messenger.canRedo())
|
||||
messenger.redo(msgWindow);
|
||||
else
|
||||
liberator.beep();
|
||||
});
|
||||
|
||||
// GETTING MAIL
|
||||
liberator.mappings.add(modes, ["gm"],
|
||||
|
||||
@@ -89,7 +89,7 @@ liberator.config = {
|
||||
function () { liberator.commandline.open(":", "open ", liberator.modes.EX); });
|
||||
|
||||
// don't wait too long when selecting new messages
|
||||
GetThreadTree()._selectDelay = 250; // TODO: make configurable
|
||||
GetThreadTree()._selectDelay = 300; // TODO: make configurable
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -172,12 +172,54 @@ or @oncommand or @class='lk' or @class='s'] |
|
||||
The XPath string of hintable elements activated by [m];[m].
|
||||
____
|
||||
|
||||
|\'fhs'| |\'focusedhintstyle'|
|
||||
||'focusedhintstyle' 'fhs'|| string
|
||||
|\'hs'| |\'hintstyle'|
|
||||
||'hintstyle' 'hs'|| string
|
||||
____
|
||||
(default: 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;)
|
||||
(default: z-index:5000; font-family:monospace; font-size:12px; color:white; background-color:red; border-color:ButtonShadow; border-width:0px; border-style:solid; padding:0px 1px 0px 1px; position:absolute;)
|
||||
|
||||
CSS specification of hints
|
||||
____
|
||||
|
||||
|\'lfc'| |\'linkfgcolor'|
|
||||
||'linkfgcolor' 'lfc'|| string (default: black)
|
||||
____
|
||||
|
||||
Foreground color of a link during hint mode.
|
||||
____
|
||||
|
||||
|\'lbc'| |\'linkbgcolor'|
|
||||
||'linkbgcolor' 'lbc'|| string (default: yellow)
|
||||
____
|
||||
|
||||
Background color of a link during hint mode.
|
||||
____
|
||||
|
||||
|\'alfc'| |\'activelinkfgcolor'|
|
||||
||'activelinkfgcolor' 'alfc'|| string (default: black)
|
||||
____
|
||||
|
||||
Foreground color of the current active link during hint mode.
|
||||
____
|
||||
|
||||
|\'albc'| |\'activelinkbgcolor'|
|
||||
||'activelinkbgcolor' 'albc'|| string (default: ##88FF00)
|
||||
____
|
||||
|
||||
Background color of the current active link during hint mode.
|
||||
____
|
||||
|
||||
|\'hm'| |\'hintmatching'|
|
||||
||'hintmatching' 'hm'|| string (default: contains)
|
||||
____
|
||||
|
||||
Change the hint matching algorithm during hint mode. Possible values:
|
||||
|
||||
`--------------`------------------------------------------------------------------------------------------------------------------------
|
||||
*contains* The typed characters are splitted by spaces, and these character groups have to be anywhere inside the text of the link.
|
||||
*wordboundary* The typed characters are splitted by spaces, and these character groups must each match the start of a word of the link.
|
||||
*startswith* The typed characters have to be in the typed order at the beginning of the text of the link.
|
||||
----------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
CSS specification of focused hints
|
||||
____
|
||||
|
||||
|\'nofs'| |\'nofullscreen'| |\'fs'| |\'fullscreen'|
|
||||
|
||||
@@ -38,14 +38,15 @@ syn match vimperatorCommand "!" contained
|
||||
syn match vimperatorCommandWrapper "\%(^\s*:\=\)\@<=\%(!\|\h\w*\>\)" contains=vimperatorCommand
|
||||
|
||||
syn region vimperatorSet matchgroup=vimperatorCommand start="\%(^\s*:\=\)\@<=\<set\=\>" end="$" keepend oneline contains=vimperatorOption
|
||||
syn keyword vimperatorOption activate act complete cpt defsearch ds editor extendedhinttags eht focusedhintstyle fhs fullscreen fs
|
||||
\ nofullscreen nofs guioptions go hintstyle hs hinttags ht hinttimeout hto history hi hlsearch hls nohlsearch nohls
|
||||
\ hlsearchstyle hlss nohlsearchstyle nohlss incsearch is noincsearch nois ignorecase ic noignorecase noic insertmode im
|
||||
\ noinsertmode noim laststatus ls linksearch lks nolinksearch nolks more nextpattern nomore pageinfo pa popups pps preload
|
||||
\ nopreload previewheight pvh previouspattern scroll scr showmode smd noshowmode nosmd showstatuslinks ssli showtabline
|
||||
\ stal smartcase scs nosmartcase noscs titlestring usermode um nousermode noum verbose vbs visualbell vb novisualbell novb
|
||||
\ wildmode wim wildoptions wop
|
||||
\ contained
|
||||
syn keyword vimperatorOption activate act activelinkfgcolor alfc activelinkbgcolor albc complete cpt defsearch ds editor extendedhinttags eht
|
||||
\ fullscreen fs nofullscreen nofs guioptions go hintmatching hm hintstyle hs hinttags ht hinttimeout hto history hi
|
||||
\ hlsearch hls nohlsearch nohls hlsearchstyle hlss nohlsearchstyle nohlss incsearch is noincsearch nois ignorecase ic
|
||||
\ noignorecase noic insertmode im noinsertmode noim laststatus ls linkbgcolor lbc linkfgcolor lfc linksearch lks linkmatching lm
|
||||
\ nolinksearch nolks more nextpattern nomore pageinfo pa popups pps preload
|
||||
\ nopreload previewheight pvh previouspattern scroll scr showmode smd noshowmode nosmd showstatuslinks ssli showtabline
|
||||
\ stal smartcase scs nosmartcase noscs titlestring usermode um nousermode noum verbose vbs visualbell vb novisualbell novb
|
||||
\ wildmode wim wildoptions wop
|
||||
\ contained
|
||||
|
||||
syn region vimperatorJavascript start="\%(^\s*\%(javascript\|js\)\s\+\)\@<=" end="$" contains=@javascriptTop keepend oneline
|
||||
syn region vimperatorJavascript matchgroup=vimperatorJavascriptDelimiter
|
||||
@@ -70,4 +71,4 @@ let b:current_syntax = "vimperator"
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
||||
|
||||
" vim: tw=130:
|
||||
" vim: tw=130 et ts=4 sw=4:
|
||||
|
||||
Reference in New Issue
Block a user