mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-04-07 04:13:33 +02:00
merge new 'more' option and more-prompt improvements
This commit is contained in:
2
NEWS
2
NEWS
@@ -1,6 +1,8 @@
|
|||||||
<pre>
|
<pre>
|
||||||
2007-XX-XX:
|
2007-XX-XX:
|
||||||
* version 0.5.2
|
* version 0.5.2
|
||||||
|
* added 'more' and standard more-prompt key mappings to control
|
||||||
|
behaviour of the message list pager
|
||||||
* added 'hlsearchstyle' option to allow for user CSS styling of the
|
* added 'hlsearchstyle' option to allow for user CSS styling of the
|
||||||
highlighted text strings when 'hlsearch' is set
|
highlighted text strings when 'hlsearch' is set
|
||||||
* added 'linksearch' option to restrict page searches to link text - \U
|
* added 'linksearch' option to restrict page searches to link text - \U
|
||||||
|
|||||||
@@ -326,6 +326,7 @@ function Events() //{{{
|
|||||||
|
|
||||||
var key = null;
|
var key = null;
|
||||||
var modifier = "";
|
var modifier = "";
|
||||||
|
|
||||||
if (event.ctrlKey)
|
if (event.ctrlKey)
|
||||||
modifier += "C-";
|
modifier += "C-";
|
||||||
if (event.altKey)
|
if (event.altKey)
|
||||||
@@ -333,33 +334,61 @@ function Events() //{{{
|
|||||||
if (event.metaKey)
|
if (event.metaKey)
|
||||||
modifier += "M-";
|
modifier += "M-";
|
||||||
|
|
||||||
if (event.charCode == 0)
|
if (event.type == "keypress")
|
||||||
{
|
{
|
||||||
if (event.shiftKey)
|
if (event.charCode == 0)
|
||||||
modifier += "S-";
|
|
||||||
|
|
||||||
for (var i in keyTable)
|
|
||||||
{
|
{
|
||||||
if (keyTable[i][0] == event.keyCode)
|
if (event.shiftKey)
|
||||||
|
modifier += "S-";
|
||||||
|
|
||||||
|
for (var i in keyTable)
|
||||||
{
|
{
|
||||||
key = keyTable[i][1][0];
|
if (keyTable[i][0] == event.keyCode)
|
||||||
break;
|
{
|
||||||
|
key = keyTable[i][1][0];
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// special handling of the Space key
|
||||||
|
else if (event.charCode == 32)
|
||||||
|
{
|
||||||
|
if (event.shiftKey)
|
||||||
|
modifier += "S-";
|
||||||
|
key = "Space";
|
||||||
|
}
|
||||||
|
// a normal key like a, b, c, 0, etc.
|
||||||
|
else if (event.charCode > 0)
|
||||||
|
{
|
||||||
|
key = String.fromCharCode(event.charCode);
|
||||||
|
if (modifier.length == 0)
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
// special handling of the Space key
|
else if (event.type == "click" || event.type == "dblclick")
|
||||||
else if (event.charCode == 32)
|
|
||||||
{
|
{
|
||||||
if (event.shiftKey)
|
if (event.shiftKey)
|
||||||
modifier += "S-";
|
modifier += "S-";
|
||||||
key = "Space";
|
if (event.type == "dblclick")
|
||||||
}
|
modifier += "2-";
|
||||||
// a normal key like a, b, c, 0, etc.
|
// TODO: triple and quadruple click
|
||||||
else if (event.charCode > 0)
|
|
||||||
{
|
switch (event.button)
|
||||||
key = String.fromCharCode(event.charCode);
|
{
|
||||||
if (modifier.length == 0)
|
case 0:
|
||||||
return key;
|
key = "LeftMouse"
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
key = "MiddleMouse"
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
key = "RightMouse"
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key == null)
|
if (key == null)
|
||||||
@@ -367,6 +396,7 @@ function Events() //{{{
|
|||||||
|
|
||||||
// a key like F1 is always enclosed in < and >
|
// a key like F1 is always enclosed in < and >
|
||||||
return "<" + modifier + key + ">";
|
return "<" + modifier + key + ">";
|
||||||
|
|
||||||
} //}}}
|
} //}}}
|
||||||
|
|
||||||
this.isAcceptKey = function(key)
|
this.isAcceptKey = function(key)
|
||||||
@@ -449,6 +479,14 @@ function Events() //{{{
|
|||||||
; // let flow continue to handle these keys
|
; // let flow continue to handle these keys
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vimperator.hasMode(vimperator.modes.COMMAND_LINE) &&
|
||||||
|
vimperator.hasMode(vimperator.modes.WRITE_MULTILINE))
|
||||||
|
{
|
||||||
|
vimperator.commandline.onMultilineOutputEvent(event);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// // FIXME: handle middle click in content area {{{
|
// // FIXME: handle middle click in content area {{{
|
||||||
|
|||||||
@@ -465,6 +465,12 @@ function Options() //{{{
|
|||||||
default_value: false
|
default_value: false
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
addOption(new Option(["more"], "boolean",
|
||||||
|
{
|
||||||
|
short_help: "Pause the message list window when more than one screen of listings is displayed",
|
||||||
|
default_value: true
|
||||||
|
}
|
||||||
|
));
|
||||||
addOption(new Option(["maxhints", "mh"], "number",
|
addOption(new Option(["maxhints", "mh"], "number",
|
||||||
{
|
{
|
||||||
short_help: "Maximum number of simultaneously shown hints",
|
short_help: "Maximum number of simultaneously shown hints",
|
||||||
|
|||||||
@@ -133,7 +133,11 @@ function CommandLine() //{{{
|
|||||||
command_widget.value = cmd;
|
command_widget.value = cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setMultiline(cmd)
|
// TODO: the invoking command should be pasted at the top of the MOW and
|
||||||
|
// the MOW messages should actually be displayed in the commandline
|
||||||
|
// : extract CSS
|
||||||
|
// : resize upon a window resize
|
||||||
|
function setMultiline(str)
|
||||||
{
|
{
|
||||||
// TODO: we should retain any previous command output like Vim
|
// TODO: we should retain any previous command output like Vim
|
||||||
if (!multiline_output_widget.collapsed)
|
if (!multiline_output_widget.collapsed)
|
||||||
@@ -141,22 +145,42 @@ function CommandLine() //{{{
|
|||||||
|
|
||||||
multiline_input_widget.collapsed = true;
|
multiline_input_widget.collapsed = true;
|
||||||
|
|
||||||
// vimperator.log(content_height);
|
var output = str.replace(/\n|\\n/g, "<br/>");
|
||||||
cmd = cmd.replace(/\n|\\n/g, "<br/>") + "<br/><span style=\"color: green;\">Press ENTER or type command to continue</span>";
|
//output = ":" + command_widget.value + "<br/>" + output;
|
||||||
multiline_output_widget.contentDocument.body.innerHTML = cmd;
|
output += "<br/>"
|
||||||
|
output += '<span id="end-prompt" style="color: green; background-color: white;">Press ENTER or type command to continue</span>';
|
||||||
|
output += '<span id="more-prompt" style="display: none; position: fixed; top: auto; bottom: 0; left: 0; right: 0; color: green; background-color: white;">';
|
||||||
|
output += "-- More --";
|
||||||
|
output += '</span>';
|
||||||
|
output += '<span id="more-help-prompt" style="display: none; position: fixed; top: auto; bottom: 0; left: 0; right: 0; color: green; background-color: white;">';
|
||||||
|
output += "-- More -- SPACE/d/j: screen/page/line down, b/u/k: up, q: quit";
|
||||||
|
output += '</span>';
|
||||||
|
|
||||||
|
multiline_output_widget.contentDocument.body.innerHTML = output;
|
||||||
|
|
||||||
// TODO: resize upon a window resize
|
|
||||||
var available_height = getBrowser().mPanelContainer.boxObject.height;
|
var available_height = getBrowser().mPanelContainer.boxObject.height;
|
||||||
var content_height = multiline_output_widget.contentDocument.height;
|
var content_height = multiline_output_widget.contentDocument.height;
|
||||||
// vimperator.log(content_height);
|
|
||||||
var height = content_height < available_height ? content_height : available_height;
|
var height = content_height < available_height ? content_height : available_height;
|
||||||
|
|
||||||
//multiline_output_widget.style.height = height + "px";
|
//multiline_output_widget.style.height = height + "px";
|
||||||
multiline_output_widget.height = height + "px";
|
multiline_output_widget.height = height + "px";
|
||||||
multiline_output_widget.collapsed = false;
|
multiline_output_widget.collapsed = false;
|
||||||
//vimperator.log(content_height);
|
|
||||||
multiline_output_widget.contentWindow.scrollTo(0, content_height); // scroll to the end when 'nomore' is set
|
if (vimperator.options["more"] && multiline_output_widget.contentWindow.scrollMaxY > 0)
|
||||||
|
{
|
||||||
|
multiline_output_widget.contentWindow.document.getElementById("more-prompt").style.display = "inline";
|
||||||
|
multiline_output_widget.contentWindow.scrollTo(0, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
multiline_output_widget.contentWindow.scrollTo(0, content_height);
|
||||||
|
}
|
||||||
|
|
||||||
multiline_output_widget.contentWindow.focus();
|
multiline_output_widget.contentWindow.focus();
|
||||||
|
|
||||||
|
// save the mode, because we need to restore it on blur()
|
||||||
|
[old_mode, old_extended_mode] = vimperator.getMode();
|
||||||
|
vimperator.setMode(vimperator.modes.COMMAND_LINE, vimperator.modes.WRITE_MULTILINE, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function autosizeMultilineInputWidget()
|
function autosizeMultilineInputWidget()
|
||||||
@@ -311,7 +335,8 @@ function CommandLine() //{{{
|
|||||||
// prevent losing focus, there should be a better way, but it just didn't work otherwise
|
// prevent losing focus, there should be a better way, but it just didn't work otherwise
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
if (vimperator.hasMode(vimperator.modes.COMMAND_LINE) &&
|
if (vimperator.hasMode(vimperator.modes.COMMAND_LINE) &&
|
||||||
!vimperator.hasMode(vimperator.modes.READ_MULTILINE))
|
!vimperator.hasMode(vimperator.modes.READ_MULTILINE) &&
|
||||||
|
!vimperator.hasMode(vimperator.modes.WRITE_MULTILINE))
|
||||||
command_widget.inputField.focus();
|
command_widget.inputField.focus();
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
@@ -577,14 +602,183 @@ function CommandLine() //{{{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: if 'more' is set and the MOW is not scrollable we should still
|
||||||
|
// allow a down motion after an up rather than closing
|
||||||
this.onMultilineOutputEvent = function(event)
|
this.onMultilineOutputEvent = function(event)
|
||||||
{
|
{
|
||||||
var key = vimperator.events.toString(event);
|
var win = multiline_output_widget.contentWindow;
|
||||||
if (vimperator.events.isAcceptKey(key) || vimperator.events.isCancelKey(key))
|
|
||||||
|
var show_more_help_prompt = false;
|
||||||
|
var show_more_prompt = false;
|
||||||
|
|
||||||
|
function isScrollable() { return !win.scrollMaxY == 0; }
|
||||||
|
|
||||||
|
function atEnd() { return win.scrollY / win.scrollMaxY >= 1; }
|
||||||
|
|
||||||
|
function close()
|
||||||
{
|
{
|
||||||
multiline_output_widget.collapsed = true;
|
multiline_output_widget.collapsed = true;
|
||||||
|
vimperator.setMode(vimperator.modes.NORMAL);
|
||||||
vimperator.focusContent();
|
vimperator.focusContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function pass(event)
|
||||||
|
{
|
||||||
|
close();
|
||||||
|
vimperator.events.onKeyPress(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
var key = vimperator.events.toString(event);
|
||||||
|
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
case ":":
|
||||||
|
vimperator.commandline.open(":", "", vimperator.modes.EX);
|
||||||
|
break;
|
||||||
|
|
||||||
|
// down a line
|
||||||
|
case "j":
|
||||||
|
case "<Down>":
|
||||||
|
if (vimperator.options["more"] && isScrollable())
|
||||||
|
win.scrollByLines(1);
|
||||||
|
else
|
||||||
|
pass(event);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "<C-j>":
|
||||||
|
case "<C-m>":
|
||||||
|
case "<Return>":
|
||||||
|
if (vimperator.options["more"] && isScrollable() && !atEnd())
|
||||||
|
win.scrollByLines(1);
|
||||||
|
else
|
||||||
|
close(); // don't propagate the event for accept keys
|
||||||
|
break;
|
||||||
|
|
||||||
|
// up a line
|
||||||
|
case "k":
|
||||||
|
case "<Up>":
|
||||||
|
case "<BS>":
|
||||||
|
if (vimperator.options["more"] && isScrollable())
|
||||||
|
win.scrollByLines(-1);
|
||||||
|
else if (vimperator.options["more"] && !isScrollable())
|
||||||
|
show_more_prompt = true;
|
||||||
|
else
|
||||||
|
pass(event);
|
||||||
|
break;
|
||||||
|
|
||||||
|
// half page down
|
||||||
|
case "d":
|
||||||
|
if (vimperator.options["more"] && isScrollable())
|
||||||
|
win.scrollBy(0, win.innerHeight / 2);
|
||||||
|
else
|
||||||
|
pass(event);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "<LeftMouse>":
|
||||||
|
case "<A-LeftMouse>":
|
||||||
|
case "<C-LeftMouse>":
|
||||||
|
case "<S-LeftMouse>":
|
||||||
|
if (/^(end|more(-help)?)-prompt$/.test(event.target.id))
|
||||||
|
; // fall through
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
|
||||||
|
// page down
|
||||||
|
case "f":
|
||||||
|
if (vimperator.options["more"] && isScrollable())
|
||||||
|
win.scrollByPages(1);
|
||||||
|
else
|
||||||
|
pass(event);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "<Space>":
|
||||||
|
case "<PageDown>":
|
||||||
|
if (vimperator.options["more"] && isScrollable() && !atEnd())
|
||||||
|
win.scrollByPages(1);
|
||||||
|
else
|
||||||
|
pass(event);
|
||||||
|
break;
|
||||||
|
|
||||||
|
// half page up
|
||||||
|
case "u":
|
||||||
|
// if (more and scrollable)
|
||||||
|
if (vimperator.options["more"] && isScrollable())
|
||||||
|
win.scrollBy(0, -(win.innerHeight / 2));
|
||||||
|
else
|
||||||
|
pass(event);
|
||||||
|
break;
|
||||||
|
|
||||||
|
// page up
|
||||||
|
case "b":
|
||||||
|
if (vimperator.options["more"] && isScrollable())
|
||||||
|
win.scrollByPages(-1);
|
||||||
|
else if (vimperator.options["more"] && !isScrollable())
|
||||||
|
show_more_prompt = true;
|
||||||
|
else
|
||||||
|
pass(event);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "<PageUp>":
|
||||||
|
if (vimperator.options["more"] && isScrollable())
|
||||||
|
win.scrollByPages(-1);
|
||||||
|
else
|
||||||
|
pass(event);
|
||||||
|
break;
|
||||||
|
|
||||||
|
// top of page
|
||||||
|
case "g":
|
||||||
|
if (vimperator.options["more"] && isScrollable())
|
||||||
|
win.scrollTo(0, 0);
|
||||||
|
else if (vimperator.options["more"] && !isScrollable())
|
||||||
|
show_more_prompt = true;
|
||||||
|
else
|
||||||
|
pass(event);
|
||||||
|
break;
|
||||||
|
|
||||||
|
// bottom of page
|
||||||
|
case "G":
|
||||||
|
if (vimperator.options["more"] && isScrollable() && !atEnd())
|
||||||
|
win.scrollTo(0, win.scrollMaxY);
|
||||||
|
else
|
||||||
|
pass(event);
|
||||||
|
break;
|
||||||
|
|
||||||
|
// copy text to clipboard
|
||||||
|
case "<C-y>":
|
||||||
|
vimperator.copyToClipboard(win.getSelection());
|
||||||
|
break;
|
||||||
|
|
||||||
|
// close the window
|
||||||
|
case "q":
|
||||||
|
close();
|
||||||
|
break;
|
||||||
|
|
||||||
|
// unmapped key
|
||||||
|
default:
|
||||||
|
if (!vimperator.options["more"] || !isScrollable() || atEnd() || vimperator.events.isCancelKey(key))
|
||||||
|
pass(event);
|
||||||
|
else
|
||||||
|
show_more_help_prompt = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set appropriate prompt string
|
||||||
|
var more_prompt = win.document.getElementById("more-prompt");
|
||||||
|
var more_help_prompt = win.document.getElementById("more-help-prompt");
|
||||||
|
|
||||||
|
if (show_more_help_prompt)
|
||||||
|
{
|
||||||
|
more_prompt.style.display = "none";
|
||||||
|
more_help_prompt.style.display = "inline";
|
||||||
|
}
|
||||||
|
else if (show_more_prompt || (vimperator.options["more"] && isScrollable() && !atEnd()))
|
||||||
|
{
|
||||||
|
more_help_prompt.style.display = "none";
|
||||||
|
more_prompt.style.display = "inline";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
more_prompt.style.display = more_help_prompt.style.display = "none";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// it would be better if we had a destructor in javascript ...
|
// it would be better if we had a destructor in javascript ...
|
||||||
|
|||||||
@@ -43,14 +43,15 @@ const vimperator = (function() //{{{
|
|||||||
// extended modes
|
// extended modes
|
||||||
EX: 1 << 10,
|
EX: 1 << 10,
|
||||||
READ_MULTILINE: 1 << 11,
|
READ_MULTILINE: 1 << 11,
|
||||||
SEARCH_FORWARD: 1 << 12,
|
WRITE_MULTILINE: 1 << 12,
|
||||||
SEARCH_BACKWARD: 1 << 13,
|
SEARCH_FORWARD: 1 << 13,
|
||||||
ESCAPE_ONE_KEY: 1 << 14,
|
SEARCH_BACKWARD: 1 << 14,
|
||||||
ESCAPE_ALL_KEYS: 1 << 15,
|
ESCAPE_ONE_KEY: 1 << 15,
|
||||||
QUICK_HINT: 1 << 16,
|
ESCAPE_ALL_KEYS: 1 << 16,
|
||||||
EXTENDED_HINT: 1 << 17,
|
QUICK_HINT: 1 << 17,
|
||||||
ALWAYS_HINT: 1 << 18,
|
EXTENDED_HINT: 1 << 18,
|
||||||
MENU: 1 << 19 // a popupmenu is active
|
ALWAYS_HINT: 1 << 19,
|
||||||
|
MENU: 1 << 20 // a popupmenu is active
|
||||||
}
|
}
|
||||||
|
|
||||||
var mode_messages = {};
|
var mode_messages = {};
|
||||||
|
|||||||
@@ -92,6 +92,10 @@ the terms of any one of the MPL, the GPL or the LGPL.
|
|||||||
</listcols>
|
</listcols>
|
||||||
</listbox>
|
</listbox>
|
||||||
|
|
||||||
|
<iframe id="vimperator-multiline-output" src="about:blank" flex="1" height="10px" hidden="false" collapsed="true"
|
||||||
|
onclick="vimperator.commandline.onMultilineOutputEvent(event)"/>
|
||||||
|
<!--onkeypress="vimperator.commandline.onMultilineOutputEvent(event)"/>-->
|
||||||
|
|
||||||
<hbox id="vimperator-commandline" flex="1" hidden="false">
|
<hbox id="vimperator-commandline" flex="1" hidden="false">
|
||||||
<label class="plain" id="vimperator-commandline-prompt" flex="0" crop="end" value="" collapsed="true"/>
|
<label class="plain" id="vimperator-commandline-prompt" flex="0" crop="end" value="" collapsed="true"/>
|
||||||
<textbox class="plain" id="vimperator-commandline-command" flex="1" hidden="false" type="timed" timeout="100"
|
<textbox class="plain" id="vimperator-commandline-command" flex="1" hidden="false" type="timed" timeout="100"
|
||||||
@@ -101,9 +105,6 @@ the terms of any one of the MPL, the GPL or the LGPL.
|
|||||||
onblur="vimperator.commandline.onEvent(event);"/>
|
onblur="vimperator.commandline.onEvent(event);"/>
|
||||||
</hbox>
|
</hbox>
|
||||||
|
|
||||||
<iframe id="vimperator-multiline-output" src="about:blank" flex="1" height="10px" hidden="false" collapsed="true"
|
|
||||||
onkeypress="vimperator.commandline.onMultilineOutputEvent(event)"/>
|
|
||||||
|
|
||||||
<textbox id="vimperator-multiline-input" class="plain" flex="1" rows="10" hidden="false" collapsed="true" multiline="true"
|
<textbox id="vimperator-multiline-input" class="plain" flex="1" rows="10" hidden="false" collapsed="true" multiline="true"
|
||||||
onkeypress="vimperator.commandline.onMultilineInputEvent(event);"
|
onkeypress="vimperator.commandline.onMultilineInputEvent(event);"
|
||||||
oninput="vimperator.commandline.onMultilineInputEvent(event);"
|
oninput="vimperator.commandline.onMultilineInputEvent(event);"
|
||||||
|
|||||||
Reference in New Issue
Block a user