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

use the 'singleton' construction idiom rather than classical constructors for

creating the bookmarks, history, commandline, search, previewwindow,
bufferwindow, statusline, buffer, editor, marks and quickmarks objects
This commit is contained in:
Doug Kearns
2007-11-11 02:18:15 +00:00
parent ca8e6f4529
commit 434844b688
9 changed files with 2539 additions and 2491 deletions

View File

@@ -32,6 +32,7 @@ vimperator.Bookmarks = function () //{{{
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION ///////////////////////////////////////// ////////////////////// PRIVATE SECTION /////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{
const history_service = Components.classes["@mozilla.org/browser/nav-history-service;1"] const history_service = Components.classes["@mozilla.org/browser/nav-history-service;1"]
.getService(Components.interfaces.nsINavHistoryService); .getService(Components.interfaces.nsINavHistoryService);
const bookmarks_service = Components.classes["@mozilla.org/browser/nav-bookmarks-service;1"] const bookmarks_service = Components.classes["@mozilla.org/browser/nav-bookmarks-service;1"]
@@ -92,25 +93,26 @@ vimperator.Bookmarks = function () //{{{
// close a container after using it! // close a container after using it!
rootNode.containerOpen = false; rootNode.containerOpen = false;
} }
return;
} }
/////////////////////////////////////////////////////////////////////////////}}} /////////////////////////////////////////////////////////////////////////////}}}
////////////////////// PUBLIC SECTION ////////////////////////////////////////// ////////////////////// PUBLIC SECTION //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{
return {
// if "bypass_cache" is true, it will force a reload of the bookmarks database // if "bypass_cache" is true, it will force a reload of the bookmarks database
// on my PC, it takes about 1ms for each bookmark to load, so loading 1000 bookmarks // on my PC, it takes about 1ms for each bookmark to load, so loading 1000 bookmarks
// takes about 1 sec // takes about 1 sec
this.get = function (filter, tags, bypass_cache) get: function (filter, tags, bypass_cache)
{ {
if (!bookmarks || bypass_cache) if (!bookmarks || bypass_cache)
load(); load();
return vimperator.completion.filterURLArray(bookmarks, filter, tags); return vimperator.completion.filterURLArray(bookmarks, filter, tags);
} },
this.add = function (title, url, keyword, tags) add: function (title, url, keyword, tags)
{ {
if (!bookmarks) if (!bookmarks)
load(); load();
@@ -144,10 +146,10 @@ vimperator.Bookmarks = function () //{{{
//also update bookmark cache //also update bookmark cache
bookmarks.unshift([url, title, keyword, tags || []]); bookmarks.unshift([url, title, keyword, tags || []]);
return true; return true;
} },
// returns number of deleted bookmarks // returns number of deleted bookmarks
this.remove = function (url) remove: function (url)
{ {
if (!url) if (!url)
return 0; return 0;
@@ -174,11 +176,11 @@ vimperator.Bookmarks = function () //{{{
load(); load();
return count.value; return count.value;
} },
// TODO: add filtering // TODO: add filtering
// also ensures that each search engine has a Vimperator-friendly alias // also ensures that each search engine has a Vimperator-friendly alias
this.getSearchEngines = function () getSearchEngines: function ()
{ {
var search_engines = []; var search_engines = [];
var firefox_engines = search_service.getVisibleEngines({ }); var firefox_engines = search_service.getVisibleEngines({ });
@@ -207,23 +209,23 @@ vimperator.Bookmarks = function () //{{{
} }
return search_engines; return search_engines;
} },
// TODO: add filtering // TODO: add filtering
// format of returned array: // format of returned array:
// [keyword, helptext, url] // [keyword, helptext, url]
this.getKeywords = function () getKeywords: function ()
{ {
if (!keywords) if (!keywords)
load(); load();
return keywords; return keywords;
} },
// if @param engine_name is null, it uses the default search engine // if @param engine_name is null, it uses the default search engine
// @returns the url for the search string // @returns the url for the search string
// if the search also requires a postdata, [url, postdata] is returned // if the search also requires a postdata, [url, postdata] is returned
this.getSearchURL = function (text, engine_name) getSearchURL: function (text, engine_name)
{ {
var url = null; var url = null;
var postdata = null; var postdata = null;
@@ -269,9 +271,9 @@ vimperator.Bookmarks = function () //{{{
return [url, postdata]; return [url, postdata];
else else
return url; // can be null return url; // can be null
} },
this.list = function (filter, tags, fullmode) list: function (filter, tags, fullmode)
{ {
if (fullmode) if (fullmode)
{ {
@@ -325,6 +327,8 @@ vimperator.Bookmarks = function () //{{{
vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE); vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE);
} }
} }
};
//}}} //}}}
} //}}} } //}}}
@@ -333,6 +337,7 @@ vimperator.History = function () //{{{
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION ///////////////////////////////////////// ////////////////////// PRIVATE SECTION /////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{
const history_service = Components.classes["@mozilla.org/browser/nav-history-service;1"] const history_service = Components.classes["@mozilla.org/browser/nav-history-service;1"]
.getService(Components.interfaces.nsINavHistoryService); .getService(Components.interfaces.nsINavHistoryService);
@@ -374,17 +379,19 @@ vimperator.History = function () //{{{
////////////////////// PUBLIC SECTION ////////////////////////////////////////// ////////////////////// PUBLIC SECTION //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{
this.get = function (filter) return {
get: function (filter)
{ {
if (!history) if (!history)
load(); load();
return vimperator.completion.filterURLArray(history, filter); return vimperator.completion.filterURLArray(history, filter);
} },
// the history is automatically added to the Places global history // the history is automatically added to the Places global history
// so just update our cached history here // so just update our cached history here
this.add = function (url, title) add: function (url, title)
{ {
if (!history) if (!history)
load(); load();
@@ -395,11 +402,11 @@ vimperator.History = function () //{{{
history.unshift([url, title]); history.unshift([url, title]);
return true; return true;
}; },
// TODO: better names? // TODO: better names?
// and move to vimperator.buffer.? // and move to vimperator.buffer.?
this.stepTo = function (steps) stepTo: function (steps)
{ {
var index = getWebNavigation().sessionHistory.index + steps; var index = getWebNavigation().sessionHistory.index + steps;
@@ -411,9 +418,9 @@ vimperator.History = function () //{{{
{ {
vimperator.beep(); vimperator.beep();
} }
} },
this.goToStart = function () goToStart: function ()
{ {
var index = getWebNavigation().sessionHistory.index; var index = getWebNavigation().sessionHistory.index;
@@ -424,9 +431,9 @@ vimperator.History = function () //{{{
} }
getWebNavigation().gotoIndex(0); getWebNavigation().gotoIndex(0);
} },
this.goToEnd = function () goToEnd: function ()
{ {
var index = getWebNavigation().sessionHistory.index; var index = getWebNavigation().sessionHistory.index;
var max = getWebNavigation().sessionHistory.count - 1; var max = getWebNavigation().sessionHistory.count - 1;
@@ -438,9 +445,9 @@ vimperator.History = function () //{{{
} }
getWebNavigation().gotoIndex(max); getWebNavigation().gotoIndex(max);
} },
this.list = function (filter, fullmode) list: function (filter, fullmode)
{ {
if (fullmode) if (fullmode)
{ {
@@ -474,6 +481,8 @@ vimperator.History = function () //{{{
vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE); vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE);
} }
} }
};
//}}} //}}}
} //}}} } //}}}
@@ -582,8 +591,10 @@ vimperator.Marks = function () //{{{
////////////////////// PUBLIC SECTION ////////////////////////////////////////// ////////////////////// PUBLIC SECTION //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{
return {
// TODO: add support for frameset pages // TODO: add support for frameset pages
this.add = function (mark) add: function (mark)
{ {
var win = window.content; var win = window.content;
@@ -611,9 +622,9 @@ vimperator.Marks = function () //{{{
vimperator.log("Adding local mark: " + mark + " | " + win.location.href + " | (" + position.x + ", " + position.y + ")", 5); vimperator.log("Adding local mark: " + mark + " | " + win.location.href + " | (" + position.x + ", " + position.y + ")", 5);
local_marks[mark].push({ location: win.location.href, position: position }); local_marks[mark].push({ location: win.location.href, position: position });
} }
} },
this.remove = function (filter, special) remove: function (filter, special)
{ {
if (special) if (special)
{ {
@@ -635,9 +646,9 @@ vimperator.Marks = function () //{{{
removeLocalMark(mark); removeLocalMark(mark);
} }
} }
} },
this.jumpTo = function (mark) jumpTo: function (mark)
{ {
var ok = false; var ok = false;
@@ -689,9 +700,9 @@ vimperator.Marks = function () //{{{
if (!ok) if (!ok)
vimperator.echoerr("E20: Mark not set"); // FIXME: move up? vimperator.echoerr("E20: Mark not set"); // FIXME: move up?
} },
this.list = function (filter) list: function (filter)
{ {
var marks = getSortedMarks(); var marks = getSortedMarks();
@@ -729,6 +740,8 @@ vimperator.Marks = function () //{{{
vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE); vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE);
} }
};
//}}} //}}}
} //}}} } //}}}
@@ -751,12 +764,14 @@ vimperator.QuickMarks = function () //{{{
////////////////////// PUBLIC SECTION ////////////////////////////////////////// ////////////////////// PUBLIC SECTION //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{
this.add = function (qmark, location) return {
add: function (qmark, location)
{ {
qmarks[qmark] = location; qmarks[qmark] = location;
} },
this.remove = function (filter) remove: function (filter)
{ {
var pattern = new RegExp("[" + filter.replace(/\s+/g, "") + "]"); var pattern = new RegExp("[" + filter.replace(/\s+/g, "") + "]");
@@ -765,14 +780,14 @@ vimperator.QuickMarks = function () //{{{
if (pattern.test(qmark)) if (pattern.test(qmark))
delete qmarks[qmark]; delete qmarks[qmark];
} }
} },
this.removeAll = function () removeAll: function ()
{ {
qmarks = {}; qmarks = {};
} },
this.jumpTo = function (qmark, where) jumpTo: function (qmark, where)
{ {
var url = qmarks[qmark]; var url = qmarks[qmark];
@@ -780,9 +795,9 @@ vimperator.QuickMarks = function () //{{{
vimperator.open(url, where); vimperator.open(url, where);
else else
vimperator.echoerr("E20: QuickMark not set"); vimperator.echoerr("E20: QuickMark not set");
} },
this.list = function (filter) list: function (filter)
{ {
var marks = []; var marks = [];
@@ -820,9 +835,9 @@ vimperator.QuickMarks = function () //{{{
list += "</table>"; list += "</table>";
vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE); vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE);
} },
this.destroy = function () destroy: function ()
{ {
// save the quickmarks // save the quickmarks
var saved_qmarks = ""; var saved_qmarks = "";
@@ -835,6 +850,7 @@ vimperator.QuickMarks = function () //{{{
vimperator.options.setPref("quickmarks", saved_qmarks); vimperator.options.setPref("quickmarks", saved_qmarks);
} }
};
//}}} //}}}
} //}}} } //}}}

