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

Fixed some focus issues

First (non-working) readMultiline implementation
This commit is contained in:
Martin Stubenschrott
2007-07-03 09:04:10 +00:00
parent 78aad7c83b
commit 84874eec04
5 changed files with 50 additions and 33 deletions

3
TODO
View File

@@ -12,7 +12,6 @@ BUGS:
id="hah_hints"></hints> near the end of it.. kinda annoying id="hah_hints"></hints> near the end of it.. kinda annoying
dpb| 09:11:50 dpb :: and this happens only when saving the complete dpb| 09:11:50 dpb :: and this happens only when saving the complete
webpage, saving only the html works just fine.. webpage, saving only the html works just fine..
- <ESC> key closes :addons and other XUL windows
- add window resize support to hints - add window resize support to hints
FEATURES: FEATURES:
@@ -25,7 +24,6 @@ FEATURES:
7 provide a buffer on the bottom where more than 1 line messages can be shown, preferrable 7 provide a buffer on the bottom where more than 1 line messages can be shown, preferrable
with color support (for things like :echo line1\nline2) with color support (for things like :echo line1\nline2)
7 whereever possible: get rid of dialogs and ask console-like dialog questions or write error prompts directly on the webpage or with :echo() 7 whereever possible: get rid of dialogs and ask console-like dialog questions or write error prompts directly on the webpage or with :echo()
7 Ctrl-6/Ctrl-^ -> jump to the previously active tab
7 3d should delete 3 tabs 7 3d should delete 3 tabs
6 downloading of links to filesystem (:save <filename>) 6 downloading of links to filesystem (:save <filename>)
6 autocommands (BrowserStart, BrowserQuit, TabClose, TabOpen, TabChanged, PageLoaded, any more?) 6 autocommands (BrowserStart, BrowserQuit, TabClose, TabOpen, TabChanged, PageLoaded, any more?)
@@ -49,7 +47,6 @@ FEATURES:
RANDOM IDEAS: RANDOM IDEAS:
* numbered tabs * numbered tabs
* make hints work with usermode
* https://addons.mozilla.org/en-US/firefox/addon/4125 - use vim to edit text fields * https://addons.mozilla.org/en-US/firefox/addon/4125 - use vim to edit text fields
* Would it be possible to add a setting "maxcompletionsshown" and * Would it be possible to add a setting "maxcompletionsshown" and
"maxpreviewwindowheight" or something like this? "maxpreviewwindowheight" or something like this?

View File

