mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-05 02:45:48 +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:
@@ -1,4 +1,4 @@
|
||||
// XXX: remove!
|
||||
// XXX: move somehere else!
|
||||
function save_history()
|
||||
{
|
||||
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
|
||||
*
|
||||
@@ -67,7 +66,7 @@ function CommandLine ()
|
||||
const UNINITIALIZED = -2; // notifies us, if we need to start history/tab-completion from the beginning
|
||||
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 history = new Array();
|
||||
@@ -77,7 +76,7 @@ function CommandLine ()
|
||||
// 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_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 completion_index = UNINITIALIZED;
|
||||
@@ -89,49 +88,49 @@ function CommandLine ()
|
||||
|
||||
function setNormalStyle()
|
||||
{
|
||||
command_widget.inputField.setAttribute("style","font-family: monospace;");
|
||||
command_widget.inputField.setAttribute("style","font-family: monospace;");
|
||||
}
|
||||
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 /
|
||||
function setPrompt(prompt)
|
||||
{
|
||||
if (typeof(prompt) != "string")
|
||||
prompt = "";
|
||||
if (typeof(prompt) != "string")
|
||||
prompt = "";
|
||||
|
||||
prompt_widget.value = prompt;
|
||||
if (prompt)
|
||||
{
|
||||
// Initially (in the xul) the prompt is 'collapsed', this makes
|
||||
// sure it's visible, then we toggle the display which works better
|
||||
prompt_widget.style.visibility = 'visible';
|
||||
prompt_widget.style.display = 'inline';
|
||||
prompt_widget.size = prompt.length;
|
||||
}
|
||||
else
|
||||
{
|
||||
prompt_widget.style.display = 'none';
|
||||
}
|
||||
prompt_widget.value = prompt;
|
||||
if (prompt)
|
||||
{
|
||||
// Initially (in the xul) the prompt is 'collapsed', this makes
|
||||
// sure it's visible, then we toggle the display which works better
|
||||
prompt_widget.style.visibility = 'visible';
|
||||
prompt_widget.style.display = 'inline';
|
||||
prompt_widget.size = prompt.length;
|
||||
}
|
||||
else
|
||||
{
|
||||
prompt_widget.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
// Sets the command - e.g. 'tabopen', 'open http://example.com/'
|
||||
function setCommand(cmd)
|
||||
{
|
||||
command_widget.value = cmd;
|
||||
command_widget.value = cmd;
|
||||
}
|
||||
|
||||
function addToHistory(str)
|
||||
{
|
||||
// first remove all old history elements which have this string
|
||||
history = history.filter(function(elem) {
|
||||
return elem != str;
|
||||
});
|
||||
// add string to the command line history
|
||||
if (str.length >= 1 && history.push(str) > HISTORY_SIZE)
|
||||
history.shift();
|
||||
// first remove all old history elements which have this string
|
||||
history = history.filter(function(elem) {
|
||||
return elem != str;
|
||||
});
|
||||
// add string to the command line history
|
||||
if (str.length >= 1 && history.push(str) > HISTORY_SIZE)
|
||||
history.shift();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -140,7 +139,7 @@ function CommandLine ()
|
||||
|
||||
this.getCommand = function()
|
||||
{
|
||||
return command_widget.value;
|
||||
return command_widget.value;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -148,422 +147,480 @@ function CommandLine ()
|
||||
*/
|
||||
this.open = function(prompt, cmd, minor_mode)
|
||||
{
|
||||
if (!prompt)
|
||||
prompt = "";
|
||||
if (!cmd)
|
||||
cmd = "";
|
||||
if (minor_mode)
|
||||
setCurrentMode(minor_mode);
|
||||
if (!prompt)
|
||||
prompt = "";
|
||||
if (!cmd)
|
||||
cmd = "";
|
||||
if (minor_mode)
|
||||
setCurrentMode(minor_mode);
|
||||
|
||||
setNormalStyle();
|
||||
setPrompt(prompt);
|
||||
setCommand(cmd);
|
||||
history_index = UNINITIALIZED;
|
||||
completion_index = UNINITIALIZED;
|
||||
command_widget.focus();
|
||||
setNormalStyle();
|
||||
setPrompt(prompt);
|
||||
setCommand(cmd);
|
||||
history_index = UNINITIALIZED;
|
||||
completion_index = UNINITIALIZED;
|
||||
command_widget.focus();
|
||||
};
|
||||
|
||||
this.echo = function(str)
|
||||
{
|
||||
setNormalStyle();
|
||||
setPrompt("");
|
||||
setCommand(str);
|
||||
setNormalStyle();
|
||||
setPrompt("");
|
||||
setCommand(str);
|
||||
};
|
||||
|
||||
this.echoErr = function(str)
|
||||
{
|
||||
setErrorStyle();
|
||||
setPrompt("");
|
||||
setCommand(str);
|
||||
setErrorStyle();
|
||||
setPrompt("");
|
||||
setCommand(str);
|
||||
};
|
||||
|
||||
this.clear = function()
|
||||
{
|
||||
setPrompt(" "); // looks faster than an empty string
|
||||
setCommand("");
|
||||
setNormalStyle();
|
||||
setPrompt(" "); // looks faster than an empty string
|
||||
setCommand("");
|
||||
setNormalStyle();
|
||||
};
|
||||
|
||||
|
||||
this.onEvent = function(event)
|
||||
{
|
||||
//var end = false;
|
||||
var command = this.getCommand();
|
||||
//var end = false;
|
||||
var command = this.getCommand();
|
||||
|
||||
if(event.type == "blur")
|
||||
{
|
||||
// when we do a command_widget.focus() we get a blur event immediately,
|
||||
// so check if the target is the actualy input field
|
||||
if (event.target == command_widget.inputField)
|
||||
{
|
||||
addToHistory(command);
|
||||
completionlist.hide();
|
||||
}
|
||||
}
|
||||
else if(event.type == "input")
|
||||
{
|
||||
vimperator.triggerCallback("change", command);
|
||||
}
|
||||
else if(event.type == "keypress")
|
||||
{
|
||||
var key = keyToString(event);
|
||||
/* user pressed ENTER to carry out a command */
|
||||
if (key == "<Return>" || key == "<C-j>" || key == "<C-m>")
|
||||
{
|
||||
// try {
|
||||
// [prev_match, heredoc, end] = multiliner(command, prev_match, heredoc);
|
||||
// } catch(e) {
|
||||
// logObject(e);
|
||||
// echoerr(e.name + ": " + e.message);
|
||||
// prev_match = new Array(5);
|
||||
// heredoc = '';
|
||||
// return;
|
||||
// }
|
||||
// if (!end)
|
||||
// command_line.value = "";
|
||||
if(event.type == "blur")
|
||||
{
|
||||
// when we do a command_widget.focus() we get a blur event immediately,
|
||||
// so check if the target is the actualy input field
|
||||
if (event.target == command_widget.inputField)
|
||||
{
|
||||
addToHistory(command);
|
||||
completionlist.hide();
|
||||
}
|
||||
}
|
||||
else if(event.type == "input")
|
||||
{
|
||||
vimperator.triggerCallback("change", command);
|
||||
}
|
||||
else if(event.type == "keypress")
|
||||
{
|
||||
var key = keyToString(event);
|
||||
/* user pressed ENTER to carry out a command */
|
||||
if (key == "<Return>" || key == "<C-j>" || key == "<C-m>")
|
||||
{
|
||||
// FIXME: move to execute() in commands.js
|
||||
// try {
|
||||
// [prev_match, heredoc, end] = multiliner(command, prev_match, heredoc);
|
||||
// } catch(e) {
|
||||
// logObject(e);
|
||||
// echoerr(e.name + ": " + e.message);
|
||||
// prev_match = new Array(5);
|
||||
// heredoc = '';
|
||||
// return;
|
||||
// }
|
||||
// if (!end)
|
||||
// command_line.value = "";
|
||||
|
||||
// the command is saved in the blur() handler
|
||||
focusContent();
|
||||
var res = vimperator.triggerCallback("submit", command);
|
||||
return res;
|
||||
}
|
||||
/* user pressed ESCAPE to cancel this prompt */
|
||||
else if (key == "<Esc>" || key == "<C-[>")
|
||||
{
|
||||
var res = vimperator.triggerCallback("cancel");
|
||||
addToHistory(command);
|
||||
this.clear();
|
||||
focusContent(true, true);
|
||||
return res;
|
||||
}
|
||||
// the command is saved in the blur() handler
|
||||
focusContent();
|
||||
var res = vimperator.triggerCallback("submit", command);
|
||||
return res;
|
||||
}
|
||||
/* user pressed ESCAPE to cancel this prompt */
|
||||
else if (key == "<Esc>" || key == "<C-[>" || key == "<C-c>")
|
||||
{
|
||||
var res = vimperator.triggerCallback("cancel");
|
||||
addToHistory(command);
|
||||
this.clear();
|
||||
focusContent(true, true);
|
||||
return res;
|
||||
}
|
||||
|
||||
/* user pressed UP or DOWN arrow to cycle history completion */
|
||||
else if (key == "<Up>" || key == "<Down>")
|
||||
{
|
||||
//always reset the tab completion if we use up/down keys
|
||||
completion_index = UNINITIALIZED;
|
||||
/* user pressed UP or DOWN arrow to cycle history completion */
|
||||
else if (key == "<Up>" || key == "<Down>")
|
||||
{
|
||||
//always reset the tab completion if we use up/down keys
|
||||
completion_index = UNINITIALIZED;
|
||||
|
||||
/* save 'start' position for iterating through the history */
|
||||
if (history_index == UNINITIALIZED)
|
||||
{
|
||||
history_index = history.length;
|
||||
history_start = command;
|
||||
}
|
||||
/* save 'start' position for iterating through the history */
|
||||
if (history_index == UNINITIALIZED)
|
||||
{
|
||||
history_index = history.length;
|
||||
history_start = command;
|
||||
}
|
||||
|
||||
while (history_index >= -1 && history_index <= history.length)
|
||||
{
|
||||
key == "<Up>" ? history_index-- : history_index++;
|
||||
if (history_index == history.length) // user pressed DOWN when there is no newer history item
|
||||
{
|
||||
setCommand(history_start);
|
||||
return;
|
||||
}
|
||||
// cannot go past history start/end
|
||||
if (history_index <= -1)
|
||||
{
|
||||
history_index = 0;
|
||||
beep();
|
||||
break;
|
||||
}
|
||||
if (history_index >= history.length + 1)
|
||||
{
|
||||
history_index = history.length;
|
||||
beep();
|
||||
break;
|
||||
}
|
||||
while (history_index >= -1 && history_index <= history.length)
|
||||
{
|
||||
key == "<Up>" ? history_index-- : history_index++;
|
||||
if (history_index == history.length) // user pressed DOWN when there is no newer history item
|
||||
{
|
||||
setCommand(history_start);
|
||||
return;
|
||||
}
|
||||
// cannot go past history start/end
|
||||
if (history_index <= -1)
|
||||
{
|
||||
history_index = 0;
|
||||
beep();
|
||||
break;
|
||||
}
|
||||
if (history_index >= history.length + 1)
|
||||
{
|
||||
history_index = history.length;
|
||||
beep();
|
||||
break;
|
||||
}
|
||||
|
||||
if (history[history_index].indexOf(history_start) == 0)
|
||||
{
|
||||
setCommand(history[history_index]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
beep();
|
||||
}
|
||||
if (history[history_index].indexOf(history_start) == 0)
|
||||
{
|
||||
setCommand(history[history_index]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
beep();
|
||||
}
|
||||
|
||||
/* user pressed TAB to get completions of a command */
|
||||
else if (key == "<Tab>" || key == "<S-Tab>")
|
||||
{
|
||||
//always reset our completion history so up/down keys will start with new values
|
||||
history_index = UNINITIALIZED;
|
||||
/* user pressed TAB to get completions of a command */
|
||||
else if (key == "<Tab>" || key == "<S-Tab>")
|
||||
{
|
||||
//always reset our completion history so up/down keys will start with new values
|
||||
history_index = UNINITIALIZED;
|
||||
|
||||
// we need to build our completion list first
|
||||
if (completion_index == UNINITIALIZED)
|
||||
{
|
||||
// FIXME: completions.clear();
|
||||
completion_start_index = 0;
|
||||
// we need to build our completion list first
|
||||
if (completion_index == UNINITIALIZED)
|
||||
{
|
||||
completion_start_index = 0;
|
||||
|
||||
completion_index = -1;
|
||||
wild_index = 0;
|
||||
completion_index = -1;
|
||||
wild_index = 0;
|
||||
|
||||
completion_prefix = command.substring(0, command_widget.selectionStart);
|
||||
completion_postfix = command.substring(command_widget.selectionStart);
|
||||
var res = vimperator.triggerCallback("complete", completion_prefix);
|
||||
if (res)
|
||||
[completion_start_index, completions] = res;
|
||||
completion_prefix = command.substring(0, command_widget.selectionStart);
|
||||
completion_postfix = command.substring(command_widget.selectionStart);
|
||||
var res = vimperator.triggerCallback("complete", completion_prefix);
|
||||
if (res)
|
||||
[completion_start_index, completions] = res;
|
||||
|
||||
// Sort the completion list
|
||||
if (get_pref('wildoptions').match(/\bsort\b/))
|
||||
{
|
||||
completions.sort(function(a, b) {
|
||||
if (a[0] < b[0])
|
||||
return -1;
|
||||
else if (a[0] > b[0])
|
||||
return 1;
|
||||
else
|
||||
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;
|
||||
}
|
||||
// Sort the completion list
|
||||
if (get_pref('wildoptions').match(/\bsort\b/))
|
||||
{
|
||||
completions.sort(function(a, b) {
|
||||
if (a[0] < b[0])
|
||||
return -1;
|
||||
else if (a[0] > b[0])
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var wim = get_pref('wildmode').split(/,/);
|
||||
var has_list = false;
|
||||
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 (completions.length == 0)
|
||||
{
|
||||
beep();
|
||||
// prevent tab from moving to the next field
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
return;
|
||||
}
|
||||
|
||||
// show the list
|
||||
if (has_list)
|
||||
completionlist.show(completions);
|
||||
var wim = get_pref('wildmode').split(/,/);
|
||||
var has_list = false;
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
// show the list
|
||||
if (has_list)
|
||||
{
|
||||
if (completion_index < 0)
|
||||
completionlist.show(completions);
|
||||
else
|
||||
completionlist.show();
|
||||
}
|
||||
|
||||
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 (full)
|
||||
{
|
||||
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 (full && completions.length > 1)
|
||||
{
|
||||
setCommand(completion_prefix + completion_postfix);
|
||||
//completion_list.selectedIndex = -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (longest && completions.length > 1)
|
||||
var compl = get_longest_substring();
|
||||
else if (full)
|
||||
var compl = completions[completion_index][0];
|
||||
else if (completions.length == 1)
|
||||
var compl = completions[0][0];
|
||||
if (compl)
|
||||
{
|
||||
setCommand(command.substring(0, completion_start_index) + compl + completion_postfix);
|
||||
command_widget.selectionStart = command_widget.selectionEnd = completion_start_index + compl.length;
|
||||
if (completion_index == -1 && !longest) // wrapped around matches, reset command line
|
||||
{
|
||||
if (full && completions.length > 1)
|
||||
{
|
||||
setCommand(completion_prefix + completion_postfix);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (longest && completions.length > 1)
|
||||
var compl = get_longest_substring();
|
||||
else if (full)
|
||||
var compl = completions[completion_index][0];
|
||||
else if (completions.length == 1)
|
||||
var compl = completions[0][0];
|
||||
if (compl)
|
||||
{
|
||||
setCommand(command.substring(0, completion_start_index) + compl + completion_postfix);
|
||||
command_widget.selectionStart = command_widget.selectionEnd = completion_start_index + compl.length;
|
||||
|
||||
// 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
|
||||
// Needed for :source to grab another set of completions after a file/directory has been filled out
|
||||
if (completions.length == 1 && !full)
|
||||
completion_index = UNINITIALIZED;
|
||||
}
|
||||
}
|
||||
// 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
|
||||
// Needed for :source to grab another set of completions after a file/directory has been filled out
|
||||
if (completions.length == 1 && !full)
|
||||
completion_index = UNINITIALIZED;
|
||||
}
|
||||
}
|
||||
|
||||
// prevent tab from moving to the next field
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}
|
||||
else if (key == "<BS>")
|
||||
{
|
||||
// reset the tab completion
|
||||
completion_index = history_index = UNINITIALIZED;
|
||||
// prevent tab from moving to the next field
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}
|
||||
else if (key == "<BS>")
|
||||
{
|
||||
// reset the tab completion
|
||||
completion_index = history_index = UNINITIALIZED;
|
||||
|
||||
// and blur the command line if there is no text left
|
||||
if(command.length == 0)
|
||||
{
|
||||
this.clear();
|
||||
focusContent();
|
||||
}
|
||||
}
|
||||
else // any other key
|
||||
{
|
||||
// reset the tab completion
|
||||
completion_index = history_index = UNINITIALIZED;
|
||||
}
|
||||
}
|
||||
// and blur the command line if there is no text left
|
||||
if(command.length == 0)
|
||||
{
|
||||
this.clear();
|
||||
focusContent();
|
||||
}
|
||||
}
|
||||
else // any other key
|
||||
{
|
||||
// reset the tab completion
|
||||
completion_index = history_index = UNINITIALIZED;
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
var completion_widget = document.getElementById("vim-completion");
|
||||
var list_offset = 0; // how many items is the displayed list shifted from the internal tab index
|
||||
var list_index = 0; // list_offset + list_index = completions[item]
|
||||
if(options)
|
||||
{
|
||||
if (options.max_items) max_items = options.max_items;
|
||||
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
|
||||
function addItem(completion_item, at_beginning)
|
||||
{
|
||||
var item = document.createElement("listitem");
|
||||
var cell1 = document.createElement("listcell");
|
||||
var cell2 = document.createElement("listcell");
|
||||
var widget = document.getElementById(id);
|
||||
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 list_index = 0; // list_offset + list_index = completions[item]
|
||||
|
||||
cell1.setAttribute("label", completion_item[0]);
|
||||
cell2.setAttribute("label", completion_item[1]);
|
||||
cell2.setAttribute("style", "color:green; font-family: sans");
|
||||
// add a single completion item to the list
|
||||
function addItem(completion_item, at_beginning)
|
||||
{
|
||||
var item = document.createElement("listitem");
|
||||
var cell1 = document.createElement("listcell");
|
||||
var cell2 = document.createElement("listcell");
|
||||
|
||||
item.appendChild(cell1);
|
||||
item.appendChild(cell2);
|
||||
if (at_beginning == true)
|
||||
{
|
||||
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);
|
||||
}
|
||||
cell1.setAttribute("label", completion_item[0]);
|
||||
cell2.setAttribute("label", completion_item[1]);
|
||||
cell2.setAttribute("style", "color:green; font-family: sans");
|
||||
|
||||
/**
|
||||
* uses the entries in completions to fill the listbox
|
||||
* @param startindex: start at this index and show MAX_ITEMS
|
||||
* @returns the number of items
|
||||
*/
|
||||
function fill(startindex)
|
||||
{
|
||||
var complength = completions.length;
|
||||
item.appendChild(cell1);
|
||||
item.appendChild(cell2);
|
||||
if (at_beginning == true)
|
||||
{
|
||||
var items = widget.getElementsByTagName("listitem");
|
||||
if (items.length > 0)
|
||||
widget.insertBefore(item, items[0]);
|
||||
else
|
||||
widget.appendChild(item);
|
||||
}
|
||||
else
|
||||
widget.appendChild(item);
|
||||
}
|
||||
|
||||
// remove all old items first
|
||||
var items = completion_widget.getElementsByTagName("listitem");
|
||||
while (items.length > 0) { completion_widget.removeChild(items[0]);}
|
||||
/**
|
||||
* uses the entries in completions to fill the listbox
|
||||
*
|
||||
* @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
|
||||
if (startindex + MAX_ITEMS > complength)
|
||||
startindex = complength - MAX_ITEMS;
|
||||
if (startindex < 0)
|
||||
startindex = 0;
|
||||
// remove all old items first
|
||||
var items = widget.getElementsByTagName("listitem");
|
||||
while (items.length > 0) { widget.removeChild(items[0]);}
|
||||
|
||||
list_offset = startindex;
|
||||
list_index = -1;
|
||||
if(!incremental_fill)
|
||||
{
|
||||
for (i in completions)
|
||||
addItem(completions[i], false);
|
||||
return complength;
|
||||
}
|
||||
|
||||
for(i = startindex; i < complength && i < startindex + MAX_ITEMS; i++)
|
||||
{
|
||||
addItem(completions[i], false);
|
||||
}
|
||||
// find start index
|
||||
if (startindex + max_items > complength)
|
||||
startindex = complength - max_items;
|
||||
if (startindex < 0)
|
||||
startindex = 0;
|
||||
|
||||
return (i-startindex);
|
||||
}
|
||||
list_offset = startindex;
|
||||
list_index = -1;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
this.len = function() {alert(completions.length);};
|
||||
this.show = function(compl)
|
||||
{
|
||||
completions = compl;
|
||||
fill(0);
|
||||
for(i = startindex; i < complength && i < startindex + max_items; i++)
|
||||
{
|
||||
addItem(completions[i], false);
|
||||
}
|
||||
|
||||
var length = completions.length;
|
||||
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;
|
||||
}
|
||||
}
|
||||
return (i-startindex);
|
||||
}
|
||||
|
||||
this.hide = function()
|
||||
{
|
||||
completion_widget.hidden = true;
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* 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");
|
||||
|
||||
/**
|
||||
* select index, refill list if necessary
|
||||
*/
|
||||
this.selectItem = function(index)
|
||||
{
|
||||
if(completion_widget.hidden)
|
||||
return;
|
||||
if (compl)
|
||||
{
|
||||
completions = compl;
|
||||
fill(0);
|
||||
}
|
||||
|
||||
// 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;
|
||||
var length = completions.length;
|
||||
if (length > max_items)
|
||||
length = max_items;
|
||||
if (length >= min_items)
|
||||
{
|
||||
widget.setAttribute("rows", length.toString());
|
||||
widget.hidden = false;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
widget.hidden = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (new_offset + MAX_ITEMS > completions.length)
|
||||
new_offset = completions.length - MAX_ITEMS;
|
||||
if (new_offset < 0)
|
||||
new_offset = 0;
|
||||
this.hide = function()
|
||||
{
|
||||
widget.hidden = true;
|
||||
}
|
||||
|
||||
// for speed reason: just remove old item, and add the new one at the end of the list
|
||||
var items = completion_widget.getElementsByTagName("listitem");
|
||||
if (new_offset == list_offset + 1)
|
||||
{
|
||||
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);
|
||||
this.visible = function()
|
||||
{
|
||||
return !widget.hidden;
|
||||
}
|
||||
|
||||
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:
|
||||
|
||||
@@ -127,7 +127,7 @@ var g_commands = [/*{{{*/
|
||||
["buffers"],
|
||||
"Show a list of all buffers",
|
||||
"If the list is already shown, close the preview window.",
|
||||
buffer_preview_toggle,
|
||||
toggleBufferList,
|
||||
null
|
||||
],
|
||||
[
|
||||
@@ -284,7 +284,7 @@ var g_commands = [/*{{{*/
|
||||
["pc[lose]"],
|
||||
"Close preview window on bottom of screen",
|
||||
null,
|
||||
function() { preview_window.hidden = true; },
|
||||
function() { vimperator.previewwindow.hide(); },
|
||||
null
|
||||
],
|
||||
[
|
||||
@@ -353,7 +353,7 @@ var g_commands = [/*{{{*/
|
||||
],
|
||||
[
|
||||
["source", "so"],
|
||||
[":so[urce][!] {file}"],
|
||||
["so[urce][!] {file}"],
|
||||
"Read Ex commands from {file}",
|
||||
"The .vimperatorrc file in your home directory is always sourced at start up.<br/>"+
|
||||
"~ is supported as a shortcut for the $HOME directory.<br/>" +
|
||||
@@ -526,14 +526,14 @@ var g_mappings = [/*{{{*/
|
||||
["b {number}"],
|
||||
"Open a prompt to switch buffers",
|
||||
"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"],
|
||||
"Toggle buffer list",
|
||||
"Toggles the display of the buffer list which shows all opened tabs,",
|
||||
buffer_preview_toggle
|
||||
toggleBufferList
|
||||
],
|
||||
[
|
||||
["d"],
|
||||
@@ -1574,8 +1574,7 @@ function bmshow(filter, fullmode)
|
||||
else
|
||||
{
|
||||
var items = get_bookmark_completions(filter);
|
||||
preview_window_fill(items);
|
||||
preview_window_show();
|
||||
vimperator.previewwindow.show(items);
|
||||
}
|
||||
}
|
||||
function hsshow(filter, fullmode)
|
||||
@@ -1585,8 +1584,7 @@ function hsshow(filter, fullmode)
|
||||
else
|
||||
{
|
||||
var items = get_history_completions(filter);
|
||||
preview_window_fill(items);
|
||||
preview_window_show();
|
||||
vimperator.previewwindow.show(items);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1697,39 +1695,6 @@ function tab_move(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)
|
||||
{
|
||||
var match;
|
||||
@@ -1744,27 +1709,27 @@ function buffer_switch(string)
|
||||
}
|
||||
|
||||
//toggles the buffer preview window
|
||||
function buffer_preview_toggle()
|
||||
function toggleBufferList()
|
||||
{
|
||||
if(g_bufshow == true)
|
||||
{
|
||||
preview_window.hidden = true;
|
||||
g_bufshow = false;
|
||||
}
|
||||
if (vimperator.bufferwindow.visible())
|
||||
vimperator.bufferwindow.hide();
|
||||
else
|
||||
{
|
||||
bufshow("", false);
|
||||
g_bufshow = true;
|
||||
var items = get_buffer_completions("");
|
||||
vimperator.bufferwindow.show(items);
|
||||
vimperator.bufferwindow.selectItem(getBrowser().mTabContainer.selectedIndex);
|
||||
}
|
||||
}
|
||||
|
||||
//updates the buffer preview in place
|
||||
function buffer_preview_update(event)
|
||||
// updates the buffer preview in place only if list is visible
|
||||
function updateBufferList()
|
||||
{
|
||||
if(g_bufshow == true)
|
||||
bufshow("", false);
|
||||
}
|
||||
if (!vimperator.bufferwindow.visible())
|
||||
return false;
|
||||
|
||||
var items = get_buffer_completions("");
|
||||
vimperator.bufferwindow.show(items);
|
||||
vimperator.bufferwindow.selectItem(getBrowser().mTabContainer.selectedIndex);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// scrolling ////////////////////////////////////////////////////// {{{1
|
||||
|
||||
@@ -15,14 +15,6 @@ var history_loaded = false;
|
||||
// array of our bookmark 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
|
||||
// 2nd element: help description
|
||||
var g_completions = new Array();
|
||||
@@ -518,7 +510,6 @@ function get_buffer_completions(filter)/*{{{*/
|
||||
}/*}}}*/
|
||||
|
||||
|
||||
|
||||
// return [startindex, [[itemtext, itemhelp],...]]
|
||||
function exTabCompletion(str)
|
||||
{
|
||||
@@ -553,57 +544,4 @@ function exTabCompletion(str)
|
||||
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:
|
||||
|
||||
@@ -234,7 +234,8 @@ var g_settings = [/*{{{*/
|
||||
["showstatuslinks", "ssli"],
|
||||
["showstatuslinks", "ssli"],
|
||||
"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\"><Tab></code> are shown. "+
|
||||
"Possible values:<br/>"+
|
||||
"<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>2</b>: Show the link in the command line</li></ul>",
|
||||
@@ -249,7 +250,7 @@ var g_settings = [/*{{{*/
|
||||
["showtabline", "stal"],
|
||||
["showtabline", "stal"],
|
||||
"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>"+
|
||||
" <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>"+
|
||||
|
||||
@@ -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
|
||||
@@ -68,9 +68,8 @@ var prev_match = new Array(5);
|
||||
var heredoc = '';
|
||||
|
||||
// handles to our gui elements
|
||||
var preview_window = null;
|
||||
//var preview_window = null;
|
||||
var status_line = null;
|
||||
var completion_list = null;
|
||||
var command_line = null;
|
||||
|
||||
// our status bar fields
|
||||
@@ -151,7 +150,7 @@ nsBrowserStatusHandler.prototype =
|
||||
{
|
||||
updateStatusbar();
|
||||
// also reset the buffer list, since the url titles are valid here
|
||||
buffer_preview_update();
|
||||
showBufferList(true);
|
||||
}
|
||||
return 0;
|
||||
},
|
||||
@@ -209,20 +208,25 @@ function init()
|
||||
{
|
||||
// init the main object
|
||||
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.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
|
||||
vimperator.registerCallback("submit", MODE_EX, function(command) { /*vimperator.*/execute(command); } );
|
||||
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");
|
||||
completion_list = document.getElementById("vim-completion");
|
||||
//completion_list = document.getElementById("vim-completion");
|
||||
command_line = document.getElementById("vim-commandbar");
|
||||
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)");
|
||||
// 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)");
|
||||
|
||||
// Setup our status handler - from browser.js
|
||||
window.XULBrowserWindow = new nsBrowserStatusHandler();
|
||||
@@ -280,8 +284,6 @@ function init()
|
||||
set_firefox_pref("browser.startup.page", 3); // start with saved session
|
||||
|
||||
|
||||
logMessage("Initialized");
|
||||
|
||||
/*
|
||||
* Finally, read a ~/.vimperatorrc
|
||||
* Make sourcing asynchronous, otherwise commands that open new tabs won't work
|
||||
@@ -290,6 +292,8 @@ function init()
|
||||
source("~/.vimperatorrc", true);
|
||||
logMessage("~/.vimperatorrc sourced");
|
||||
}, 50);
|
||||
|
||||
logMessage("Vimperator fully initialized");
|
||||
}
|
||||
|
||||
function unload()
|
||||
@@ -637,10 +641,10 @@ function addEventListeners()
|
||||
{
|
||||
var browser = event.target.linkedBrowser;
|
||||
browser.removeProgressListener(buffer_changed_listener);
|
||||
buffer_preview_update();
|
||||
updateBufferList();
|
||||
}, false);
|
||||
container.addEventListener("TabSelect", buffer_preview_update, false);
|
||||
container.addEventListener("TabMove", buffer_preview_update, false);
|
||||
container.addEventListener("TabSelect", updateBufferList, 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
|
||||
// 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; },
|
||||
onStatusChange: function() {return 0;},
|
||||
onSecurityChange: function() {return 0;},
|
||||
@@ -993,7 +997,7 @@ function Vimperator()
|
||||
return false;
|
||||
}
|
||||
|
||||
this.foo = function () {alert("foo");};
|
||||
this.foo = function () {alert("foo");};
|
||||
|
||||
// just forward these echo commands
|
||||
this.echo = this.commandline.echo;
|
||||
|
||||
@@ -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="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="vimperator.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">
|
||||
<toolbar id="vimperator-toolbar" hidden="false" align="center" fullscreentoolbar="true">
|
||||
<vbox id="vim-container" flex="1" hidden="false">
|
||||
<listbox id="vim-preview_window" class="plain" rows="10" flex="1" hidden="true"
|
||||
ondblclick="preview_window_select(event);" onclick="preview_window_select(event);" onkeydown="preview_window_select(event);"
|
||||
style="font-family: monospace; -moz-user-focus:ignore; overflow:-moz-scrollbars-none;">
|
||||
<listbox id="vimperator-buffer-window" class="plain" rows="10" flex="1" hidden="true"
|
||||
onclick= "vimperator.bufferwindow.onEvent(event);"
|
||||
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>
|
||||
<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">
|
||||
<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();"/>
|
||||
|
||||
<!-- other keys are handled inside vimperator.js event loop -->
|
||||
<!-- other keys are handled inside vimperator.js event loop -->
|
||||
</keyset>
|
||||
</window>
|
||||
|
||||
</overlay>
|
||||
<!-- vim: set et ts=4 sw=4 : -->
|
||||
|
||||
Reference in New Issue
Block a user