View File

@@ -31,6 +31,7 @@ vimperator.Buffer = function () //{{{
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION ///////////////////////////////////////// ////////////////////// PRIVATE SECTION /////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{
// used for the "B" mapping to remember the last :buffer[!] command // used for the "B" mapping to remember the last :buffer[!] command
var lastBufferSwitchArgs = ""; var lastBufferSwitchArgs = "";
var lastBufferSwitchSpecial = true; var lastBufferSwitchSpecial = true;
@@ -126,46 +127,49 @@ vimperator.Buffer = function () //{{{
/////////////////////////////////////////////////////////////////////////////}}} /////////////////////////////////////////////////////////////////////////////}}}
////////////////////// PUBLIC SECTION ////////////////////////////////////////// ////////////////////// PUBLIC SECTION //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{
this.lastInputField = null; // used to keep track of the right field for "gi"
return {
lastInputField: null, // used to keep track of the right field for "gi"
this.__defineGetter__("URL", function () get URL()
{ {
// TODO: .URL is not defined for XUL documents // TODO: .URL is not defined for XUL documents
//return window.content.document.URL; //return window.content.document.URL;
return window.content.document.location.href; return window.content.document.location.href;
}); },
this.__defineGetter__("pageHeight", function () get pageHeight()
{ {
return window.content.innerHeight; return window.content.innerHeight;
}); },
this.__defineGetter__("textZoom", function () get textZoom()
{ {
return getBrowser().mCurrentBrowser.markupDocumentViewer.textZoom * 100; return getBrowser().mCurrentBrowser.markupDocumentViewer.textZoom * 100;
}); },
this.__defineSetter__("textZoom", function (value) set textZoom(value)
{ {
setZoom(value, false); setZoom(value, false);
}); },
this.__defineGetter__("fullZoom", function () get fullZoom()
{ {
return getBrowser().mCurrentBrowser.markupDocumentViewer.fullZoom * 100; return getBrowser().mCurrentBrowser.markupDocumentViewer.fullZoom * 100;
}); },
this.__defineSetter__("fullZoom", function (value) set fullZoom(value)
{ {
setZoom(value, true); setZoom(value, true);
}); },
this.__defineGetter__("title", function () get title()
{ {
return window.content.document.title; return window.content.document.title;
}); },
// returns an XPathResult object // returns an XPathResult object
this.evaluateXPath = function (expression, doc, elem, asIterator) evaluateXPath: function (expression, doc, elem, asIterator)
{ {
if (!doc) if (!doc)
doc = window.content.document; doc = window.content.document;
@@ -186,12 +190,12 @@ vimperator.Buffer = function () //{{{
); );
return result; return result;
} },
// in contrast to vim, returns the selection if one is made, // in contrast to vim, returns the selection if one is made,
// otherwise tries to guess the current word unter the text cursor // otherwise tries to guess the current word unter the text cursor
// NOTE: might change the selection // NOTE: might change the selection
this.getCurrentWord = function () getCurrentWord: function ()
{ {
var selection = window.content.getSelection().toString(); var selection = window.content.getSelection().toString();
@@ -209,9 +213,9 @@ vimperator.Buffer = function () //{{{
} }
return selection; return selection;
} },
this.list = function (fullmode) list: function (fullmode)
{ {
if (fullmode) if (fullmode)
{ {
@@ -256,14 +260,14 @@ vimperator.Buffer = function () //{{{
vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE); vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE);
} }
} },
this.scrollBottom = function () scrollBottom: function ()
{ {
scrollToPercentiles(-1, 100); scrollToPercentiles(-1, 100);
} },
this.scrollColumns = function (cols) scrollColumns: function (cols)
{ {
var win = window.document.commandDispatcher.focusedWindow; var win = window.document.commandDispatcher.focusedWindow;
const COL_WIDTH = 20; const COL_WIDTH = 20;
@@ -272,44 +276,44 @@ vimperator.Buffer = function () //{{{
vimperator.beep(); vimperator.beep();
win.scrollBy(COL_WIDTH * cols, 0); win.scrollBy(COL_WIDTH * cols, 0);
} },
this.scrollEnd = function () scrollEnd: function ()
{ {
scrollToPercentiles(100, -1); scrollToPercentiles(100, -1);
} },
this.scrollLines = function (lines) scrollLines: function (lines)
{ {
var win = window.document.commandDispatcher.focusedWindow; var win = window.document.commandDispatcher.focusedWindow;
checkScrollYBounds(win, lines); checkScrollYBounds(win, lines);
win.scrollByLines(lines); win.scrollByLines(lines);
} },
this.scrollPages = function (pages) scrollPages: function (pages)
{ {
var win = window.document.commandDispatcher.focusedWindow; var win = window.document.commandDispatcher.focusedWindow;
checkScrollYBounds(win, pages); checkScrollYBounds(win, pages);
win.scrollByPages(pages); win.scrollByPages(pages);
} },
this.scrollToPercentile = function (percentage) scrollToPercentile: function (percentage)
{ {
scrollToPercentiles(-1, percentage); scrollToPercentiles(-1, percentage);
} },
this.scrollStart = function () scrollStart: function ()
{ {
scrollToPercentiles(0, -1); scrollToPercentiles(0, -1);
} },
this.scrollTop = function () scrollTop: function ()
{ {
scrollToPercentiles(-1, 0); scrollToPercentiles(-1, 0);
} },
// TODO: allow callback for filtering out unwanted frames? User defined? // TODO: allow callback for filtering out unwanted frames? User defined?
this.shiftFrameFocus = function (count, forward) shiftFrameFocus: function (count, forward)
{ {
if (!window.content.document instanceof HTMLDocument) if (!window.content.document instanceof HTMLDocument)
return; return;
@@ -405,10 +409,10 @@ vimperator.Buffer = function () //{{{
// remove the frame indicator // remove the frame indicator
setTimeout(function () { doc.body.removeChild(indicator); }, 500); setTimeout(function () { doc.body.removeChild(indicator); }, 500);
} },
// updates the buffer preview in place only if list is visible // updates the buffer preview in place only if list is visible
this.updateBufferList = function () updateBufferList: function ()
{ {
if (!vimperator.bufferwindow.visible()) if (!vimperator.bufferwindow.visible())
return false; return false;
@@ -416,12 +420,12 @@ vimperator.Buffer = function () //{{{
var items = vimperator.completion.get_buffer_completions(""); var items = vimperator.completion.get_buffer_completions("");
vimperator.bufferwindow.show(items); vimperator.bufferwindow.show(items);
vimperator.bufferwindow.selectItem(getBrowser().mTabContainer.selectedIndex); vimperator.bufferwindow.selectItem(getBrowser().mTabContainer.selectedIndex);
} },
// XXX: should this be in v.buffers. or v.tabs.? // XXX: should this be in v.buffers. or v.tabs.?
// "buffer" is a string which matches the URL or title of a buffer, if it // "buffer" is a string which matches the URL or title of a buffer, if it
// is null, the last used string is used again // is null, the last used string is used again
this.switchTo = function (buffer, allowNonUnique, count, reverse) switchTo: function (buffer, allowNonUnique, count, reverse)
{ {
if (buffer != null) if (buffer != null)
{ {
@@ -476,19 +480,19 @@ vimperator.Buffer = function () //{{{
vimperator.tabs.select(matches[index], false); vimperator.tabs.select(matches[index], false);
} }
}; },
this.zoomIn = function (steps, full_zoom) zoomIn: function (steps, full_zoom)
{ {
bumpZoomLevel(steps, full_zoom); bumpZoomLevel(steps, full_zoom);
}; },
this.zoomOut = function (steps, full_zoom) zoomOut: function (steps, full_zoom)
{ {
bumpZoomLevel(-steps, full_zoom); bumpZoomLevel(-steps, full_zoom);
}; },
this.pageInfo = function (verbose) pageInfo: function (verbose)
{ {
// TODO: copied from firefox. Needs some review/work... // TODO: copied from firefox. Needs some review/work...
// const feedTypes = { // const feedTypes = {
@@ -728,6 +732,8 @@ vimperator.Buffer = function () //{{{
} }
vimperator.echo(pageInfoText, vimperator.commandline.FORCE_MULTILINE); vimperator.echo(pageInfoText, vimperator.commandline.FORCE_MULTILINE);
} }
};
//}}} //}}}
} //}}} } //}}}

