1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-19 18:25:45 +01:00

renamed CompletionList -> InformationList which is now a common class for the

completion window, for the preview window and the buffer window ("B").
Only the StatusLine class to go...
This commit is contained in:
Martin Stubenschrott
2007-05-15 04:50:00 +00:00
parent 80a31de59c
commit 77686ff159
7 changed files with 502 additions and 686 deletions

View File

@@ -1,4 +1,4 @@
// XXX: remove! // XXX: move somehere else!
function save_history() function save_history()
{ {
set_pref("comp_history", comp_history.join("\n")); set_pref("comp_history", comp_history.join("\n"));
@@ -52,7 +52,6 @@ function multiliner(line, prev_match, heredoc)
} }
/* /*
* This class is used for prompting of user input and echoing of messages * This class is used for prompting of user input and echoing of messages
* *
@@ -67,7 +66,7 @@ function CommandLine ()
const UNINITIALIZED = -2; // notifies us, if we need to start history/tab-completion from the beginning const UNINITIALIZED = -2; // notifies us, if we need to start history/tab-completion from the beginning
const HISTORY_SIZE = 500; const HISTORY_SIZE = 500;
var completionlist = new CompletionList(); var completionlist = new InformationList("vim-completion", { min_items: 2, max_items: 10 });
var completions = new Array(); var completions = new Array();
var history = new Array(); var history = new Array();
@@ -77,7 +76,7 @@ function CommandLine ()
// for the example command "open sometext| othertext" (| is the cursor pos) // for the example command "open sometext| othertext" (| is the cursor pos)
var completion_start_index = 0; // will be 5 because we want to complete arguments for the :open command var completion_start_index = 0; // will be 5 because we want to complete arguments for the :open command
var completion_prefix = "" // will be: "open sometext" var completion_prefix = "" // will be: "open sometext"
var completion_postfix = ""; // will be: " othertext" var completion_postfix = ""; // will be: " othertext"
var wild_index = 0; // keep track how often we press <Tab> in a row var wild_index = 0; // keep track how often we press <Tab> in a row
var completion_index = UNINITIALIZED; var completion_index = UNINITIALIZED;
@@ -89,49 +88,49 @@ function CommandLine ()
function setNormalStyle() function setNormalStyle()
{ {
command_widget.inputField.setAttribute("style","font-family: monospace;"); command_widget.inputField.setAttribute("style","font-family: monospace;");
} }
function setErrorStyle() function setErrorStyle()
{ {
command_widget.inputField.setAttribute("style", "font-family: monospace; color:white; background-color:red; font-weight: bold"); command_widget.inputField.setAttribute("style", "font-family: monospace; color:white; background-color:red; font-weight: bold");
} }
// Sets the prompt - for example, : or / // Sets the prompt - for example, : or /
function setPrompt(prompt) function setPrompt(prompt)
{ {
if (typeof(prompt) != "string") if (typeof(prompt) != "string")
prompt = ""; prompt = "";
prompt_widget.value = prompt; prompt_widget.value = prompt;
if (prompt) if (prompt)
{ {
// Initially (in the xul) the prompt is 'collapsed', this makes // Initially (in the xul) the prompt is 'collapsed', this makes
// sure it's visible, then we toggle the display which works better // sure it's visible, then we toggle the display which works better
prompt_widget.style.visibility = 'visible'; prompt_widget.style.visibility = 'visible';
prompt_widget.style.display = 'inline'; prompt_widget.style.display = 'inline';
prompt_widget.size = prompt.length; prompt_widget.size = prompt.length;
} }
else else
{ {
prompt_widget.style.display = 'none'; prompt_widget.style.display = 'none';
} }
} }
// Sets the command - e.g. 'tabopen', 'open http://example.com/' // Sets the command - e.g. 'tabopen', 'open http://example.com/'
function setCommand(cmd) function setCommand(cmd)
{ {
command_widget.value = cmd; command_widget.value = cmd;
} }
function addToHistory(str) function addToHistory(str)
{ {
// first remove all old history elements which have this string // first remove all old history elements which have this string
history = history.filter(function(elem) { history = history.filter(function(elem) {
return elem != str; return elem != str;
}); });
// add string to the command line history // add string to the command line history
if (str.length >= 1 && history.push(str) > HISTORY_SIZE) if (str.length >= 1 && history.push(str) > HISTORY_SIZE)
history.shift(); history.shift();
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -140,7 +139,7 @@ function CommandLine ()
this.getCommand = function() this.getCommand = function()
{ {
return command_widget.value; return command_widget.value;
}; };
/** /**
@@ -148,422 +147,480 @@ function CommandLine ()
*/ */
this.open = function(prompt, cmd, minor_mode) this.open = function(prompt, cmd, minor_mode)
{ {
if (!prompt) if (!prompt)
prompt = ""; prompt = "";
if (!cmd) if (!cmd)
cmd = ""; cmd = "";
if (minor_mode) if (minor_mode)
setCurrentMode(minor_mode); setCurrentMode(minor_mode);
setNormalStyle(); setNormalStyle();
setPrompt(prompt); setPrompt(prompt);
setCommand(cmd); setCommand(cmd);
history_index = UNINITIALIZED; history_index = UNINITIALIZED;
completion_index = UNINITIALIZED; completion_index = UNINITIALIZED;
command_widget.focus(); command_widget.focus();
}; };
this.echo = function(str) this.echo = function(str)
{ {
setNormalStyle(); setNormalStyle();
setPrompt(""); setPrompt("");
setCommand(str); setCommand(str);
}; };
this.echoErr = function(str) this.echoErr = function(str)
{ {
setErrorStyle(); setErrorStyle();
setPrompt(""); setPrompt("");
setCommand(str); setCommand(str);
}; };
this.clear = function() this.clear = function()
{ {
setPrompt(" "); // looks faster than an empty string setPrompt(" "); // looks faster than an empty string
setCommand(""); setCommand("");
setNormalStyle(); setNormalStyle();
}; };
this.onEvent = function(event) this.onEvent = function(event)
{ {
//var end = false; //var end = false;
var command = this.getCommand(); var command = this.getCommand();
if(event.type == "blur") if(event.type == "blur")
{ {
// when we do a command_widget.focus() we get a blur event immediately, // when we do a command_widget.focus() we get a blur event immediately,
// so check if the target is the actualy input field // so check if the target is the actualy input field
if (event.target == command_widget.inputField) if (event.target == command_widget.inputField)
{ {
addToHistory(command); addToHistory(command);
completionlist.hide(); completionlist.hide();
} }
} }
else if(event.type == "input") else if(event.type == "input")
{ {
vimperator.triggerCallback("change", command); vimperator.triggerCallback("change", command);
} }
else if(event.type == "keypress") else if(event.type == "keypress")
{ {
var key = keyToString(event); var key = keyToString(event);
/* user pressed ENTER to carry out a command */ /* user pressed ENTER to carry out a command */
if (key == "<Return>" || key == "<C-j>" || key == "<C-m>") if (key == "<Return>" || key == "<C-j>" || key == "<C-m>")
{ {
// try { // FIXME: move to execute() in commands.js
// [prev_match, heredoc, end] = multiliner(command, prev_match, heredoc); // try {
// } catch(e) { // [prev_match, heredoc, end] = multiliner(command, prev_match, heredoc);
// logObject(e); // } catch(e) {
// echoerr(e.name + ": " + e.message); // logObject(e);
// prev_match = new Array(5); // echoerr(e.name + ": " + e.message);
// heredoc = ''; // prev_match = new Array(5);
// return; // heredoc = '';
// } // return;
// if (!end) // }
// command_line.value = ""; // if (!end)
// command_line.value = "";
// the command is saved in the blur() handler // the command is saved in the blur() handler
focusContent(); focusContent();
var res = vimperator.triggerCallback("submit", command); var res = vimperator.triggerCallback("submit", command);
return res; return res;
} }
/* user pressed ESCAPE to cancel this prompt */ /* user pressed ESCAPE to cancel this prompt */
else if (key == "<Esc>" || key == "<C-[>") else if (key == "<Esc>" || key == "<C-[>" || key == "<C-c>")
{ {
var res = vimperator.triggerCallback("cancel"); var res = vimperator.triggerCallback("cancel");
addToHistory(command); addToHistory(command);
this.clear(); this.clear();
focusContent(true, true); focusContent(true, true);
return res; return res;
} }
/* user pressed UP or DOWN arrow to cycle history completion */ /* user pressed UP or DOWN arrow to cycle history completion */
else if (key == "<Up>" || key == "<Down>") else if (key == "<Up>" || key == "<Down>")
{ {
//always reset the tab completion if we use up/down keys //always reset the tab completion if we use up/down keys
completion_index = UNINITIALIZED; completion_index = UNINITIALIZED;
/* save 'start' position for iterating through the history */ /* save 'start' position for iterating through the history */
if (history_index == UNINITIALIZED) if (history_index == UNINITIALIZED)
{ {
history_index = history.length; history_index = history.length;
history_start = command; history_start = command;
} }
while (history_index >= -1 && history_index <= history.length) while (history_index >= -1 && history_index <= history.length)
{ {
key == "<Up>" ? history_index-- : history_index++; key == "<Up>" ? history_index-- : history_index++;
if (history_index == history.length) // user pressed DOWN when there is no newer history item if (history_index == history.length) // user pressed DOWN when there is no newer history item
{ {
setCommand(history_start); setCommand(history_start);
return; return;
} }
// cannot go past history start/end // cannot go past history start/end
if (history_index <= -1) if (history_index <= -1)
{ {
history_index = 0; history_index = 0;
beep(); beep();
break; break;
} }
if (history_index >= history.length + 1) if (history_index >= history.length + 1)
{ {
history_index = history.length; history_index = history.length;
beep(); beep();
break; break;
} }
if (history[history_index].indexOf(history_start) == 0) if (history[history_index].indexOf(history_start) == 0)
{ {
setCommand(history[history_index]); setCommand(history[history_index]);
return; return;
} }
} }
beep(); beep();
} }
/* user pressed TAB to get completions of a command */ /* user pressed TAB to get completions of a command */
else if (key == "<Tab>" || key == "<S-Tab>") else if (key == "<Tab>" || key == "<S-Tab>")
{ {
//always reset our completion history so up/down keys will start with new values //always reset our completion history so up/down keys will start with new values
history_index = UNINITIALIZED; history_index = UNINITIALIZED;
// we need to build our completion list first // we need to build our completion list first
if (completion_index == UNINITIALIZED) if (completion_index == UNINITIALIZED)
{ {
// FIXME: completions.clear(); completion_start_index = 0;
completion_start_index = 0;
completion_index = -1; completion_index = -1;
wild_index = 0; wild_index = 0;
completion_prefix = command.substring(0, command_widget.selectionStart); completion_prefix = command.substring(0, command_widget.selectionStart);
completion_postfix = command.substring(command_widget.selectionStart); completion_postfix = command.substring(command_widget.selectionStart);
var res = vimperator.triggerCallback("complete", completion_prefix); var res = vimperator.triggerCallback("complete", completion_prefix);
if (res) if (res)
[completion_start_index, completions] = res; [completion_start_index, completions] = res;
// Sort the completion list // Sort the completion list
if (get_pref('wildoptions').match(/\bsort\b/)) if (get_pref('wildoptions').match(/\bsort\b/))
{ {
completions.sort(function(a, b) { completions.sort(function(a, b) {
if (a[0] < b[0]) if (a[0] < b[0])
return -1; return -1;
else if (a[0] > b[0]) else if (a[0] > b[0])
return 1; return 1;
else else
return 0; return 0;
}); });
} }
} }
// we could also return when no completion is found
// but we fall through to the cleanup anyway
if (completions.length == 0)
{
beep();
// prevent tab from moving to the next field
event.preventDefault();
event.stopPropagation();
return;
}
var wim = get_pref('wildmode').split(/,/); if (completions.length == 0)
var has_list = false; {
var longest = false; beep();
var full = false; // prevent tab from moving to the next field
var wildtype = wim[wild_index++] || wim[wim.length - 1]; event.preventDefault();
if (wildtype == 'list' || wildtype == 'list:full' || wildtype == 'list:longest') event.stopPropagation();
has_list = true; return;
if (wildtype == 'longest' || wildtype == 'list:longest') }
longest = true;
else if (wildtype == 'full' || wildtype == 'list:full')
full = true;
// show the list var wim = get_pref('wildmode').split(/,/);
if (has_list) var has_list = false;
completionlist.show(completions); var longest = false;
var full = false;
var wildtype = wim[wild_index++] || wim[wim.length - 1];
if (wildtype == 'list' || wildtype == 'list:full' || wildtype == 'list:longest')
has_list = true;
if (wildtype == 'longest' || wildtype == 'list:longest')
longest = true;
else if (wildtype == 'full' || wildtype == 'list:full')
full = true;
if (full) // show the list
{ if (has_list)
if (event.shiftKey) {
{ if (completion_index < 0)
completion_index--; completionlist.show(completions);
if(completion_index < -1) else
completion_index = completions.length -1; completionlist.show();
} }
else
{
completion_index++;
if(completion_index >= completions.length)
completion_index = -1;
}
showStatusbarMessage("match " + (completion_index+1).toString() + " of " + completions.length.toString(), STATUSFIELD_PROGRESS); if (full)
// if the list is hidden, this function does nothing {
completionlist.selectItem(completion_index); if (event.shiftKey)
} {
completion_index--;
if(completion_index < -1)
completion_index = completions.length -1;
}
else
{
completion_index++;
if(completion_index >= completions.length)
completion_index = -1;
}
showStatusbarMessage("match " + (completion_index+1).toString() + " of " + completions.length.toString(), STATUSFIELD_PROGRESS);
// if the list is hidden, this function does nothing
completionlist.selectItem(completion_index);
}
if (completion_index == -1 && !longest) // wrapped around matches, reset command line if (completion_index == -1 && !longest) // wrapped around matches, reset command line
{ {
if (full && completions.length > 1) if (full && completions.length > 1)
{ {
setCommand(completion_prefix + completion_postfix); setCommand(completion_prefix + completion_postfix);
//completion_list.selectedIndex = -1; }
} }
} else
else {
{ if (longest && completions.length > 1)
if (longest && completions.length > 1) var compl = get_longest_substring();
var compl = get_longest_substring(); else if (full)
else if (full) var compl = completions[completion_index][0];
var compl = completions[completion_index][0]; else if (completions.length == 1)
else if (completions.length == 1) var compl = completions[0][0];
var compl = completions[0][0]; if (compl)
if (compl) {
{ setCommand(command.substring(0, completion_start_index) + compl + completion_postfix);
setCommand(command.substring(0, completion_start_index) + compl + completion_postfix); command_widget.selectionStart = command_widget.selectionEnd = completion_start_index + compl.length;
command_widget.selectionStart = command_widget.selectionEnd = completion_start_index + compl.length;
// Start a new completion in the next iteration. Useful for commands like :source // Start a new completion in the next iteration. Useful for commands like :source
// RFC: perhaps the command can indicate whether the completion should be restarted // RFC: perhaps the command can indicate whether the completion should be restarted
// Needed for :source to grab another set of completions after a file/directory has been filled out // Needed for :source to grab another set of completions after a file/directory has been filled out
if (completions.length == 1 && !full) if (completions.length == 1 && !full)
completion_index = UNINITIALIZED; completion_index = UNINITIALIZED;
} }
} }
// prevent tab from moving to the next field // prevent tab from moving to the next field
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
} }
else if (key == "<BS>") else if (key == "<BS>")
{ {
// reset the tab completion // reset the tab completion
completion_index = history_index = UNINITIALIZED; completion_index = history_index = UNINITIALIZED;
// and blur the command line if there is no text left // and blur the command line if there is no text left
if(command.length == 0) if(command.length == 0)
{ {
this.clear(); this.clear();
focusContent(); focusContent();
} }
} }
else // any other key else // any other key
{ {
// reset the tab completion // reset the tab completion
completion_index = history_index = UNINITIALIZED; completion_index = history_index = UNINITIALIZED;
} }
} }
} }
logMessage("CommandLine initialized."); logMessage("CommandLine initialized.");
} }
function CompletionList() /**
* The list which is used for the completion box, the preview window and the buffer preview window
*
* @param id: the id of the the XUL widget which we want to fill
* @param options: an optional hash which modifies the behavior of the list
*/
function InformationList(id, options)
{ {
const MAX_ITEMS = 10; const CONTEXT_LINES = 3;
const CONTEXT_LINES = 3; var max_items = 10;
var min_items = 1;
var incremental_fill = true; // make display faster, but does not show scrollbar
var completions = null; // a reference to the Array of completions if(options)
var completion_widget = document.getElementById("vim-completion"); {
var list_offset = 0; // how many items is the displayed list shifted from the internal tab index if (options.max_items) max_items = options.max_items;
var list_index = 0; // list_offset + list_index = completions[item] if (options.min_items) min_items = options.min_items;
if (options.incremental_fill) incremental_fill = options.incremental_fill;
}
// add a single completion item to the list var widget = document.getElementById(id);
function addItem(completion_item, at_beginning) var completions = null; // a reference to the Array of completions
{ var list_offset = 0; // how many items is the displayed list shifted from the internal tab index
var item = document.createElement("listitem"); var list_index = 0; // list_offset + list_index = completions[item]
var cell1 = document.createElement("listcell");
var cell2 = document.createElement("listcell");
cell1.setAttribute("label", completion_item[0]); // add a single completion item to the list
cell2.setAttribute("label", completion_item[1]); function addItem(completion_item, at_beginning)
cell2.setAttribute("style", "color:green; font-family: sans"); {
var item = document.createElement("listitem");
var cell1 = document.createElement("listcell");
var cell2 = document.createElement("listcell");
item.appendChild(cell1); cell1.setAttribute("label", completion_item[0]);
item.appendChild(cell2); cell2.setAttribute("label", completion_item[1]);
if (at_beginning == true) cell2.setAttribute("style", "color:green; font-family: sans");
{
var items = completion_widget.getElementsByTagName("listitem");
if (items.length > 0)
completion_widget.insertBefore(item, items[0]);
else
completion_widget.appendChild(item);
}
else
completion_widget.appendChild(item);
}
/** item.appendChild(cell1);
* uses the entries in completions to fill the listbox item.appendChild(cell2);
* @param startindex: start at this index and show MAX_ITEMS if (at_beginning == true)
* @returns the number of items {
*/ var items = widget.getElementsByTagName("listitem");
function fill(startindex) if (items.length > 0)
{ widget.insertBefore(item, items[0]);
var complength = completions.length; else
widget.appendChild(item);
}
else
widget.appendChild(item);
}
// remove all old items first /**
var items = completion_widget.getElementsByTagName("listitem"); * uses the entries in completions to fill the listbox
while (items.length > 0) { completion_widget.removeChild(items[0]);} *
* @param startindex: start at this index and show max_items
* @returns the number of items
*/
function fill(startindex)
{
var complength = completions.length;
// find start index // remove all old items first
if (startindex + MAX_ITEMS > complength) var items = widget.getElementsByTagName("listitem");
startindex = complength - MAX_ITEMS; while (items.length > 0) { widget.removeChild(items[0]);}
if (startindex < 0)
startindex = 0;
list_offset = startindex; if(!incremental_fill)
list_index = -1; {
for (i in completions)
addItem(completions[i], false);
return complength;
}
for(i = startindex; i < complength && i < startindex + MAX_ITEMS; i++) // find start index
{ if (startindex + max_items > complength)
addItem(completions[i], false); startindex = complength - max_items;
} if (startindex < 0)
startindex = 0;
return (i-startindex); list_offset = startindex;
} list_index = -1;
//////////////////////////////////////////////////////////////////////////////// for(i = startindex; i < complength && i < startindex + max_items; i++)
////////////////////// PUBLIC SECTION ////////////////////////////////////////// {
//////////////////////////////////////////////////////////////////////////////// addItem(completions[i], false);
this.len = function() {alert(completions.length);}; }
this.show = function(compl)
{
completions = compl;
fill(0);
var length = completions.length; return (i-startindex);
if (length > MAX_ITEMS) }
length = MAX_ITEMS;
if (length > 1)
{
completion_widget.setAttribute("rows", length.toString());
completion_widget.hidden = false;
return true;
}
else
{
completion_widget.hidden = true;
return false;
}
}
this.hide = function() ////////////////////////////////////////////////////////////////////////////////
{ ////////////////////// PUBLIC SECTION //////////////////////////////////////////
completion_widget.hidden = true; ////////////////////////////////////////////////////////////////////////////////
}
/**
* Show the completion list window
*
* @param compl: if null, only show the list with current entries, otherwise
* use entries of 'compl' to fill the list.
* Required format: [["left", "right"], ["another"], ["completion"]]
*/
this.show = function(compl)
{
//max_items = get_pref("previewheight");
/** if (compl)
* select index, refill list if necessary {
*/ completions = compl;
this.selectItem = function(index) fill(0);
{ }
if(completion_widget.hidden)
return;
// find start index var length = completions.length;
var new_offset = 0; if (length > max_items)
if (index >= list_offset + MAX_ITEMS - CONTEXT_LINES) length = max_items;
new_offset = index - MAX_ITEMS + CONTEXT_LINES + 1; if (length >= min_items)
else if (index <= list_offset + CONTEXT_LINES) {
new_offset = index - CONTEXT_LINES; widget.setAttribute("rows", length.toString());
else widget.hidden = false;
new_offset = list_offset; return true;
}
else
{
widget.hidden = true;
return false;
}
}
if (new_offset + MAX_ITEMS > completions.length) this.hide = function()
new_offset = completions.length - MAX_ITEMS; {
if (new_offset < 0) widget.hidden = true;
new_offset = 0; }
// for speed reason: just remove old item, and add the new one at the end of the list this.visible = function()
var items = completion_widget.getElementsByTagName("listitem"); {
if (new_offset == list_offset + 1) return !widget.hidden;
{ }
completion_widget.removeChild(items[0]);
addItem(completions[index + CONTEXT_LINES], false);
}
else if (new_offset == list_offset - 1)
{
completion_widget.removeChild(items[items.length-1]);
addItem(completions[index - CONTEXT_LINES], true);
}
else if (new_offset == list_offset)
{
// do nothing
}
else
fill(new_offset);
list_offset = new_offset; /**
completion_widget.selectedIndex = index - list_offset; * select index, refill list if necessary
} */
this.selectItem = function(index)
{
if(widget.hidden)
return;
if(!incremental_fill)
{
widget.selectedIndex = index;
return;
}
// find start index
var new_offset = 0;
if (index >= list_offset + max_items - CONTEXT_LINES)
new_offset = index - max_items + CONTEXT_LINES + 1;
else if (index <= list_offset + CONTEXT_LINES)
new_offset = index - CONTEXT_LINES;
else
new_offset = list_offset;
if (new_offset + max_items > completions.length)
new_offset = completions.length - max_items;
if (new_offset < 0)
new_offset = 0;
// for speed reason: just remove old item, and add the new one at the end of the list
var items = widget.getElementsByTagName("listitem");
if (new_offset == list_offset + 1)
{
widget.removeChild(items[0]);
addItem(completions[index + CONTEXT_LINES], false);
}
else if (new_offset == list_offset - 1)
{
widget.removeChild(items[items.length-1]);
addItem(completions[index - CONTEXT_LINES], true);
}
else if (new_offset == list_offset)
{
// do nothing
}
else
fill(new_offset);
list_offset = new_offset;
widget.selectedIndex = index - list_offset;
}
this.onEvent = function(event)
{
var listcells = document.getElementsByTagName("listcell");
// 2 columns for now, use the first column
var index = (widget.selectedIndex * 2) + 0;
var val = listcells[index].getAttribute("label");
if (val && event.button == 0 && event.type == "dblclick") // left double click
openURLs(val);
else if (val && event.button == 1) // middle click
openURLsInNewTab(val);
else
return false;
}
logMessage("InformationList initialized for widget id: " + id);
} }
// function PreviewWindow()
// {
// var completion_widget = document.getElementById("vim-preview_window");
// }
// PreviewWindow.protoype = new CompletionList;
// var pw = new PreviewWindow();
// vim: set fdm=marker sw=4 ts=4 et: // vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -127,7 +127,7 @@ var g_commands = [/*{{{*/
["buffers"], ["buffers"],
"Show a list of all buffers", "Show a list of all buffers",
"If the list is already shown, close the preview window.", "If the list is already shown, close the preview window.",
buffer_preview_toggle, toggleBufferList,
null null
], ],
[ [
@@ -284,7 +284,7 @@ var g_commands = [/*{{{*/
["pc[lose]"], ["pc[lose]"],
"Close preview window on bottom of screen", "Close preview window on bottom of screen",
null, null,
function() { preview_window.hidden = true; }, function() { vimperator.previewwindow.hide(); },
null null
], ],
[ [
@@ -353,7 +353,7 @@ var g_commands = [/*{{{*/
], ],
[ [
["source", "so"], ["source", "so"],
[":so[urce][!] {file}"], ["so[urce][!] {file}"],
"Read Ex commands from {file}", "Read Ex commands from {file}",
"The .vimperatorrc file in your home directory is always sourced at start up.<br/>"+ "The .vimperatorrc file in your home directory is always sourced at start up.<br/>"+
"~ is supported as a shortcut for the $HOME directory.<br/>" + "~ is supported as a shortcut for the $HOME directory.<br/>" +
@@ -526,14 +526,14 @@ var g_mappings = [/*{{{*/
["b {number}"], ["b {number}"],
"Open a prompt to switch buffers", "Open a prompt to switch buffers",
"Typing the corresponding number opens switches to this buffer", "Typing the corresponding number opens switches to this buffer",
function (args) { bufshow("", true); vimperator.commandline.open(":", "buffer ", MODE_EX); } function (args) { /*bufshow("", true); */vimperator.commandline.open(":", "buffer ", MODE_EX); }
], ],
[ [
["B"], ["B"],
["B"], ["B"],
"Toggle buffer list", "Toggle buffer list",
"Toggles the display of the buffer list which shows all opened tabs,", "Toggles the display of the buffer list which shows all opened tabs,",
buffer_preview_toggle toggleBufferList
], ],
[ [
["d"], ["d"],
@@ -1574,8 +1574,7 @@ function bmshow(filter, fullmode)
else else
{ {
var items = get_bookmark_completions(filter); var items = get_bookmark_completions(filter);
preview_window_fill(items); vimperator.previewwindow.show(items);
preview_window_show();
} }
} }
function hsshow(filter, fullmode) function hsshow(filter, fullmode)
@@ -1585,8 +1584,7 @@ function hsshow(filter, fullmode)
else else
{ {
var items = get_history_completions(filter); var items = get_history_completions(filter);
preview_window_fill(items); vimperator.previewwindow.show(items);
preview_window_show();
} }
} }
@@ -1697,39 +1695,6 @@ function tab_move(position)
getBrowser().moveTabTo(getBrowser().mCurrentTab, parseInt(position)); getBrowser().moveTabTo(getBrowser().mCurrentTab, parseInt(position));
} }
function bufshow(filter, in_comp_window)
{
if (in_comp_window) // fill the completion list
{
// FIXME
// g_completions = get_buffer_completions(filter);
// completion_fill_list(0);
// completion_show_list();
}
else // in the preview window
{
if(g_bufshow == true)
{
setTimeout(function ()
{
var items = get_buffer_completions(filter);
preview_window_fill(items);
preview_window_show();
g_bufshow = true;
preview_window.selectItem(preview_window.getItemAtIndex(gBrowser.mTabContainer.selectedIndex));
}, 100);
}
else
{
var items = get_buffer_completions(filter);
preview_window_fill(items);
preview_window_show();
g_bufshow = true;
preview_window.selectItem(preview_window.getItemAtIndex(gBrowser.mTabContainer.selectedIndex));
}
}
}
function buffer_switch(string) function buffer_switch(string)
{ {
var match; var match;
@@ -1744,27 +1709,27 @@ function buffer_switch(string)
} }
//toggles the buffer preview window //toggles the buffer preview window
function buffer_preview_toggle() function toggleBufferList()
{ {
if(g_bufshow == true) if (vimperator.bufferwindow.visible())
{ vimperator.bufferwindow.hide();
preview_window.hidden = true;
g_bufshow = false;
}
else else
{ {
bufshow("", false); var items = get_buffer_completions("");
g_bufshow = true; vimperator.bufferwindow.show(items);
vimperator.bufferwindow.selectItem(getBrowser().mTabContainer.selectedIndex);
} }
} }
// updates the buffer preview in place only if list is visible
//updates the buffer preview in place function updateBufferList()
function buffer_preview_update(event)
{ {
if(g_bufshow == true) if (!vimperator.bufferwindow.visible())
bufshow("", false); return false;
}
var items = get_buffer_completions("");
vimperator.bufferwindow.show(items);
vimperator.bufferwindow.selectItem(getBrowser().mTabContainer.selectedIndex);
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// scrolling ////////////////////////////////////////////////////// {{{1 // scrolling ////////////////////////////////////////////////////// {{{1

View File

@@ -15,14 +15,6 @@ var history_loaded = false;
// array of our bookmark keywords // array of our bookmark keywords
var g_keywords = []; var g_keywords = [];
// variables for the tab completion and command history:
// -1: filled, but no selection made
// >= 0: index of current item in the g_completions array
const COMPLETION_UNINITIALIZED = -2; // if we need to build the completion array first
const COMPLETION_MAXITEMS = 10;
const COMPLETION_CONTEXTLINES = 3;
const COMMAND_LINE_HISTORY_SIZE = 500;
// 2 dimensional: 1st element: what to complete // 2 dimensional: 1st element: what to complete
// 2nd element: help description // 2nd element: help description
var g_completions = new Array(); var g_completions = new Array();
@@ -518,7 +510,6 @@ function get_buffer_completions(filter)/*{{{*/
}/*}}}*/ }/*}}}*/
// return [startindex, [[itemtext, itemhelp],...]] // return [startindex, [[itemtext, itemhelp],...]]
function exTabCompletion(str) function exTabCompletion(str)
{ {
@@ -553,57 +544,4 @@ function exTabCompletion(str)
return [start, completions]; return [start, completions];
} }
///////// PREVIEW WINDOW //////////////////////
/* uses the entries in completions to fill the listbox */
function preview_window_fill(completions)/*{{{*/
{
// remove all old items first
var items = preview_window.getElementsByTagName("listitem");
while (items.length > 0) { preview_window.removeChild(items[0]);}
for(i=0; i<completions.length; i++)
{
var item = document.createElement("listitem");
var cell1 = document.createElement("listcell");
var cell2 = document.createElement("listcell");
cell1.setAttribute("label", completions[i][0]);
cell2.setAttribute("label", completions[i][1]);
//cell2.setAttribute("style", "color:green; font-family: sans; text-align:right");
cell2.setAttribute("style", "color:green; font-family: sans;");
item.appendChild(cell1);
item.appendChild(cell2);
preview_window.appendChild(item);
}
}/*}}}*/
function preview_window_select(event)/*{{{*/
{
var listcell = document.getElementsByTagName("listcell");
// 2 columns for now, use the first column
var index = (preview_window.selectedIndex * 2) + 0;
var val = listcell[index].getAttribute("label");
if (val && event.button == 0 && event.type == "dblclick") // left double click
openURLs(val);
else if (val && event.button == 1) // middle click
openURLsInNewTab(val);
else
return false;
}/*}}}*/
function preview_window_show()/*{{{*/
{
var items = preview_window.getElementsByTagName("listitem").length;
var height = get_pref("previewheight");
if (items > height)
items = height;
if (items < 3) // minimum of 3 entries, drop that constraint?
items = 3;
preview_window.setAttribute("rows", items.toString());
preview_window.hidden = false;
g_bufshow = false;
}/*}}}*/
// vim: set fdm=marker sw=4 ts=4 et: // vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -234,7 +234,8 @@ var g_settings = [/*{{{*/
["showstatuslinks", "ssli"], ["showstatuslinks", "ssli"],
["showstatuslinks", "ssli"], ["showstatuslinks", "ssli"],
"Show the destination of the link under the cursor in the status bar", "Show the destination of the link under the cursor in the status bar",
"Available items:<br/>"+ "Also links which are focused by keyboard commands like <code class=\"mapping\">&lt;Tab&gt;</code> are shown. "+
"Possible values:<br/>"+
"<ul><li><b>0</b>: Don't show link destination</li><li>" + "<ul><li><b>0</b>: Don't show link destination</li><li>" +
" <b>1</b>: Show the link in the status line</li><li>" + " <b>1</b>: Show the link in the status line</li><li>" +
" <b>2</b>: Show the link in the command line</li></ul>", " <b>2</b>: Show the link in the command line</li></ul>",
@@ -249,7 +250,7 @@ var g_settings = [/*{{{*/
["showtabline", "stal"], ["showtabline", "stal"],
["showtabline", "stal"], ["showtabline", "stal"],
"Control when to show the tab bar of opened web pages", "Control when to show the tab bar of opened web pages",
"Available items:<br/>"+ "Possible values:<br/>"+
"<ul><li><b>0</b>: Never show tab bar</li><li>"+ "<ul><li><b>0</b>: Never show tab bar</li><li>"+
" <b>1</b>: Show tab bar only if more than one tab is open</li><li>"+ " <b>1</b>: Show tab bar only if more than one tab is open</li><li>"+
" <b>2</b>: Always show tab bar</li></ul>"+ " <b>2</b>: Always show tab bar</li></ul>"+

View File

@@ -1,159 +0,0 @@
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 2 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
!_TAG_PROGRAM_NAME Exuberant Ctags //
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
!_TAG_PROGRAM_VERSION 5.6 //
abs_point find.js /^function abs_point (node) {$/;" f
addBookmark bookmarks.js /^function addBookmark(title, uri)$/;" f
addEventListeners vimperator.js /^function addEventListeners()$/;" f
addMode commands.js /^function addMode(mode)$/;" f
addToHistory commandline.js /^ function addToHistory(str)$/;" f
add_to_command_history commandline.js /^function add_to_command_history(str)$/;" f
beep commands.js /^function beep()$/;" f
bmadd commands.js /^function bmadd(str)$/;" f
bmdel commands.js /^function bmdel(str)$/;" f
bmshow commands.js /^function bmshow(filter, fullmode)$/;" f
Bookmarks bookmarks.js /^function Bookmarks()$/;" f
buffer_preview_toggle commands.js /^function buffer_preview_toggle()$/;" f
buffer_preview_update commands.js /^function buffer_preview_update(event)$/;" f
buffer_switch commands.js /^function buffer_switch(string)$/;" f
bufshow commands.js /^function bufshow(filter, in_comp_window)$/;" f
build_longest_common_substring completion.js /^function build_longest_common_substring(list, filter)\/*{{{*\/$/;" f
build_longest_starting_substring completion.js /^function build_longest_starting_substring(list, filter)\/*{{{*\/$/;" f
changeHintFocus hints.js /^ function changeHintFocus(linkNumString, oldLinkNumString)$/;" f
clearHighlight find.js /^function clearHighlight()$/;" f
clearSelection find.js /^function clearSelection() {$/;" f
CommandLine commandline.js /^function CommandLine ()$/;" f
completion_add_to_list commandline.js /^function completion_add_to_list(completion_item, at_beginning)\/*{{{*\/$/;" f
completion_fill_list commandline.js /^function completion_fill_list(startindex)\/*{{{*\/$/;" f
completion_select_next_item commandline.js /^function completion_select_next_item(has_list, has_full, has_longest)\/*{{{*\/$/;" f
completion_select_previous_item commandline.js /^function completion_select_previous_item(has_list, has_full, has_longest)\/*{{{*\/$/;" f
completion_show_list commandline.js /^function completion_show_list()\/*{{{*\/$/;" f
copyToClipboard commands.js /^function copyToClipboard(str)$/;" f
createCursorPositionString vimperator.js /^function createCursorPositionString()$/;" f
createHints hints.js /^ function createHints(win)$/;" f
createProgressBar vimperator.js /^function createProgressBar(aProgress)$/;" f
cumulativeOffset help.js /^ function cumulativeOffset(element)$/;" f
deleteBookmark bookmarks.js /^function deleteBookmark(url)$/;" f
del_url_mark commands.js /^function del_url_mark(mark)$/;" f
echo commands.js /^function echo(msg)$/;" f
echoerr commands.js /^function echoerr(msg)$/;" f
evaluateXPath commands.js /^function evaluateXPath(expression, doc, ordered)$/;" f
execute commands.js /^function execute(string)$/;" f
execute_command commands.js /^function execute_command(count, cmd, special, args, modifiers) \/\/ {{{$/;" f
exTabCompletion completion.js /^function exTabCompletion(str)$/;" f
filter_url_array completion.js /^function filter_url_array(urls, filter)\/*{{{*\/$/;" f
focusContent vimperator.js /^function focusContent(clear_command_line, clear_statusline)$/;" f
focusNextFrame commands.js /^function focusNextFrame()$/;" f
fopen file.js /^function fopen (path, mode, perms, tmp)$/;" f
formatHint hints.js /^ function formatHint(hintNum)$/;" f
fo_close file.js /^function fo_close()$/;" f
fo_read file.js /^function fo_read(max)$/;" f
fo_write file.js /^function fo_write(buf)$/;" f
genElemCoords hints.js /^ function genElemCoords(elem)$/;" f
genHintContainer hints.js /^ function genHintContainer(doc)$/;" f
getCurrentLinkLocation commands.js /^function getCurrentLinkLocation()$/;" f
getCurrentLocation commands.js /^function getCurrentLocation()$/;" f
getCurrentTitle commands.js /^function getCurrentTitle()$/;" f
getHintById hints.js /^ function getHintById(id, win)$/;" f
getLinkNodes vimperator.js /^function getLinkNodes(doc)$/;" f
getPageLinkNodes vimperator.js /^function getPageLinkNodes()$/;" f
getProperty bookmarks.js /^function getProperty( aInput, aArc, DS )$/;" f
get_bookmark_completions completion.js /^function get_bookmark_completions(filter)\/*{{{*\/$/;" f
get_buffer_completions completion.js /^function get_buffer_completions(filter)\/*{{{*\/$/;" f
get_command commands.js /^function get_command(cmd) \/\/ {{{$/;" f
get_command_completions completion.js /^function get_command_completions(filter)\/*{{{*\/$/;" f
get_file_completions completion.js /^function get_file_completions(filter)\/*{{{*\/$/;" f
get_firefox_pref settings.js /^function get_firefox_pref(name, default_value)$/;" f
get_help_completions completion.js /^function get_help_completions(filter)\/*{{{*\/$/;" f
get_history_completions completion.js /^function get_history_completions(filter)\/*{{{*\/$/;" f
get_longest_substring completion.js /^function get_longest_substring()\/*{{{*\/$/;" f
get_pref settings.js /^function get_pref(name, forced_default)$/;" f
get_search_completions completion.js /^function get_search_completions(filter)\/*{{{*\/$/;" f
get_setting settings.js /^function get_setting(cmd)\/*{{{*\/$/;" f
get_settings_completions completion.js /^function get_settings_completions(filter, unfiltered)\/*{{{*\/$/;" f
get_url_completions completion.js /^function get_url_completions(filter, complete)\/*{{{*\/$/;" f
get_url_mark commands.js /^function get_url_mark(mark)$/;" f
goUp commands.js /^function goUp(count)$/;" f
hasMode commands.js /^function hasMode(mode)$/;" f
help help.js /^function help(section, easter)$/;" f
highlightFind find.js /^function highlightFind(str, color, wrapped, dir, pt)$/;" f
historyGoToBeginning commands.js /^function historyGoToBeginning()$/;" f
historyGoToEnd commands.js /^function historyGoToEnd()$/;" f
hit_a_hint hints.js /^function hit_a_hint()$/;" f
hsshow commands.js /^function hsshow(filter, fullmode)$/;" f
init vimperator.js /^function init()$/;" f
initDoc hints.js /^ function initDoc(event)$/;" f
invalidateCoords hints.js /^ function invalidateCoords(doc)$/;" f
isDirectory commands.js /^function isDirectory(url)$/;" f
isFormElemFocused vimperator.js /^function isFormElemFocused()$/;" f
keyToString vimperator.js /^function keyToString(event)$/;" f
load_history commandline.js /^function load_history()$/;" f
LocalFile file.js /^function LocalFile(file, mode, perms, tmp)$/;" f
logMessage vimperator.js /^function logMessage(msg)$/;" f
logObject vimperator.js /^function logObject(object)$/;" f
lookupNamespaceURI commands.js /^ function lookupNamespaceURI(prefix) { $/;" f
makeHelpString help.js /^ function makeHelpString(commands, color, beg, end, func)$/;" f
makeSettingsHelpString help.js /^ function makeSettingsHelpString(command)$/;" f
multiliner commandline.js /^function multiliner(line, prev_match, heredoc)$/;" f
nsBrowserStatusHandler vimperator.js /^function nsBrowserStatusHandler() \/*{{{*\/$/;" f
onCommandBar2Keypress vimperator.js /^function onCommandBar2Keypress(evt)\/*{{{*\/$/;" f
onEscape vimperator.js /^function onEscape()$/;" f
onResize hints.js /^ function onResize(event)$/;" f
onVimperatorKeypress vimperator.js /^function onVimperatorKeypress(event)\/*{{{*\/$/;" f
openURLs commands.js /^function openURLs(str)$/;" f
openURLsInNewTab commands.js /^function openURLsInNewTab(str, activate)$/;" f
openVimperatorBar vimperator.js /^function openVimperatorBar(str)$/;" f
outputAddonsList commands.js /^function outputAddonsList(aTarget)$/;" f
parseBookmarkString bookmarks.js /^function parseBookmarkString(str, res)$/;" f
preview_window_fill completion.js /^function preview_window_fill(completions)\/*{{{*\/$/;" f
preview_window_select completion.js /^function preview_window_select(event)\/*{{{*\/$/;" f
preview_window_show completion.js /^function preview_window_show()\/*{{{*\/$/;" f
QM bookmarks.js /^function QM()$/;" f
quit commands.js /^function quit(save_session)$/;" f
reload commands.js /^function reload(all_tabs)$/;" f
removeHints hints.js /^ function removeHints(win)$/;" f
removeMode commands.js /^function removeMode(mode)$/;" f
restart commands.js /^function restart()$/;" f
save_history commandline.js /^function save_history()$/;" f
scrollBufferAbsolute commands.js /^function scrollBufferAbsolute(horizontal, vertical)$/;" f
scrollBufferRelative commands.js /^function scrollBufferRelative(right, down)$/;" f
Search find.js /^function Search()$/;" f
selectInput commands.js /^function selectInput()$/;" f
set commands.js /^function set(args, special)$/;" f
setCommand commandline.js /^ function setCommand(cmd)$/;" f
setCurrentMode commands.js /^function setCurrentMode(mode)$/;" f
setErrorStyle commandline.js /^ function setErrorStyle()$/;" f
setHintStyle hints.js /^ function setHintStyle(hintElem, styleString)$/;" f
setMouseOverElement hints.js /^ function setMouseOverElement(elem)$/;" f
setNormalStyle commandline.js /^ function setNormalStyle()$/;" f
setPrompt commandline.js /^ function setPrompt(prompt)$/;" f
setSelection find.js /^function setSelection(range) {$/;" f
setStatusbarColor vimperator.js /^function setStatusbarColor(color)$/;" f
set_firefox_pref settings.js /^function set_firefox_pref(name, value)$/;" f
set_guioptions settings.js /^function set_guioptions(value)$/;" f
set_location_mark commands.js /^function set_location_mark(mark)$/;" f
set_pref settings.js /^function set_pref(name, value)$/;" f
set_showtabline settings.js /^function set_showtabline(value)$/;" f
set_url_mark commands.js /^function set_url_mark(mark, url)$/;" f
showHints hints.js /^ function showHints(win, off)$/;" f
showMode commands.js /^function showMode()$/;" f
showStatusbarMessage vimperator.js /^function showStatusbarMessage(msg, field)$/;" f
show_location_marks commands.js /^function show_location_marks(mark)$/;" f
show_url_marks commands.js /^function show_url_marks(mark)$/;" f
source commands.js /^function source(filename, silent)$/;" f
startCoordLoader hints.js /^ function startCoordLoader(doc)$/;" f
stepInHistory commands.js /^function stepInHistory(steps)$/;" f
stringToURLs commands.js /^function stringToURLs(str)$/;" f
tab commands.js /^function tab()$/;" f
tab_go commands.js /^function tab_go(index)$/;" f
tab_remove commands.js /^function tab_remove(count, focus_left_tab, quit_on_last_tab)$/;" f
toggle_images commands.js /^function toggle_images() {$/;" f
tokenize_ex commands.js /^function tokenize_ex(string, tag)$/;" f
unload vimperator.js /^function unload()$/;" f
updateStatusbar vimperator.js /^function updateStatusbar(message)$/;" f
Vimperator vimperator.js /^function Vimperator()$/;" f
yankCurrentLocation commands.js /^function yankCurrentLocation()$/;" f
zoom_in commands.js /^function zoom_in(factor)$/;" f
zoom_to commands.js /^function zoom_to(value) {};$/;" f

View File

@@ -68,9 +68,8 @@ var prev_match = new Array(5);
var heredoc = ''; var heredoc = '';
// handles to our gui elements // handles to our gui elements
var preview_window = null; //var preview_window = null;
var status_line = null; var status_line = null;
var completion_list = null;
var command_line = null; var command_line = null;
// our status bar fields // our status bar fields
@@ -151,7 +150,7 @@ nsBrowserStatusHandler.prototype =
{ {
updateStatusbar(); updateStatusbar();
// also reset the buffer list, since the url titles are valid here // also reset the buffer list, since the url titles are valid here
buffer_preview_update(); showBufferList(true);
} }
return 0; return 0;
}, },
@@ -209,20 +208,25 @@ function init()
{ {
// init the main object // init the main object
vimperator = new Vimperator; vimperator = new Vimperator;
// these inner classes are only created here, because outside the init()
// function, the chrome:// is not ready
Vimperator.prototype.qm = new QM; Vimperator.prototype.qm = new QM;
Vimperator.prototype.search = new Search; Vimperator.prototype.search = new Search;
Vimperator.prototype.previewwindow = new InformationList("vimperator-preview-window", { incremental_fill: false, max_items: 10 });
Vimperator.prototype.bufferwindow = new InformationList("vimperator-buffer-window", { incremental_fill: false, max_items: 10 });
// XXX: move elsewhere // XXX: move elsewhere
vimperator.registerCallback("submit", MODE_EX, function(command) { /*vimperator.*/execute(command); } ); vimperator.registerCallback("submit", MODE_EX, function(command) { /*vimperator.*/execute(command); } );
vimperator.registerCallback("complete", MODE_EX, function(str) { return exTabCompletion(str); } ); vimperator.registerCallback("complete", MODE_EX, function(str) { return exTabCompletion(str); } );
preview_window = document.getElementById("vim-preview_window"); //preview_window = document.getElementById("vim-preview_window");
status_line = document.getElementById("vim-statusbar"); status_line = document.getElementById("vim-statusbar");
completion_list = document.getElementById("vim-completion"); //completion_list = document.getElementById("vim-completion");
command_line = document.getElementById("vim-commandbar"); command_line = document.getElementById("vim-commandbar");
if (!completion_list || !command_line) // if (!completion_list || !command_line)
alert("GUI not correctly created! Strange things will happen (until I find out, how to exit this script by code)"); // alert("GUI not correctly created! Strange things will happen (until I find out, how to exit this script by code)");
// Setup our status handler - from browser.js // Setup our status handler - from browser.js
window.XULBrowserWindow = new nsBrowserStatusHandler(); window.XULBrowserWindow = new nsBrowserStatusHandler();
@@ -280,8 +284,6 @@ function init()
set_firefox_pref("browser.startup.page", 3); // start with saved session set_firefox_pref("browser.startup.page", 3); // start with saved session
logMessage("Initialized");
/* /*
* Finally, read a ~/.vimperatorrc * Finally, read a ~/.vimperatorrc
* Make sourcing asynchronous, otherwise commands that open new tabs won't work * Make sourcing asynchronous, otherwise commands that open new tabs won't work
@@ -290,6 +292,8 @@ function init()
source("~/.vimperatorrc", true); source("~/.vimperatorrc", true);
logMessage("~/.vimperatorrc sourced"); logMessage("~/.vimperatorrc sourced");
}, 50); }, 50);
logMessage("Vimperator fully initialized");
} }
function unload() function unload()
@@ -637,10 +641,10 @@ function addEventListeners()
{ {
var browser = event.target.linkedBrowser; var browser = event.target.linkedBrowser;
browser.removeProgressListener(buffer_changed_listener); browser.removeProgressListener(buffer_changed_listener);
buffer_preview_update(); updateBufferList();
}, false); }, false);
container.addEventListener("TabSelect", buffer_preview_update, false); container.addEventListener("TabSelect", updateBufferList, false);
container.addEventListener("TabMove", buffer_preview_update, false); container.addEventListener("TabMove", updateBufferList, false);
} }
@@ -672,7 +676,7 @@ var buffer_changed_listener =
// This fires when the location bar changes i.e load event is confirmed // This fires when the location bar changes i.e load event is confirmed
// or when the user switches tabs // or when the user switches tabs
onLocationChange: function(aProgress, aRequest, aURI) { /*alert('locchange');*/buffer_preview_update(); return 0; }, onLocationChange: function(aProgress, aRequest, aURI) { /*alert('locchange');*/ setTimeout( updateBufferList, 250); return 0; },
onProgressChange:function(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress){ return 0; }, onProgressChange:function(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress){ return 0; },
onStatusChange: function() {return 0;}, onStatusChange: function() {return 0;},
onSecurityChange: function() {return 0;}, onSecurityChange: function() {return 0;},
@@ -993,7 +997,7 @@ function Vimperator()
return false; return false;
} }
this.foo = function () {alert("foo");}; this.foo = function () {alert("foo");};
// just forward these echo commands // just forward these echo commands
this.echo = this.commandline.echo; this.echo = this.commandline.echo;