@@ -1366,7 +1366,8 @@ function updateBufferList()
function scrollBufferRelative(right, down) function scrollBufferRelative(right, down)
{ {
var win = document.commandDispatcher.focusedWindow; //var win = window.document.commandDispatcher.focusedWindow;
var win = window.content;
if (vimperator.input.count < 1) if (vimperator.input.count < 1)
vimperator.input.count = 1; vimperator.input.count = 1;
@@ -1395,7 +1396,8 @@ function scrollBufferRelative(right, down)
/* both values are given in percent, -1 means no change */ /* both values are given in percent, -1 means no change */
function scrollBufferAbsolute(horizontal, vertical) function scrollBufferAbsolute(horizontal, vertical)
{ {
var win = document.commandDispatcher.focusedWindow; //var win = document.commandDispatcher.focusedWindow;
var win = window.content;
var horiz, vert; var horiz, vert;
if (horizontal < 0) if (horizontal < 0)

View File

@@ -230,12 +230,26 @@ function CommandLine() //{{{
this.input = function(str) this.input = function(str)
{ {
// TODO: unfinished, need to find out how/if we can block the execution of code // TODO: unfinished, need to find out how/if we can block the execution of code
// to make this code synchronous // to make this code synchronous or at least use a callback
setPrompt(""); setPrompt("");
setMessageStyle(); setMessageStyle();
setCommand(str); setCommand(str);
return "not implemented"; return "not implemented";
} };
// reads a multi line input and returns the string once the last line matches
// param until_regex
this.readMultiline = function(until_regex, callback_func)
{
// 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.READ_MULTLINE, true);
multiline_widget.collapsed = false;
multiline_widget.contentDocument.body.innerHTML = "";
multiline_widget.contentDocument.designMode = "on";
multiline_widget.contentWindow.focus(); // FIXME: does not work
};
this.clear = function() this.clear = function()
{ {
@@ -244,7 +258,6 @@ function CommandLine() //{{{
setNormalStyle(); setNormalStyle();
}; };
this.onEvent = function(event) this.onEvent = function(event)
{ {
var command = this.getCommand(); var command = this.getCommand();

View File

@@ -164,13 +164,14 @@ function Vimperator() //{{{
COMMAND_LINE: 1 << 4, COMMAND_LINE: 1 << 4,
// extended modes // extended modes
EX: 1 << 10, EX: 1 << 10,
SEARCH_FORWARD: 1 << 11, READ_MULTLINE: 1 << 11,
SEARCH_BACKWARD: 1 << 12, SEARCH_FORWARD: 1 << 12,
ESCAPE_ONE_KEY: 1 << 13, SEARCH_BACKWARD: 1 << 13,
ESCAPE_ALL_KEYS: 1 << 14, ESCAPE_ONE_KEY: 1 << 14,
QUICK_HINT: 1 << 15, ESCAPE_ALL_KEYS: 1 << 15,
EXTENDED_HINT: 1 << 16, QUICK_HINT: 1 << 16,
ALWAYS_HINT: 1 << 17 EXTENDED_HINT: 1 << 17,
ALWAYS_HINT: 1 << 18
} }
var mode_messages = {}; var mode_messages = {};
mode_messages[this.modes.NORMAL] = ""; mode_messages[this.modes.NORMAL] = "";
@@ -386,12 +387,12 @@ function Events() //{{{
// page is loaded in a background tab // page is loaded in a background tab
getBrowser().addEventListener("load", onPageLoad, true); getBrowser().addEventListener("load", onPageLoad, true);
// called when the window is scrolled. // called when the active document is scrolled
window.onscroll = function (event) getBrowser().addEventListener("scroll", function (event)
{ {
vimperator.statusline.updateBufferPosition(); vimperator.statusline.updateBufferPosition();
vimperator.setMode(); // trick to reshow the mode in the command line vimperator.setMode(); // trick to reshow the mode in the command line
}; }, null);
window.document.addEventListener("DOMTitleChanged", function(event) window.document.addEventListener("DOMTitleChanged", function(event)
{ {
@@ -460,13 +461,15 @@ function Events() //{{{
this.onKeyPress = function(event) this.onKeyPress = function(event)
{ {
if (event.type != "keypress") // alert(event)
return false; // if (event.type != "keypress")
// return false;
// vimperator.logObject(event);
var key = event.toString() var key = event.toString()
//alert(key); if (!key)
if (key == null)
return false; return false;
// event.stopPropagation();
// event.preventDefault();
// sometimes the non-content area has focus, making our keys not work // sometimes the non-content area has focus, making our keys not work
// if (event.target.id == "main-window") // if (event.target.id == "main-window")
// alert("focusContent();"); // alert("focusContent();");
@@ -1064,19 +1067,21 @@ function Tabs() //{{{
/////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////{{{
function isFormElemFocused() function isFormElemFocused()
{ {
var elt = document.commandDispatcher.focusedElement; var elt = window.document.commandDispatcher.focusedElement;
if (elt == null) if (elt == null)
return false; return false;
var tagname = elt.localName.toLowerCase(); try { // sometimes the elt doesn't have .localName
var type = elt.type.toLowerCase(); var tagname = elt.localName.toLowerCase();
var type = elt.type.toLowerCase();
if ( (tagname == "input" && (type != "image")) || if ( (tagname == "input" && (type != "image")) ||
tagname == "textarea" || tagname == "textarea" ||
// tagName == "SELECT" || // tagName == "SELECT" ||
// tagName == "BUTTON" || // tagName == "BUTTON" ||
tagname == "isindex") // isindex is a deprecated one-line input box tagname == "isindex") // isindex is a deprecated one-line input box
return true; return true;
} catch(e) {};
return false; return false;
} }

View File

@@ -101,7 +101,7 @@ the terms of any one of the MPL, the GPL or the LGPL.
onblur="vimperator.commandline.onEvent(event);" onblur="vimperator.commandline.onEvent(event);"
style="font-family: monospace; -moz-user-focus:ignore;"/> style="font-family: monospace; -moz-user-focus:ignore;"/>
</hbox> </hbox>
<iframe id="vimperator-multiline" src="about:blank" flex="100%" hidden="false" collapsed="true"/> <iframe id="vimperator-multiline" src="about:blank" flex="1" hidden="false" collapsed="true"/>
</vbox> </vbox>
</toolbar> </toolbar>