View File

@@ -610,7 +610,7 @@ vimperator.Completion = function () // {{{
return [start, completions]; return [start, completions];
} //}}} } //}}}
} };
} // }}} } // }}}
// vim: set fdm=marker sw=4 ts=4 et: // vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -50,7 +50,9 @@ vimperator.Editor = function () //{{{
return ed.controllers.getControllerForCommand("cmd_beginLine"); return ed.controllers.getControllerForCommand("cmd_beginLine");
} }
this.line = function () return {
line: function ()
{ {
var line = 1; var line = 1;
var text = editor().value; var text = editor().value;
@@ -58,9 +60,9 @@ vimperator.Editor = function () //{{{
if (text[i] == "\n") if (text[i] == "\n")
line++; line++;
return line; return line;
} },
this.col = function () col: function ()
{ {
var col = 1; var col = 1;
var text = editor().value; var text = editor().value;
@@ -71,22 +73,22 @@ vimperator.Editor = function () //{{{
col = 1; col = 1;
} }
return col; return col;
} },
this.unselectText = function () unselectText: function ()
{ {
var elt = window.document.commandDispatcher.focusedElement; var elt = window.document.commandDispatcher.focusedElement;
if (elt && elt.selectionEnd) if (elt && elt.selectionEnd)
elt.selectionEnd = elt.selectionStart; elt.selectionEnd = elt.selectionStart;
} },
this.selectedText = function () selectedText: function ()
{ {
var text = editor().value; var text = editor().value;
return text.substring(editor().selectionStart, editor().selectionEnd); return text.substring(editor().selectionStart, editor().selectionEnd);
} },
this.pasteClipboard = function () pasteClipboard: function ()
{ {
var elt = window.document.commandDispatcher.focusedElement; var elt = window.document.commandDispatcher.focusedElement;
@@ -103,10 +105,10 @@ vimperator.Editor = function () //{{{
elt.selectionStart = rangeStart + tempStr2.length; elt.selectionStart = rangeStart + tempStr2.length;
elt.selectionEnd = elt.selectionStart; elt.selectionEnd = elt.selectionStart;
} }
} },
// count is optional, defaults to 1 // count is optional, defaults to 1
this.executeCommand = function (cmd, count) executeCommand: function (cmd, count)
{ {
var controller = getController(); var controller = getController();
if (!controller || !controller.supportsCommand(cmd) || !controller.isCommandEnabled(cmd)) if (!controller || !controller.supportsCommand(cmd) || !controller.isCommandEnabled(cmd))
@@ -138,11 +140,11 @@ vimperator.Editor = function () //{{{
} }
return true; return true;
} },
// cmd = y, d, c // cmd = y, d, c
// motion = b, 0, gg, G, etc. // motion = b, 0, gg, G, etc.
this.executeCommandWithMotion = function (cmd, motion, count) executeCommandWithMotion: function (cmd, motion, count)
{ {
if (!typeof count == "number" || count < 1) if (!typeof count == "number" || count < 1)
count = 1; count = 1;
@@ -223,13 +225,13 @@ vimperator.Editor = function () //{{{
return false; return false;
} }
return true; return true;
} },
// This function will move/select up to given "pos" // This function will move/select up to given "pos"
// Simple setSelectionRange() would be better, but we want to maintain the correct // Simple setSelectionRange() would be better, but we want to maintain the correct
// order of selectionStart/End (a firefox bug always makes selectionStart <= selectionEnd) // order of selectionStart/End (a firefox bug always makes selectionStart <= selectionEnd)
// Use only for small movements! // Use only for small movements!
this.moveToPosition = function (pos, forward, select) moveToPosition: function (pos, forward, select)
{ {
if (!select) if (!select)
{ {
@@ -259,10 +261,10 @@ vimperator.Editor = function () //{{{
} }
while ( editor().selectionStart != pos ); while ( editor().selectionStart != pos );
} }
} },
// returns the position of char // returns the position of char
this.findCharForward = function (char, count) findCharForward: function (char, count)
{ {
if (!editor()) if (!editor())
return -1; return -1;
@@ -286,9 +288,10 @@ vimperator.Editor = function () //{{{
vimperator.beep(); vimperator.beep();
return -1; return -1;
} },
// returns the position of char // returns the position of char
this.findCharBackward = function (char, count) findCharBackward: function (char, count)
{ {
if (!editor()) if (!editor())
return -1; return -1;
@@ -312,9 +315,9 @@ vimperator.Editor = function () //{{{
vimperator.beep(); vimperator.beep();
return -1; return -1;
} },
this.editWithExternalEditor = function () editWithExternalEditor: function ()
{ {
var textBox = document.commandDispatcher.focusedElement; var textBox = document.commandDispatcher.focusedElement;
var editor = vimperator.options["editor"]; var editor = vimperator.options["editor"];
@@ -391,12 +394,12 @@ vimperator.Editor = function () //{{{
}, timeout); }, timeout);
tmpfile.remove(false); tmpfile.remove(false);
} },
// Abbreviations {{{ // Abbreviations {{{
this.abbreviations = {}; abbreviations: {
this.abbreviations.__iterator__ = function () __iterator__: function ()
{ {
var tmpCmd; var tmpCmd;
for (var lhs in abbrev) for (var lhs in abbrev)
@@ -408,9 +411,10 @@ vimperator.Editor = function () //{{{
} }
} }
} }
},
// filter is i, c or "!" (insert or command abbreviations or both) // filter is i, c or "!" (insert or command abbreviations or both)
this.listAbbreviations = function (filter, lhs) listAbbreviations: function (filter, lhs)
{ {
if (lhs) // list only that one if (lhs) // list only that one
{ {
@@ -457,9 +461,9 @@ vimperator.Editor = function () //{{{
list += "</table>"; list += "</table>";
vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE); vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE);
} }
} },
this.addAbbreviation = function (filter, lhs, rhs) addAbbreviation: function (filter, lhs, rhs)
{ {
if (!abbrev[lhs]) if (!abbrev[lhs])
{ {
@@ -541,9 +545,9 @@ vimperator.Editor = function () //{{{
// 1 not !: opposite mode (first), add/change 'second' and END // 1 not !: opposite mode (first), add/change 'second' and END
// 1 not !: same mode (first), overwrite first this END // 1 not !: same mode (first), overwrite first this END
// //
} },
this.removeAbbreviation = function (filter, lhs) removeAbbreviation: function (filter, lhs)
{ {
if (!lhs) if (!lhs)
{ {
@@ -587,9 +591,9 @@ vimperator.Editor = function () //{{{
vimperator.echoerr("E24: No such abbreviation"); vimperator.echoerr("E24: No such abbreviation");
return false; return false;
} },
this.removeAllAbbreviations = function (filter) removeAllAbbreviations: function (filter)
{ {
if (filter == "!") if (filter == "!")
{ {
@@ -606,9 +610,9 @@ vimperator.Editor = function () //{{{
} }
} }
} }
} },
this.expandAbbreviation = function (filter) // try to find an candidate and replace accordingly expandAbbreviation: function (filter) // try to find an candidate and replace accordingly
{ {
var textbox = editor(); var textbox = editor();
var text = textbox.value; var text = textbox.value;
@@ -637,6 +641,8 @@ vimperator.Editor = function () //{{{
} }
return true; return true;
} //}}} } //}}}
};
} //}}} } //}}}
// vim: set fdm=marker sw=4 ts=4 et: // vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -39,7 +39,8 @@ the terms of any one of the MPL, the GPL or the LGPL.
// make sure you only create this object when the "vimperator" object is ready // make sure you only create this object when the "vimperator" object is ready
vimperator.Search = function () //{{{ vimperator.Search = function () //{{{
{ {
var self = this; // needed for callbacks since "this" is the "vimperator" object in a callback // FIXME:
//var self = this; // needed for callbacks since "this" is the "vimperator" object in a callback
var found = false; // true if the last search was successful var found = false; // true if the last search was successful
var backwards = false; // currently searching backwards var backwards = false; // currently searching backwards
var search_string = ""; // current search string (without modifiers) var search_string = ""; // current search string (without modifiers)
@@ -51,13 +52,13 @@ vimperator.Search = function () //{{{
var links_only = false; // search is limited to link text only var links_only = false; // search is limited to link text only
// Event handlers for search - closure is needed // Event handlers for search - closure is needed
vimperator.registerCallback("change", vimperator.modes.SEARCH_FORWARD, function (command) { self.searchKeyPressed(command); }); vimperator.registerCallback("change", vimperator.modes.SEARCH_FORWARD, function (command) { vimperator.search.searchKeyPressed(command); });
vimperator.registerCallback("submit", vimperator.modes.SEARCH_FORWARD, function (command) { self.searchSubmitted(command); }); vimperator.registerCallback("submit", vimperator.modes.SEARCH_FORWARD, function (command) { vimperator.search.searchSubmitted(command); });
vimperator.registerCallback("cancel", vimperator.modes.SEARCH_FORWARD, function () { self.searchCanceled(); }); vimperator.registerCallback("cancel", vimperator.modes.SEARCH_FORWARD, function () { vimperator.search.searchCanceled(); });
// TODO: allow advanced modes in register/triggerCallback // TODO: allow advanced modes in register/triggerCallback
vimperator.registerCallback("change", vimperator.modes.SEARCH_BACKWARD, function (command) { self.searchKeyPressed(command); }); vimperator.registerCallback("change", vimperator.modes.SEARCH_BACKWARD, function (command) { vimperator.search.searchKeyPressed(command); });
vimperator.registerCallback("submit", vimperator.modes.SEARCH_BACKWARD, function (command) { self.searchSubmitted(command); }); vimperator.registerCallback("submit", vimperator.modes.SEARCH_BACKWARD, function (command) { vimperator.search.searchSubmitted(command); });
vimperator.registerCallback("cancel", vimperator.modes.SEARCH_BACKWARD, function () { self.searchCanceled(); }); vimperator.registerCallback("cancel", vimperator.modes.SEARCH_BACKWARD, function () { vimperator.search.searchCanceled(); });
// set search_string, search_pattern, case_sensitive, links_only // set search_string, search_pattern, case_sensitive, links_only
function processUserPattern(pattern) function processUserPattern(pattern)
@@ -104,9 +105,11 @@ vimperator.Search = function () //{{{
search_string = pattern; search_string = pattern;
} }
return {
// Called when the search dialog is asked for // Called when the search dialog is asked for
// If you omit "mode", it will default to forward searching // If you omit "mode", it will default to forward searching
this.openSearchDialog = function (mode) openSearchDialog: function (mode)
{ {
if (mode == vimperator.modes.SEARCH_BACKWARD) if (mode == vimperator.modes.SEARCH_BACKWARD)
{ {
@@ -120,11 +123,11 @@ vimperator.Search = function () //{{{
} }
// TODO: focus the top of the currently visible screen // TODO: focus the top of the currently visible screen
} },
// Finds text in a page // Finds text in a page
// TODO: backwards seems impossible i fear :( // TODO: backwards seems impossible i fear :(
this.find = function (str, backwards) find: function (str, backwards)
{ {
var fastFind = getBrowser().fastFind; var fastFind = getBrowser().fastFind;
@@ -137,10 +140,10 @@ vimperator.Search = function () //{{{
vimperator.echoerr("E486: Pattern not found: " + search_pattern); vimperator.echoerr("E486: Pattern not found: " + search_pattern);
return found; return found;
} },
// Called when the current search needs to be repeated // Called when the current search needs to be repeated
this.findAgain = function (reverse) findAgain: function (reverse)
{ {
// this hack is needed to make n/N work with the correct string, if // this hack is needed to make n/N work with the correct string, if
// we typed /foo<esc> after the original search. Since searchString is // we typed /foo<esc> after the original search. Since searchString is
@@ -173,18 +176,18 @@ vimperator.Search = function () //{{{
if (vimperator.options["hlsearch"]) if (vimperator.options["hlsearch"])
this.highlight(last_search_string); this.highlight(last_search_string);
} }
} },
// Called when the user types a key in the search dialog. Triggers a find attempt if 'incsearch' is set // Called when the user types a key in the search dialog. Triggers a find attempt if 'incsearch' is set
this.searchKeyPressed = function (command) searchKeyPressed: function (command)
{ {
if (vimperator.options["incsearch"]) if (vimperator.options["incsearch"])
this.find(command, backwards); this.find(command, backwards);
} },
// Called when the enter key is pressed to trigger a search // Called when the enter key is pressed to trigger a search
// use forced_direction if you call this function directly // use forced_direction if you call this function directly
this.searchSubmitted = function (command, forced_backward) searchSubmitted: function (command, forced_backward)
{ {
if (typeof forced_backward === "boolean") if (typeof forced_backward === "boolean")
backwards = forced_backward; backwards = forced_backward;
@@ -209,18 +212,18 @@ vimperator.Search = function () //{{{
this.highlight(search_string); this.highlight(search_string);
vimperator.modes.reset(); vimperator.modes.reset();
} },
// Called when the search is canceled - for example if someone presses // Called when the search is canceled - for example if someone presses
// escape while typing a search // escape while typing a search
this.searchCanceled = function () searchCanceled: function ()
{ {
this.clear(); this.clear();
// TODO: code to reposition the document to the place before search started // TODO: code to reposition the document to the place before search started
} },
// this is not dependent on the value of 'hlsearch' // this is not dependent on the value of 'hlsearch'
this.highlight = function (text) highlight: function (text)
{ {
// already highlighted? // already highlighted?
if (window.content.document.getElementsByClassName("__mozilla-findbar-search").length > 0) if (window.content.document.getElementsByClassName("__mozilla-findbar-search").length > 0)
@@ -246,9 +249,9 @@ vimperator.Search = function () //{{{
getBrowser().fastFind.findAgain(false, links_only); getBrowser().fastFind.findAgain(false, links_only);
// TODO: remove highlighting from non-link matches (HTML - A/AREA with href attribute; XML - Xlink [type="simple"]) // TODO: remove highlighting from non-link matches (HTML - A/AREA with href attribute; XML - Xlink [type="simple"])
} },
this.clear = function () clear: function ()
{ {
gFindBar._highlightDoc(); gFindBar._highlightDoc();
// need to manually collapse the selection if the document is not // need to manually collapse the selection if the document is not
@@ -256,6 +259,7 @@ vimperator.Search = function () //{{{
getBrowser().fastFind.collapseSelection(); getBrowser().fastFind.collapseSelection();
} }
};
} //}}} } //}}}
// vim: set fdm=marker sw=4 ts=4 et: // vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -234,7 +234,7 @@ vimperator.IO = function ()
ocstream.close(); ocstream.close();
ofstream.close(); ofstream.close();
} }
} };
} }
// vim: set fdm=marker sw=4 ts=4 et: // vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -92,9 +92,11 @@ vimperator.modes = (function ()
{ {
// clear any selection made // clear any selection made
var selection = window.content.getSelection(); var selection = window.content.getSelection();
try { // a simple if (selection) does not work try
{ // a simple if (selection) does not work
selection.collapseToStart(); selection.collapseToStart();
} catch (e) { } }
catch (e) { }
} }
else else
vimperator.editor.unselectText(); vimperator.editor.unselectText();
@@ -122,6 +124,7 @@ vimperator.modes = (function ()
} }
return { return {
// main modes, only one should ever be active // main modes, only one should ever be active
NONE: 0, NONE: 0,
NORMAL: 1 << 0, NORMAL: 1 << 0,
@@ -219,7 +222,8 @@ vimperator.modes = (function ()
set extended(value) { set extended(value) {
extended = value; this.show(); extended = value; this.show();
} }
}
};
})(); })();
// vim: set fdm=marker sw=4 ts=4 et: // vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -236,27 +236,29 @@ vimperator.CommandLine = function () //{{{
////////////////////// PUBLIC SECTION ////////////////////////////////////////// ////////////////////// PUBLIC SECTION //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{
this.HL_NORMAL = "hl-Normal"; return {
this.HL_ERRORMSG = "hl-ErrorMsg";
this.HL_MODEMSG = "hl-ModeMsg"; HL_NORMAL : "hl-Normal",
this.HL_MOREMSG = "hl-MoreMsg"; HL_ERRORMSG: "hl-ErrorMsg",
this.HL_QUESTION = "hl-Question"; HL_MODEMSG : "hl-ModeMsg",
this.HL_WARNING = "hl-Warning"; HL_MOREMSG : "hl-MoreMsg",
HL_QUESTION: "hl-Question",
HL_WARNING : "hl-Warning",
// not yet used // not yet used
this.FORCE_MULTILINE = 1 << 0; FORCE_MULTILINE : 1 << 0,
this.FORCE_SINGLELINE = 1 << 1; FORCE_SINGLELINE : 1 << 1,
this.DISALLOW_MULTILINE = 1 << 2; // if an echo() should try to use the single line, DISALLOW_MULTILINE : 1 << 2, // if an echo() should try to use the single line,
// but output nothing when the MOW is open; when also // but output nothing when the MOW is open; when also
// FORCE_MULTILINE is given, FORCE_MULTILINE takes precedence // FORCE_MULTILINE is given, FORCE_MULTILINE takes precedence
this.APPEND_TO_MESSAGES = 1 << 3; // will show the string in :messages APPEND_TO_MESSAGES : 1 << 3, // will show the string in :messages
this.getCommand = function () getCommand: function ()
{ {
return command_widget.value; return command_widget.value;
}; },
this.open = function (prompt, cmd, ext_mode) open: function (prompt, cmd, ext_mode)
{ {
// save the current prompts, we need it later if the command widget // save the current prompts, we need it later if the command widget
// receives focus without calling the this.open() method // receives focus without calling the this.open() method
@@ -276,29 +278,29 @@ vimperator.CommandLine = function () //{{{
setCommand(cur_command); setCommand(cur_command);
command_widget.focus(); command_widget.focus();
}; },
// normally used when pressing esc, does not execute a command // normally used when pressing esc, does not execute a command
this.close = function () close: function ()
{ {
var res = vimperator.triggerCallback("cancel", cur_extended_mode); var res = vimperator.triggerCallback("cancel", cur_extended_mode);
history.add(this.getCommand()); history.add(this.getCommand());
vimperator.statusline.updateProgress(""); // we may have a "match x of y" visible vimperator.statusline.updateProgress(""); // we may have a "match x of y" visible
this.clear(); this.clear();
} },
this.clear = function () clear: function ()
{ {
multiline_input_widget.collapsed = true; multiline_input_widget.collapsed = true;
multiline_output_widget.collapsed = true; multiline_output_widget.collapsed = true;
completionlist.hide(); completionlist.hide();
setLine("", this.HL_NORMAL); setLine("", this.HL_NORMAL);
}; },
// TODO: add :messages entry // TODO: add :messages entry
// vimperator.echo uses different order of flags as it omits the hightlight group, change v.commandline.echo argument order? --mst // vimperator.echo uses different order of flags as it omits the hightlight group, change v.commandline.echo argument order? --mst
this.echo = function (str, highlight_group, flags) echo: function (str, highlight_group, flags)
{ {
var focused = document.commandDispatcher.focusedElement; var focused = document.commandDispatcher.focusedElement;
if (focused && focused == command_widget.inputField || focused == multiline_input_widget.inputField) if (focused && focused == command_widget.inputField || focused == multiline_input_widget.inputField)
@@ -327,22 +329,22 @@ vimperator.CommandLine = function () //{{{
cur_extended_mode = null; cur_extended_mode = null;
return true; return true;
}; },
// this will prompt the user for a string // this will prompt the user for a string
// vimperator.commandline.input("(s)ave or (o)pen the file?") // vimperator.commandline.input("(s)ave or (o)pen the file?")
this.input = function (str) input: function (str)
{ {
// TODO: unfinished, need to find out how/if we can block the execution of code // TODO: unfinished, need to find out how/if we can block the execution of code
// to make this code synchronous or at least use a callback // to make this code synchronous or at least use a callback
setLine(str, this.HL_QUESTION); setLine(str, this.HL_QUESTION);
command_widget.focus(); command_widget.focus();
return "not implemented"; return "not implemented";
}; },
// reads a multi line input and returns the string once the last line matches // reads a multi line input and returns the string once the last line matches
// @param until_regexp // @param until_regexp
this.inputMultiline = function (until_regexp, callback_func) inputMultiline: function (until_regexp, callback_func)
{ {
// save the mode, because we need to restore it // save the mode, because we need to restore it
old_mode = vimperator.mode; old_mode = vimperator.mode;
@@ -360,9 +362,9 @@ vimperator.CommandLine = function () //{{{
setTimeout(function () { setTimeout(function () {
multiline_input_widget.focus(); multiline_input_widget.focus();
}, 10); }, 10);
}; },
this.onEvent = function (event) onEvent: function (event)
{ {
var command = this.getCommand(); var command = this.getCommand();
@@ -596,9 +598,9 @@ vimperator.CommandLine = function () //{{{
completion_index = history_index = UNINITIALIZED; completion_index = history_index = UNINITIALIZED;
} }
} }
} },
this.onMultilineInputEvent = function (event) onMultilineInputEvent: function (event)
{ {
if (event.type == "keypress") if (event.type == "keypress")
{ {
@@ -629,11 +631,11 @@ vimperator.CommandLine = function () //{{{
{ {
autosizeMultilineInputWidget(); autosizeMultilineInputWidget();
} }
} },
// FIXME: if 'more' is set and the MOW is not scrollable we should still // FIXME: if 'more' is set and the MOW is not scrollable we should still
// allow a down motion after an up rather than closing // allow a down motion after an up rather than closing
this.onMultilineOutputEvent = function (event) onMultilineOutputEvent: function (event)
{ {
var win = multiline_output_widget.contentWindow; var win = multiline_output_widget.contentWindow;
@@ -826,13 +828,15 @@ vimperator.CommandLine = function () //{{{
else else
setLine("Press ENTER or type command to continue", this.HL_QUESTION); setLine("Press ENTER or type command to continue", this.HL_QUESTION);
} }
} },
// it would be better if we had a destructor in javascript ... // it would be better if we had a destructor in javascript ...
this.destroy = function () destroy: function ()
{ {
history.save(); history.save();
} }
};
//}}} //}}}
} //}}} } //}}}
@@ -935,6 +939,8 @@ vimperator.InformationList = function (id, options) //{{{
////////////////////// PUBLIC SECTION ////////////////////////////////////////// ////////////////////// PUBLIC SECTION //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{
return {
/** /**
* Show the completion list window * Show the completion list window
* *
@@ -942,7 +948,7 @@ vimperator.InformationList = function (id, options) //{{{
* use entries of 'compl' to fill the list. * use entries of 'compl' to fill the list.
* Required format: [["left", "right"], ["another"], ["completion"]] * Required format: [["left", "right"], ["another"], ["completion"]]
*/ */
this.show = function (compl) show: function (compl)
{ {
//max_items = vimperator.options["previewheight"]; //max_items = vimperator.options["previewheight"];
@@ -966,22 +972,22 @@ vimperator.InformationList = function (id, options) //{{{
widget.hidden = true; widget.hidden = true;
return false; return false;
} }
} },
this.hide = function () hide: function ()
{ {
widget.hidden = true; widget.hidden = true;
} },
this.visible = function () visible: function ()
{ {
return !widget.hidden; return !widget.hidden;
} },
/** /**
* select index, refill list if necessary * select index, refill list if necessary
*/ */
this.selectItem = function (index) selectItem: function (index)
{ {
if (widget.hidden) if (widget.hidden)
return; return;
@@ -1027,9 +1033,9 @@ vimperator.InformationList = function (id, options) //{{{
list_offset = new_offset; list_offset = new_offset;
widget.selectedIndex = index - list_offset; widget.selectedIndex = index - list_offset;
} },
this.onEvent = function (event) onEvent: function (event)
{ {
var listcells = document.getElementsByTagName("listcell"); var listcells = document.getElementsByTagName("listcell");
// 2 columns for now, use the first column // 2 columns for now, use the first column
@@ -1042,6 +1048,8 @@ vimperator.InformationList = function (id, options) //{{{
else else
return false; return false;
} }
};
//}}} //}}}
} //}}} } //}}}
@@ -1065,7 +1073,9 @@ vimperator.StatusLine = function () //{{{
////////////////////// PUBLIC SECTION ////////////////////////////////////////// ////////////////////// PUBLIC SECTION //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{
this.setClass = function (type) return {
setClass: function (type)
{ {
var highlight_group; var highlight_group;
@@ -1083,20 +1093,20 @@ vimperator.StatusLine = function () //{{{
} }
status_bar.setAttribute("class", "chromeclass-status " + highlight_group); status_bar.setAttribute("class", "chromeclass-status " + highlight_group);
}; },
// update all fields of the statusline // update all fields of the statusline
this.update = function () update: function ()
{ {
this.updateUrl(); this.updateUrl();
this.updateInputBuffer(); this.updateInputBuffer();
this.updateProgress(); this.updateProgress();
this.updateTabCount(); this.updateTabCount();
this.updateBufferPosition(); this.updateBufferPosition();
} },
// if "url" is ommited, build a usable string for the URL // if "url" is ommited, build a usable string for the URL
this.updateUrl = function (url) updateUrl: function (url)
{ {
if (typeof url == "string") if (typeof url == "string")
{ {
@@ -1128,17 +1138,17 @@ vimperator.StatusLine = function () //{{{
url += " [" + modified + "]" url += " [" + modified + "]"
url_widget.value = url; url_widget.value = url;
}; },
this.updateInputBuffer = function (buffer) updateInputBuffer: function (buffer)
{ {
if (!buffer || typeof buffer != "string") if (!buffer || typeof buffer != "string")
buffer = ""; buffer = "";
inputbuffer_widget.value = buffer; inputbuffer_widget.value = buffer;
}; },
this.updateProgress = function (progress) updateProgress: function (progress)
{ {
if (!progress) if (!progress)
progress = ""; progress = "";
@@ -1166,10 +1176,10 @@ vimperator.StatusLine = function () //{{{
} }
progress_widget.value = progress_str; progress_widget.value = progress_str;
} }
}; },
// you can omit either of the 2 arguments // you can omit either of the 2 arguments
this.updateTabCount = function (cur_index, total_tabs) updateTabCount: function (cur_index, total_tabs)
{ {
if (!cur_index || typeof cur_index != "number") if (!cur_index || typeof cur_index != "number")
cur_index = vimperator.tabs.index() + 1; cur_index = vimperator.tabs.index() + 1;
@@ -1177,10 +1187,10 @@ vimperator.StatusLine = function () //{{{
total_tabs = vimperator.tabs.count(); total_tabs = vimperator.tabs.count();
tabcount_widget.value = "[" + cur_index + "/" + total_tabs + "]"; tabcount_widget.value = "[" + cur_index + "/" + total_tabs + "]";
}; },
// percent is given between 0 and 1 // percent is given between 0 and 1
this.updateBufferPosition = function (percent) updateBufferPosition: function (percent)
{ {
if (!percent || typeof percent != "number") if (!percent || typeof percent != "number")
{ {
@@ -1197,6 +1207,8 @@ vimperator.StatusLine = function () //{{{
else bufferposition_str = percent + "%"; else bufferposition_str = percent + "%";
bufferposition_widget.value = bufferposition_str; bufferposition_widget.value = bufferposition_str;
}
}; };
//}}} //}}}
} //}}} } //}}}

