1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-21 22:17:59 +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
dpb| 09:11:50 dpb :: and this happens only when saving the complete
webpage, saving only the html works just fine..
- <ESC> key closes :addons and other XUL windows
- add window resize support to hints
FEATURES:
@@ -25,7 +24,6 @@ FEATURES:
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)
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
6 downloading of links to filesystem (:save <filename>)
6 autocommands (BrowserStart, BrowserQuit, TabClose, TabOpen, TabChanged, PageLoaded, any more?)
@@ -49,7 +47,6 @@ FEATURES:
RANDOM IDEAS:
* numbered tabs
* make hints work with usermode
* 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
"maxpreviewwindowheight" or something like this?

View File

@@ -1366,7 +1366,8 @@ function updateBufferList()
function scrollBufferRelative(right, down)
{
var win = document.commandDispatcher.focusedWindow;
//var win = window.document.commandDispatcher.focusedWindow;
var win = window.content;
if (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 */
function scrollBufferAbsolute(horizontal, vertical)
{
var win = document.commandDispatcher.focusedWindow;
//var win = document.commandDispatcher.focusedWindow;
var win = window.content;
var horiz, vert;
if (horizontal < 0)

View File

@@ -230,12 +230,26 @@ function CommandLine() //{{{
this.input = function(str)
{
// 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("");
setMessageStyle();
setCommand(str);
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()
{
@@ -244,7 +258,6 @@ function CommandLine() //{{{
setNormalStyle();
};
this.onEvent = function(event)
{
var command = this.getCommand();

View File

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