View File

@@ -38,7 +38,6 @@ the terms of any one of the MPL, the GPL or the LGPL.
xmlns:html="http://www.w3.org/1999/xhtml" xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<!-- you may not believe it, but order is really important here -->
<script type="application/x-javascript" src="help.js"/> <script type="application/x-javascript" src="help.js"/>
<script type="application/x-javascript" src="vimperator.js"/> <script type="application/x-javascript" src="vimperator.js"/>
<script type="application/x-javascript" src="commands.js"/> <script type="application/x-javascript" src="commands.js"/>
@@ -53,9 +52,22 @@ the terms of any one of the MPL, the GPL or the LGPL.
<window id="main-window"> <window id="main-window">
<toolbar id="vimperator-toolbar" hidden="false" align="center" fullscreentoolbar="true"> <toolbar id="vimperator-toolbar" hidden="false" align="center" fullscreentoolbar="true">
<vbox id="vim-container" flex="1" hidden="false"> <vbox id="vim-container" flex="1" hidden="false">
<listbox id="vim-preview_window" class="plain" rows="10" flex="1" hidden="true" <listbox id="vimperator-buffer-window" class="plain" rows="10" flex="1" hidden="true"
ondblclick="preview_window_select(event);" onclick="preview_window_select(event);" onkeydown="preview_window_select(event);" onclick= "vimperator.bufferwindow.onEvent(event);"
style="font-family: monospace; -moz-user-focus:ignore; overflow:-moz-scrollbars-none;"> ondblclick="vimperator.bufferwindow.onEvent(event);"
onkeydown= "vimperator.bufferwindow.onEvent(event);"
style="font-family: monospace; overflow:-moz-scrollbars-none;">
<listcols>
<listcol flex="1" width="50%"/>
<listcol flex="1" width="50%"/>
</listcols>
</listbox>
<listbox id="vimperator-preview-window" class="plain" rows="10" flex="1" hidden="true"
onclick= "vimperator.previewwindow.onEvent(event);"
ondblclick="vimperator.previewwindow.onEvent(event);"
onkeydown= "vimperator.previewwindow.onEvent(event);"
style="font-family: monospace; overflow:-moz-scrollbars-none;">
<listcols> <listcols>
<listcol flex="1" width="50%"/> <listcol flex="1" width="50%"/>
<listcol flex="1" width="50%"/> <listcol flex="1" width="50%"/>
@@ -102,11 +114,9 @@ the terms of any one of the MPL, the GPL or the LGPL.
<keyset id="mainKeyset"> <keyset id="mainKeyset">
<key id="key_open_vimbar" key=":" oncommand="vimperator.commandline.open(':', '', MODE_EX);" modifiers=""/> <key id="key_open_vimbar" key=":" oncommand="vimperator.commandline.open(':', '', MODE_EX);" modifiers=""/>
<!--<key id="key_open_vimbar" key=":" oncommand="vimperator.commandline.open(':');alert('from keyset');" modifiers=""/>-->
<key id="key_stop" keycode="VK_ESCAPE" oncommand="onEscape();"/> <key id="key_stop" keycode="VK_ESCAPE" oncommand="onEscape();"/>
<!-- other keys are handled inside vimperator.js event loop -->
<!-- other keys are handled inside vimperator.js event loop -->
</keyset> </keyset>
</window> </window>
</overlay> </overlay>
<!-- vim: set et ts=4 sw=4 : -->