View File

@@ -584,37 +584,37 @@ const vimperator = (function () //{{{
vimperator.log("Loading module commands...", 3); vimperator.log("Loading module commands...", 3);
vimperator.commands = new vimperator.Commands(); vimperator.commands = new vimperator.Commands();
vimperator.log("Loading module bookmarks...", 3); vimperator.log("Loading module bookmarks...", 3);
vimperator.bookmarks = new vimperator.Bookmarks(); vimperator.bookmarks = vimperator.Bookmarks();
vimperator.log("Loading module history...", 3); vimperator.log("Loading module history...", 3);
vimperator.history = new vimperator.History(); vimperator.history = vimperator.History();
vimperator.log("Loading module commandline...", 3); vimperator.log("Loading module commandline...", 3);
vimperator.commandline = new vimperator.CommandLine(); vimperator.commandline = vimperator.CommandLine();
vimperator.log("Loading module search...", 3); vimperator.log("Loading module search...", 3);
vimperator.search = new vimperator.Search(); vimperator.search = vimperator.Search();
vimperator.log("Loading module preview window...", 3); vimperator.log("Loading module preview window...", 3);
vimperator.previewwindow = new vimperator.InformationList("vimperator-previewwindow", { incremental_fill: false, max_items: 10 }); vimperator.previewwindow = vimperator.InformationList("vimperator-previewwindow", { incremental_fill: false, max_items: 10 });
vimperator.log("Loading module buffer window...", 3); vimperator.log("Loading module buffer window...", 3);
vimperator.bufferwindow = new vimperator.InformationList("vimperator-bufferwindow", { incremental_fill: false, max_items: 10 }); vimperator.bufferwindow = vimperator.InformationList("vimperator-bufferwindow", { incremental_fill: false, max_items: 10 });
vimperator.log("Loading module mappings...", 3); vimperator.log("Loading module mappings...", 3);
vimperator.mappings = new vimperator.Mappings(); vimperator.mappings = new vimperator.Mappings();
vimperator.log("Loading module statusline...", 3); vimperator.log("Loading module statusline...", 3);
vimperator.statusline = new vimperator.StatusLine(); vimperator.statusline = vimperator.StatusLine();
vimperator.log("Loading module buffer...", 3); vimperator.log("Loading module buffer...", 3);
vimperator.buffer = new vimperator.Buffer(); vimperator.buffer = vimperator.Buffer();
vimperator.log("Loading module editor...", 3); vimperator.log("Loading module editor...", 3);
vimperator.editor = new vimperator.Editor(); vimperator.editor = vimperator.Editor();
vimperator.log("Loading module tabs...", 3); vimperator.log("Loading module tabs...", 3);
vimperator.tabs = new vimperator.Tabs(); vimperator.tabs = new vimperator.Tabs();
vimperator.log("Loading module marks...", 3); vimperator.log("Loading module marks...", 3);
vimperator.marks = new vimperator.Marks(); vimperator.marks = vimperator.Marks();
vimperator.log("Loading module quickmarks...", 3); vimperator.log("Loading module quickmarks...", 3);
vimperator.quickmarks = new vimperator.QuickMarks(); vimperator.quickmarks = vimperator.QuickMarks();
vimperator.log("Loading module hints...", 3); vimperator.log("Loading module hints...", 3);
vimperator.hints = new vimperator.Hints(); vimperator.hints = new vimperator.Hints();
vimperator.log("Loading module io...", 3); vimperator.log("Loading module io...", 3);
vimperator.io = new vimperator.IO(); vimperator.io = vimperator.IO();
vimperator.log("Loading module completion...", 3); vimperator.log("Loading module completion...", 3);
vimperator.completion = new vimperator.Completion(); vimperator.completion = vimperator.Completion();
vimperator.log("All modules loaded", 3); vimperator.log("All modules loaded", 3);
vimperator.echo = function (str, flags) { vimperator.commandline.echo(str, vimperator.commandline.HL_NORMAL, flags); }; vimperator.echo = function (str, flags) { vimperator.commandline.echo(str, vimperator.commandline.HL_NORMAL, flags); };