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:
@@ -32,6 +32,7 @@ vimperator.Bookmarks = function () //{{{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
|
||||
const history_service = Components.classes["@mozilla.org/browser/nav-history-service;1"]
|
||||
.getService(Components.interfaces.nsINavHistoryService);
|
||||
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!
|
||||
rootNode.containerOpen = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////}}}
|
||||
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
|
||||
return {
|
||||
|
||||
// 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
|
||||
// takes about 1 sec
|
||||
this.get = function (filter, tags, bypass_cache)
|
||||
get: function (filter, tags, bypass_cache)
|
||||
{
|
||||
if (!bookmarks || bypass_cache)
|
||||
load();
|
||||
|
||||
return vimperator.completion.filterURLArray(bookmarks, filter, tags);
|
||||
}
|
||||
},
|
||||
|
||||
this.add = function (title, url, keyword, tags)
|
||||
add: function (title, url, keyword, tags)
|
||||
{
|
||||
if (!bookmarks)
|
||||
load();
|
||||
@@ -144,10 +146,10 @@ vimperator.Bookmarks = function () //{{{
|
||||
//also update bookmark cache
|
||||
bookmarks.unshift([url, title, keyword, tags || []]);
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
// returns number of deleted bookmarks
|
||||
this.remove = function (url)
|
||||
remove: function (url)
|
||||
{
|
||||
if (!url)
|
||||
return 0;
|
||||
@@ -174,11 +176,11 @@ vimperator.Bookmarks = function () //{{{
|
||||
load();
|
||||
|
||||
return count.value;
|
||||
}
|
||||
},
|
||||
|
||||
// TODO: add filtering
|
||||
// also ensures that each search engine has a Vimperator-friendly alias
|
||||
this.getSearchEngines = function ()
|
||||
getSearchEngines: function ()
|
||||
{
|
||||
var search_engines = [];
|
||||
var firefox_engines = search_service.getVisibleEngines({ });
|
||||
@@ -207,23 +209,23 @@ vimperator.Bookmarks = function () //{{{
|
||||
}
|
||||
|
||||
return search_engines;
|
||||
}
|
||||
},
|
||||
|
||||
// TODO: add filtering
|
||||
// format of returned array:
|
||||
// [keyword, helptext, url]
|
||||
this.getKeywords = function ()
|
||||
getKeywords: function ()
|
||||
{
|
||||
if (!keywords)
|
||||
load();
|
||||
|
||||
return keywords;
|
||||
}
|
||||
},
|
||||
|
||||
// if @param engine_name is null, it uses the default search engine
|
||||
// @returns the url for the search string
|
||||
// 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 postdata = null;
|
||||
@@ -269,9 +271,9 @@ vimperator.Bookmarks = function () //{{{
|
||||
return [url, postdata];
|
||||
else
|
||||
return url; // can be null
|
||||
}
|
||||
},
|
||||
|
||||
this.list = function (filter, tags, fullmode)
|
||||
list: function (filter, tags, fullmode)
|
||||
{
|
||||
if (fullmode)
|
||||
{
|
||||
@@ -325,6 +327,8 @@ vimperator.Bookmarks = function () //{{{
|
||||
vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
//}}}
|
||||
} //}}}
|
||||
|
||||
@@ -333,6 +337,7 @@ vimperator.History = function () //{{{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
|
||||
const history_service = Components.classes["@mozilla.org/browser/nav-history-service;1"]
|
||||
.getService(Components.interfaces.nsINavHistoryService);
|
||||
|
||||
@@ -374,17 +379,19 @@ vimperator.History = function () //{{{
|
||||
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
|
||||
this.get = function (filter)
|
||||
return {
|
||||
|
||||
get: function (filter)
|
||||
{
|
||||
if (!history)
|
||||
load();
|
||||
|
||||
return vimperator.completion.filterURLArray(history, filter);
|
||||
}
|
||||
},
|
||||
|
||||
// the history is automatically added to the Places global history
|
||||
// so just update our cached history here
|
||||
this.add = function (url, title)
|
||||
add: function (url, title)
|
||||
{
|
||||
if (!history)
|
||||
load();
|
||||
@@ -395,11 +402,11 @@ vimperator.History = function () //{{{
|
||||
|
||||
history.unshift([url, title]);
|
||||
return true;
|
||||
};
|
||||
},
|
||||
|
||||
// TODO: better names?
|
||||
// and move to vimperator.buffer.?
|
||||
this.stepTo = function (steps)
|
||||
stepTo: function (steps)
|
||||
{
|
||||
var index = getWebNavigation().sessionHistory.index + steps;
|
||||
|
||||
@@ -411,9 +418,9 @@ vimperator.History = function () //{{{
|
||||
{
|
||||
vimperator.beep();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
this.goToStart = function ()
|
||||
goToStart: function ()
|
||||
{
|
||||
var index = getWebNavigation().sessionHistory.index;
|
||||
|
||||
@@ -424,9 +431,9 @@ vimperator.History = function () //{{{
|
||||
}
|
||||
|
||||
getWebNavigation().gotoIndex(0);
|
||||
}
|
||||
},
|
||||
|
||||
this.goToEnd = function ()
|
||||
goToEnd: function ()
|
||||
{
|
||||
var index = getWebNavigation().sessionHistory.index;
|
||||
var max = getWebNavigation().sessionHistory.count - 1;
|
||||
@@ -438,9 +445,9 @@ vimperator.History = function () //{{{
|
||||
}
|
||||
|
||||
getWebNavigation().gotoIndex(max);
|
||||
}
|
||||
},
|
||||
|
||||
this.list = function (filter, fullmode)
|
||||
list: function (filter, fullmode)
|
||||
{
|
||||
if (fullmode)
|
||||
{
|
||||
@@ -474,6 +481,8 @@ vimperator.History = function () //{{{
|
||||
vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
//}}}
|
||||
} //}}}
|
||||
|
||||
@@ -582,8 +591,10 @@ vimperator.Marks = function () //{{{
|
||||
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
|
||||
return {
|
||||
|
||||
// TODO: add support for frameset pages
|
||||
this.add = function (mark)
|
||||
add: function (mark)
|
||||
{
|
||||
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);
|
||||
local_marks[mark].push({ location: win.location.href, position: position });
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
this.remove = function (filter, special)
|
||||
remove: function (filter, special)
|
||||
{
|
||||
if (special)
|
||||
{
|
||||
@@ -635,9 +646,9 @@ vimperator.Marks = function () //{{{
|
||||
removeLocalMark(mark);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
this.jumpTo = function (mark)
|
||||
jumpTo: function (mark)
|
||||
{
|
||||
var ok = false;
|
||||
|
||||
@@ -689,9 +700,9 @@ vimperator.Marks = function () //{{{
|
||||
|
||||
if (!ok)
|
||||
vimperator.echoerr("E20: Mark not set"); // FIXME: move up?
|
||||
}
|
||||
},
|
||||
|
||||
this.list = function (filter)
|
||||
list: function (filter)
|
||||
{
|
||||
var marks = getSortedMarks();
|
||||
|
||||
@@ -729,6 +740,8 @@ vimperator.Marks = function () //{{{
|
||||
|
||||
vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE);
|
||||
}
|
||||
|
||||
};
|
||||
//}}}
|
||||
} //}}}
|
||||
|
||||
@@ -751,12 +764,14 @@ vimperator.QuickMarks = function () //{{{
|
||||
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
|
||||
this.add = function (qmark, location)
|
||||
return {
|
||||
|
||||
add: function (qmark, location)
|
||||
{
|
||||
qmarks[qmark] = location;
|
||||
}
|
||||
},
|
||||
|
||||
this.remove = function (filter)
|
||||
remove: function (filter)
|
||||
{
|
||||
var pattern = new RegExp("[" + filter.replace(/\s+/g, "") + "]");
|
||||
|
||||
@@ -765,14 +780,14 @@ vimperator.QuickMarks = function () //{{{
|
||||
if (pattern.test(qmark))
|
||||
delete qmarks[qmark];
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
this.removeAll = function ()
|
||||
removeAll: function ()
|
||||
{
|
||||
qmarks = {};
|
||||
}
|
||||
},
|
||||
|
||||
this.jumpTo = function (qmark, where)
|
||||
jumpTo: function (qmark, where)
|
||||
{
|
||||
var url = qmarks[qmark];
|
||||
|
||||
@@ -780,9 +795,9 @@ vimperator.QuickMarks = function () //{{{
|
||||
vimperator.open(url, where);
|
||||
else
|
||||
vimperator.echoerr("E20: QuickMark not set");
|
||||
}
|
||||
},
|
||||
|
||||
this.list = function (filter)
|
||||
list: function (filter)
|
||||
{
|
||||
var marks = [];
|
||||
|
||||
@@ -820,9 +835,9 @@ vimperator.QuickMarks = function () //{{{
|
||||
list += "</table>";
|
||||
|
||||
vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE);
|
||||
}
|
||||
},
|
||||
|
||||
this.destroy = function ()
|
||||
destroy: function ()
|
||||
{
|
||||
// save the quickmarks
|
||||
var saved_qmarks = "";
|
||||
@@ -835,6 +850,7 @@ vimperator.QuickMarks = function () //{{{
|
||||
|
||||
vimperator.options.setPref("quickmarks", saved_qmarks);
|
||||
}
|
||||
};
|
||||
//}}}
|
||||
} //}}}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ vimperator.Buffer = function () //{{{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
|
||||
// used for the "B" mapping to remember the last :buffer[!] command
|
||||
var lastBufferSwitchArgs = "";
|
||||
var lastBufferSwitchSpecial = true;
|
||||
@@ -126,46 +127,49 @@ vimperator.Buffer = function () //{{{
|
||||
/////////////////////////////////////////////////////////////////////////////}}}
|
||||
////////////////////// 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
|
||||
//return window.content.document.URL;
|
||||
return window.content.document.location.href;
|
||||
});
|
||||
},
|
||||
|
||||
this.__defineGetter__("pageHeight", function ()
|
||||
get pageHeight()
|
||||
{
|
||||
return window.content.innerHeight;
|
||||
});
|
||||
},
|
||||
|
||||
this.__defineGetter__("textZoom", function ()
|
||||
get textZoom()
|
||||
{
|
||||
return getBrowser().mCurrentBrowser.markupDocumentViewer.textZoom * 100;
|
||||
});
|
||||
this.__defineSetter__("textZoom", function (value)
|
||||
},
|
||||
set textZoom(value)
|
||||
{
|
||||
setZoom(value, false);
|
||||
});
|
||||
},
|
||||
|
||||
this.__defineGetter__("fullZoom", function ()
|
||||
get fullZoom()
|
||||
{
|
||||
return getBrowser().mCurrentBrowser.markupDocumentViewer.fullZoom * 100;
|
||||
});
|
||||
this.__defineSetter__("fullZoom", function (value)
|
||||
},
|
||||
set fullZoom(value)
|
||||
{
|
||||
setZoom(value, true);
|
||||
});
|
||||
},
|
||||
|
||||
this.__defineGetter__("title", function ()
|
||||
get title()
|
||||
{
|
||||
return window.content.document.title;
|
||||
});
|
||||
},
|
||||
|
||||
// returns an XPathResult object
|
||||
this.evaluateXPath = function (expression, doc, elem, asIterator)
|
||||
evaluateXPath: function (expression, doc, elem, asIterator)
|
||||
{
|
||||
if (!doc)
|
||||
doc = window.content.document;
|
||||
@@ -186,12 +190,12 @@ vimperator.Buffer = function () //{{{
|
||||
);
|
||||
|
||||
return result;
|
||||
}
|
||||
},
|
||||
|
||||
// in contrast to vim, returns the selection if one is made,
|
||||
// otherwise tries to guess the current word unter the text cursor
|
||||
// NOTE: might change the selection
|
||||
this.getCurrentWord = function ()
|
||||
getCurrentWord: function ()
|
||||
{
|
||||
var selection = window.content.getSelection().toString();
|
||||
|
||||
@@ -209,9 +213,9 @@ vimperator.Buffer = function () //{{{
|
||||
}
|
||||
|
||||
return selection;
|
||||
}
|
||||
},
|
||||
|
||||
this.list = function (fullmode)
|
||||
list: function (fullmode)
|
||||
{
|
||||
if (fullmode)
|
||||
{
|
||||
@@ -256,14 +260,14 @@ vimperator.Buffer = function () //{{{
|
||||
|
||||
vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
this.scrollBottom = function ()
|
||||
scrollBottom: function ()
|
||||
{
|
||||
scrollToPercentiles(-1, 100);
|
||||
}
|
||||
},
|
||||
|
||||
this.scrollColumns = function (cols)
|
||||
scrollColumns: function (cols)
|
||||
{
|
||||
var win = window.document.commandDispatcher.focusedWindow;
|
||||
const COL_WIDTH = 20;
|
||||
@@ -272,44 +276,44 @@ vimperator.Buffer = function () //{{{
|
||||
vimperator.beep();
|
||||
|
||||
win.scrollBy(COL_WIDTH * cols, 0);
|
||||
}
|
||||
},
|
||||
|
||||
this.scrollEnd = function ()
|
||||
scrollEnd: function ()
|
||||
{
|
||||
scrollToPercentiles(100, -1);
|
||||
}
|
||||
},
|
||||
|
||||
this.scrollLines = function (lines)
|
||||
scrollLines: function (lines)
|
||||
{
|
||||
var win = window.document.commandDispatcher.focusedWindow;
|
||||
checkScrollYBounds(win, lines);
|
||||
win.scrollByLines(lines);
|
||||
}
|
||||
},
|
||||
|
||||
this.scrollPages = function (pages)
|
||||
scrollPages: function (pages)
|
||||
{
|
||||
var win = window.document.commandDispatcher.focusedWindow;
|
||||
checkScrollYBounds(win, pages);
|
||||
win.scrollByPages(pages);
|
||||
}
|
||||
},
|
||||
|
||||
this.scrollToPercentile = function (percentage)
|
||||
scrollToPercentile: function (percentage)
|
||||
{
|
||||
scrollToPercentiles(-1, percentage);
|
||||
}
|
||||
},
|
||||
|
||||
this.scrollStart = function ()
|
||||
scrollStart: function ()
|
||||
{
|
||||
scrollToPercentiles(0, -1);
|
||||
}
|
||||
},
|
||||
|
||||
this.scrollTop = function ()
|
||||
scrollTop: function ()
|
||||
{
|
||||
scrollToPercentiles(-1, 0);
|
||||
}
|
||||
},
|
||||
|
||||
// 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)
|
||||
return;
|
||||
@@ -405,10 +409,10 @@ vimperator.Buffer = function () //{{{
|
||||
|
||||
// remove the frame indicator
|
||||
setTimeout(function () { doc.body.removeChild(indicator); }, 500);
|
||||
}
|
||||
},
|
||||
|
||||
// updates the buffer preview in place only if list is visible
|
||||
this.updateBufferList = function ()
|
||||
updateBufferList: function ()
|
||||
{
|
||||
if (!vimperator.bufferwindow.visible())
|
||||
return false;
|
||||
@@ -416,12 +420,12 @@ vimperator.Buffer = function () //{{{
|
||||
var items = vimperator.completion.get_buffer_completions("");
|
||||
vimperator.bufferwindow.show(items);
|
||||
vimperator.bufferwindow.selectItem(getBrowser().mTabContainer.selectedIndex);
|
||||
}
|
||||
},
|
||||
|
||||
// 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
|
||||
// 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)
|
||||
{
|
||||
@@ -476,19 +480,19 @@ vimperator.Buffer = function () //{{{
|
||||
|
||||
vimperator.tabs.select(matches[index], false);
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
this.zoomIn = function (steps, full_zoom)
|
||||
zoomIn: function (steps, full_zoom)
|
||||
{
|
||||
bumpZoomLevel(steps, full_zoom);
|
||||
};
|
||||
},
|
||||
|
||||
this.zoomOut = function (steps, full_zoom)
|
||||
zoomOut: function (steps, full_zoom)
|
||||
{
|
||||
bumpZoomLevel(-steps, full_zoom);
|
||||
};
|
||||
},
|
||||
|
||||
this.pageInfo = function (verbose)
|
||||
pageInfo: function (verbose)
|
||||
{
|
||||
// TODO: copied from firefox. Needs some review/work...
|
||||
// const feedTypes = {
|
||||
@@ -611,7 +615,7 @@ vimperator.Buffer = function () //{{{
|
||||
var feed = { title: link.title, href: link.href, type: link.type || "" };
|
||||
if (isValidFeed(feed, window.content.document.nodePrincipal, rels.feed))
|
||||
{
|
||||
// var type = feedTypes[feed.type] || feedTypes["application/rss+xml"]; // TODO: dig into that.. --calmar
|
||||
// var type = feedTypes[feed.type] || feedTypes["application/rss+xml"]; // TODO: dig into that.. --calmar
|
||||
var type = feed.type || "application/rss+xml";
|
||||
pageFeeds.push([feed.title, vimperator.util.highlightURL(feed.href, true)]);
|
||||
}
|
||||
@@ -728,6 +732,8 @@ vimperator.Buffer = function () //{{{
|
||||
}
|
||||
vimperator.echo(pageInfoText, vimperator.commandline.FORCE_MULTILINE);
|
||||
}
|
||||
|
||||
};
|
||||
//}}}
|
||||
} //}}}
|
||||
|
||||
|
||||
@@ -610,7 +610,7 @@ vimperator.Completion = function () // {{{
|
||||
return [start, completions];
|
||||
} //}}}
|
||||
|
||||
}
|
||||
};
|
||||
} // }}}
|
||||
|
||||
// vim: set fdm=marker sw=4 ts=4 et:
|
||||
|
||||
@@ -50,7 +50,9 @@ vimperator.Editor = function () //{{{
|
||||
return ed.controllers.getControllerForCommand("cmd_beginLine");
|
||||
}
|
||||
|
||||
this.line = function ()
|
||||
return {
|
||||
|
||||
line: function ()
|
||||
{
|
||||
var line = 1;
|
||||
var text = editor().value;
|
||||
@@ -58,9 +60,9 @@ vimperator.Editor = function () //{{{
|
||||
if (text[i] == "\n")
|
||||
line++;
|
||||
return line;
|
||||
}
|
||||
},
|
||||
|
||||
this.col = function ()
|
||||
col: function ()
|
||||
{
|
||||
var col = 1;
|
||||
var text = editor().value;
|
||||
@@ -71,22 +73,22 @@ vimperator.Editor = function () //{{{
|
||||
col = 1;
|
||||
}
|
||||
return col;
|
||||
}
|
||||
},
|
||||
|
||||
this.unselectText = function ()
|
||||
unselectText: function ()
|
||||
{
|
||||
var elt = window.document.commandDispatcher.focusedElement;
|
||||
if (elt && elt.selectionEnd)
|
||||
elt.selectionEnd = elt.selectionStart;
|
||||
}
|
||||
},
|
||||
|
||||
this.selectedText = function ()
|
||||
selectedText: function ()
|
||||
{
|
||||
var text = editor().value;
|
||||
return text.substring(editor().selectionStart, editor().selectionEnd);
|
||||
}
|
||||
},
|
||||
|
||||
this.pasteClipboard = function ()
|
||||
pasteClipboard: function ()
|
||||
{
|
||||
var elt = window.document.commandDispatcher.focusedElement;
|
||||
|
||||
@@ -103,10 +105,10 @@ vimperator.Editor = function () //{{{
|
||||
elt.selectionStart = rangeStart + tempStr2.length;
|
||||
elt.selectionEnd = elt.selectionStart;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// count is optional, defaults to 1
|
||||
this.executeCommand = function (cmd, count)
|
||||
executeCommand: function (cmd, count)
|
||||
{
|
||||
var controller = getController();
|
||||
if (!controller || !controller.supportsCommand(cmd) || !controller.isCommandEnabled(cmd))
|
||||
@@ -138,11 +140,11 @@ vimperator.Editor = function () //{{{
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
// cmd = y, d, c
|
||||
// motion = b, 0, gg, G, etc.
|
||||
this.executeCommandWithMotion = function (cmd, motion, count)
|
||||
executeCommandWithMotion: function (cmd, motion, count)
|
||||
{
|
||||
if (!typeof count == "number" || count < 1)
|
||||
count = 1;
|
||||
@@ -223,13 +225,13 @@ vimperator.Editor = function () //{{{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
// This function will move/select up to given "pos"
|
||||
// Simple setSelectionRange() would be better, but we want to maintain the correct
|
||||
// order of selectionStart/End (a firefox bug always makes selectionStart <= selectionEnd)
|
||||
// Use only for small movements!
|
||||
this.moveToPosition = function (pos, forward, select)
|
||||
moveToPosition: function (pos, forward, select)
|
||||
{
|
||||
if (!select)
|
||||
{
|
||||
@@ -259,10 +261,10 @@ vimperator.Editor = function () //{{{
|
||||
}
|
||||
while ( editor().selectionStart != pos );
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// returns the position of char
|
||||
this.findCharForward = function (char, count)
|
||||
findCharForward: function (char, count)
|
||||
{
|
||||
if (!editor())
|
||||
return -1;
|
||||
@@ -286,9 +288,10 @@ vimperator.Editor = function () //{{{
|
||||
|
||||
vimperator.beep();
|
||||
return -1;
|
||||
}
|
||||
},
|
||||
|
||||
// returns the position of char
|
||||
this.findCharBackward = function (char, count)
|
||||
findCharBackward: function (char, count)
|
||||
{
|
||||
if (!editor())
|
||||
return -1;
|
||||
@@ -312,9 +315,9 @@ vimperator.Editor = function () //{{{
|
||||
|
||||
vimperator.beep();
|
||||
return -1;
|
||||
}
|
||||
},
|
||||
|
||||
this.editWithExternalEditor = function ()
|
||||
editWithExternalEditor: function ()
|
||||
{
|
||||
var textBox = document.commandDispatcher.focusedElement;
|
||||
var editor = vimperator.options["editor"];
|
||||
@@ -358,12 +361,12 @@ vimperator.Editor = function () //{{{
|
||||
textBox.removeAttribute("readonly");
|
||||
|
||||
|
||||
// if (v:shell_error != 0)
|
||||
// {
|
||||
// tmpBg = "red";
|
||||
// vimperator.echoerr("External editor returned with exit code " + retcode);
|
||||
// }
|
||||
// else
|
||||
// if (v:shell_error != 0)
|
||||
// {
|
||||
// tmpBg = "red";
|
||||
// vimperator.echoerr("External editor returned with exit code " + retcode);
|
||||
// }
|
||||
// else
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -391,12 +394,12 @@ vimperator.Editor = function () //{{{
|
||||
}, timeout);
|
||||
|
||||
tmpfile.remove(false);
|
||||
}
|
||||
},
|
||||
|
||||
// Abbreviations {{{
|
||||
|
||||
this.abbreviations = {};
|
||||
this.abbreviations.__iterator__ = function ()
|
||||
abbreviations: {
|
||||
__iterator__: function ()
|
||||
{
|
||||
var tmpCmd;
|
||||
for (var lhs in abbrev)
|
||||
@@ -408,9 +411,10 @@ vimperator.Editor = function () //{{{
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 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
|
||||
{
|
||||
@@ -457,9 +461,9 @@ vimperator.Editor = function () //{{{
|
||||
list += "</table>";
|
||||
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])
|
||||
{
|
||||
@@ -541,9 +545,9 @@ vimperator.Editor = function () //{{{
|
||||
// 1 not !: opposite mode (first), add/change 'second' and END
|
||||
// 1 not !: same mode (first), overwrite first this END
|
||||
//
|
||||
}
|
||||
},
|
||||
|
||||
this.removeAbbreviation = function (filter, lhs)
|
||||
removeAbbreviation: function (filter, lhs)
|
||||
{
|
||||
if (!lhs)
|
||||
{
|
||||
@@ -587,9 +591,9 @@ vimperator.Editor = function () //{{{
|
||||
|
||||
vimperator.echoerr("E24: No such abbreviation");
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
this.removeAllAbbreviations = function (filter)
|
||||
removeAllAbbreviations: function (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 text = textbox.value;
|
||||
@@ -637,6 +641,8 @@ vimperator.Editor = function () //{{{
|
||||
}
|
||||
return true;
|
||||
} //}}}
|
||||
|
||||
};
|
||||
} //}}}
|
||||
|
||||
// vim: set fdm=marker sw=4 ts=4 et:
|
||||
|
||||
@@ -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
|
||||
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 backwards = false; // currently searching backwards
|
||||
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
|
||||
|
||||
// Event handlers for search - closure is needed
|
||||
vimperator.registerCallback("change", vimperator.modes.SEARCH_FORWARD, function (command) { self.searchKeyPressed(command); });
|
||||
vimperator.registerCallback("submit", vimperator.modes.SEARCH_FORWARD, function (command) { self.searchSubmitted(command); });
|
||||
vimperator.registerCallback("cancel", vimperator.modes.SEARCH_FORWARD, function () { self.searchCanceled(); });
|
||||
vimperator.registerCallback("change", vimperator.modes.SEARCH_FORWARD, function (command) { vimperator.search.searchKeyPressed(command); });
|
||||
vimperator.registerCallback("submit", vimperator.modes.SEARCH_FORWARD, function (command) { vimperator.search.searchSubmitted(command); });
|
||||
vimperator.registerCallback("cancel", vimperator.modes.SEARCH_FORWARD, function () { vimperator.search.searchCanceled(); });
|
||||
// TODO: allow advanced modes in register/triggerCallback
|
||||
vimperator.registerCallback("change", vimperator.modes.SEARCH_BACKWARD, function (command) { self.searchKeyPressed(command); });
|
||||
vimperator.registerCallback("submit", vimperator.modes.SEARCH_BACKWARD, function (command) { self.searchSubmitted(command); });
|
||||
vimperator.registerCallback("cancel", vimperator.modes.SEARCH_BACKWARD, function () { self.searchCanceled(); });
|
||||
vimperator.registerCallback("change", vimperator.modes.SEARCH_BACKWARD, function (command) { vimperator.search.searchKeyPressed(command); });
|
||||
vimperator.registerCallback("submit", vimperator.modes.SEARCH_BACKWARD, function (command) { vimperator.search.searchSubmitted(command); });
|
||||
vimperator.registerCallback("cancel", vimperator.modes.SEARCH_BACKWARD, function () { vimperator.search.searchCanceled(); });
|
||||
|
||||
// set search_string, search_pattern, case_sensitive, links_only
|
||||
function processUserPattern(pattern)
|
||||
@@ -104,9 +105,11 @@ vimperator.Search = function () //{{{
|
||||
search_string = pattern;
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
// Called when the search dialog is asked for
|
||||
// If you omit "mode", it will default to forward searching
|
||||
this.openSearchDialog = function (mode)
|
||||
openSearchDialog: function (mode)
|
||||
{
|
||||
if (mode == vimperator.modes.SEARCH_BACKWARD)
|
||||
{
|
||||
@@ -120,11 +123,11 @@ vimperator.Search = function () //{{{
|
||||
}
|
||||
|
||||
// TODO: focus the top of the currently visible screen
|
||||
}
|
||||
},
|
||||
|
||||
// Finds text in a page
|
||||
// TODO: backwards seems impossible i fear :(
|
||||
this.find = function (str, backwards)
|
||||
find: function (str, backwards)
|
||||
{
|
||||
var fastFind = getBrowser().fastFind;
|
||||
|
||||
@@ -137,10 +140,10 @@ vimperator.Search = function () //{{{
|
||||
vimperator.echoerr("E486: Pattern not found: " + search_pattern);
|
||||
|
||||
return found;
|
||||
}
|
||||
},
|
||||
|
||||
// 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
|
||||
// we typed /foo<esc> after the original search. Since searchString is
|
||||
@@ -173,18 +176,18 @@ vimperator.Search = function () //{{{
|
||||
if (vimperator.options["hlsearch"])
|
||||
this.highlight(last_search_string);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 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"])
|
||||
this.find(command, backwards);
|
||||
}
|
||||
},
|
||||
|
||||
// Called when the enter key is pressed to trigger a search
|
||||
// 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")
|
||||
backwards = forced_backward;
|
||||
@@ -209,18 +212,18 @@ vimperator.Search = function () //{{{
|
||||
this.highlight(search_string);
|
||||
|
||||
vimperator.modes.reset();
|
||||
}
|
||||
},
|
||||
|
||||
// Called when the search is canceled - for example if someone presses
|
||||
// escape while typing a search
|
||||
this.searchCanceled = function ()
|
||||
searchCanceled: function ()
|
||||
{
|
||||
this.clear();
|
||||
// TODO: code to reposition the document to the place before search started
|
||||
}
|
||||
},
|
||||
|
||||
// this is not dependent on the value of 'hlsearch'
|
||||
this.highlight = function (text)
|
||||
highlight: function (text)
|
||||
{
|
||||
// already highlighted?
|
||||
if (window.content.document.getElementsByClassName("__mozilla-findbar-search").length > 0)
|
||||
@@ -246,9 +249,9 @@ vimperator.Search = function () //{{{
|
||||
getBrowser().fastFind.findAgain(false, links_only);
|
||||
|
||||
// TODO: remove highlighting from non-link matches (HTML - A/AREA with href attribute; XML - Xlink [type="simple"])
|
||||
}
|
||||
},
|
||||
|
||||
this.clear = function ()
|
||||
clear: function ()
|
||||
{
|
||||
gFindBar._highlightDoc();
|
||||
// need to manually collapse the selection if the document is not
|
||||
@@ -256,6 +259,7 @@ vimperator.Search = function () //{{{
|
||||
getBrowser().fastFind.collapseSelection();
|
||||
}
|
||||
|
||||
};
|
||||
} //}}}
|
||||
|
||||
// vim: set fdm=marker sw=4 ts=4 et:
|
||||
|
||||
@@ -234,7 +234,7 @@ vimperator.IO = function ()
|
||||
ocstream.close();
|
||||
ofstream.close();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// vim: set fdm=marker sw=4 ts=4 et:
|
||||
|
||||
@@ -92,9 +92,11 @@ vimperator.modes = (function ()
|
||||
{
|
||||
// clear any selection made
|
||||
var selection = window.content.getSelection();
|
||||
try { // a simple if (selection) does not work
|
||||
try
|
||||
{ // a simple if (selection) does not work
|
||||
selection.collapseToStart();
|
||||
} catch (e) { }
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
else
|
||||
vimperator.editor.unselectText();
|
||||
@@ -122,6 +124,7 @@ vimperator.modes = (function ()
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
// main modes, only one should ever be active
|
||||
NONE: 0,
|
||||
NORMAL: 1 << 0,
|
||||
@@ -219,7 +222,8 @@ vimperator.modes = (function ()
|
||||
set extended(value) {
|
||||
extended = value; this.show();
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
})();
|
||||
|
||||
// vim: set fdm=marker sw=4 ts=4 et:
|
||||
|
||||
118
content/ui.js
118
content/ui.js
@@ -236,27 +236,29 @@ vimperator.CommandLine = function () //{{{
|
||||
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
|
||||
this.HL_NORMAL = "hl-Normal";
|
||||
this.HL_ERRORMSG = "hl-ErrorMsg";
|
||||
this.HL_MODEMSG = "hl-ModeMsg";
|
||||
this.HL_MOREMSG = "hl-MoreMsg";
|
||||
this.HL_QUESTION = "hl-Question";
|
||||
this.HL_WARNING = "hl-Warning";
|
||||
return {
|
||||
|
||||
HL_NORMAL : "hl-Normal",
|
||||
HL_ERRORMSG: "hl-ErrorMsg",
|
||||
HL_MODEMSG : "hl-ModeMsg",
|
||||
HL_MOREMSG : "hl-MoreMsg",
|
||||
HL_QUESTION: "hl-Question",
|
||||
HL_WARNING : "hl-Warning",
|
||||
|
||||
// not yet used
|
||||
this.FORCE_MULTILINE = 1 << 0;
|
||||
this.FORCE_SINGLELINE = 1 << 1;
|
||||
this.DISALLOW_MULTILINE = 1 << 2; // if an echo() should try to use the single line,
|
||||
FORCE_MULTILINE : 1 << 0,
|
||||
FORCE_SINGLELINE : 1 << 1,
|
||||
DISALLOW_MULTILINE : 1 << 2, // if an echo() should try to use the single line,
|
||||
// but output nothing when the MOW is open; when also
|
||||
// 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;
|
||||
};
|
||||
},
|
||||
|
||||
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
|
||||
// receives focus without calling the this.open() method
|
||||
@@ -276,29 +278,29 @@ vimperator.CommandLine = function () //{{{
|
||||
setCommand(cur_command);
|
||||
|
||||
command_widget.focus();
|
||||
};
|
||||
},
|
||||
|
||||
// normally used when pressing esc, does not execute a command
|
||||
this.close = function ()
|
||||
close: function ()
|
||||
{
|
||||
var res = vimperator.triggerCallback("cancel", cur_extended_mode);
|
||||
history.add(this.getCommand());
|
||||
vimperator.statusline.updateProgress(""); // we may have a "match x of y" visible
|
||||
this.clear();
|
||||
}
|
||||
},
|
||||
|
||||
this.clear = function ()
|
||||
clear: function ()
|
||||
{
|
||||
multiline_input_widget.collapsed = true;
|
||||
multiline_output_widget.collapsed = true;
|
||||
completionlist.hide();
|
||||
|
||||
setLine("", this.HL_NORMAL);
|
||||
};
|
||||
},
|
||||
|
||||
// TODO: add :messages entry
|
||||
// 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;
|
||||
if (focused && focused == command_widget.inputField || focused == multiline_input_widget.inputField)
|
||||
@@ -327,22 +329,22 @@ vimperator.CommandLine = function () //{{{
|
||||
cur_extended_mode = null;
|
||||
|
||||
return true;
|
||||
};
|
||||
},
|
||||
|
||||
// this will prompt the user for a string
|
||||
// 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
|
||||
// to make this code synchronous or at least use a callback
|
||||
setLine(str, this.HL_QUESTION);
|
||||
command_widget.focus();
|
||||
return "not implemented";
|
||||
};
|
||||
},
|
||||
|
||||
// reads a multi line input and returns the string once the last line matches
|
||||
// @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
|
||||
old_mode = vimperator.mode;
|
||||
@@ -360,9 +362,9 @@ vimperator.CommandLine = function () //{{{
|
||||
setTimeout(function () {
|
||||
multiline_input_widget.focus();
|
||||
}, 10);
|
||||
};
|
||||
},
|
||||
|
||||
this.onEvent = function (event)
|
||||
onEvent: function (event)
|
||||
{
|
||||
var command = this.getCommand();
|
||||
|
||||
@@ -596,9 +598,9 @@ vimperator.CommandLine = function () //{{{
|
||||
completion_index = history_index = UNINITIALIZED;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
this.onMultilineInputEvent = function (event)
|
||||
onMultilineInputEvent: function (event)
|
||||
{
|
||||
if (event.type == "keypress")
|
||||
{
|
||||
@@ -629,11 +631,11 @@ vimperator.CommandLine = function () //{{{
|
||||
{
|
||||
autosizeMultilineInputWidget();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// FIXME: if 'more' is set and the MOW is not scrollable we should still
|
||||
// allow a down motion after an up rather than closing
|
||||
this.onMultilineOutputEvent = function (event)
|
||||
onMultilineOutputEvent: function (event)
|
||||
{
|
||||
var win = multiline_output_widget.contentWindow;
|
||||
|
||||
@@ -826,13 +828,15 @@ vimperator.CommandLine = function () //{{{
|
||||
else
|
||||
setLine("Press ENTER or type command to continue", this.HL_QUESTION);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// it would be better if we had a destructor in javascript ...
|
||||
this.destroy = function ()
|
||||
destroy: function ()
|
||||
{
|
||||
history.save();
|
||||
}
|
||||
|
||||
};
|
||||
//}}}
|
||||
} //}}}
|
||||
|
||||
@@ -935,6 +939,8 @@ vimperator.InformationList = function (id, options) //{{{
|
||||
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
|
||||
return {
|
||||
|
||||
/**
|
||||
* Show the completion list window
|
||||
*
|
||||
@@ -942,7 +948,7 @@ vimperator.InformationList = function (id, options) //{{{
|
||||
* use entries of 'compl' to fill the list.
|
||||
* Required format: [["left", "right"], ["another"], ["completion"]]
|
||||
*/
|
||||
this.show = function (compl)
|
||||
show: function (compl)
|
||||
{
|
||||
//max_items = vimperator.options["previewheight"];
|
||||
|
||||
@@ -966,22 +972,22 @@ vimperator.InformationList = function (id, options) //{{{
|
||||
widget.hidden = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
this.hide = function ()
|
||||
hide: function ()
|
||||
{
|
||||
widget.hidden = true;
|
||||
}
|
||||
},
|
||||
|
||||
this.visible = function ()
|
||||
visible: function ()
|
||||
{
|
||||
return !widget.hidden;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* select index, refill list if necessary
|
||||
*/
|
||||
this.selectItem = function (index)
|
||||
selectItem: function (index)
|
||||
{
|
||||
if (widget.hidden)
|
||||
return;
|
||||
@@ -1027,9 +1033,9 @@ vimperator.InformationList = function (id, options) //{{{
|
||||
|
||||
list_offset = new_offset;
|
||||
widget.selectedIndex = index - list_offset;
|
||||
}
|
||||
},
|
||||
|
||||
this.onEvent = function (event)
|
||||
onEvent: function (event)
|
||||
{
|
||||
var listcells = document.getElementsByTagName("listcell");
|
||||
// 2 columns for now, use the first column
|
||||
@@ -1042,6 +1048,8 @@ vimperator.InformationList = function (id, options) //{{{
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
//}}}
|
||||
} //}}}
|
||||
|
||||
@@ -1065,7 +1073,9 @@ vimperator.StatusLine = function () //{{{
|
||||
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
|
||||
this.setClass = function (type)
|
||||
return {
|
||||
|
||||
setClass: function (type)
|
||||
{
|
||||
var highlight_group;
|
||||
|
||||
@@ -1083,20 +1093,20 @@ vimperator.StatusLine = function () //{{{
|
||||
}
|
||||
|
||||
status_bar.setAttribute("class", "chromeclass-status " + highlight_group);
|
||||
};
|
||||
},
|
||||
|
||||
// update all fields of the statusline
|
||||
this.update = function ()
|
||||
update: function ()
|
||||
{
|
||||
this.updateUrl();
|
||||
this.updateInputBuffer();
|
||||
this.updateProgress();
|
||||
this.updateTabCount();
|
||||
this.updateBufferPosition();
|
||||
}
|
||||
},
|
||||
|
||||
// if "url" is ommited, build a usable string for the URL
|
||||
this.updateUrl = function (url)
|
||||
updateUrl: function (url)
|
||||
{
|
||||
if (typeof url == "string")
|
||||
{
|
||||
@@ -1128,17 +1138,17 @@ vimperator.StatusLine = function () //{{{
|
||||
url += " [" + modified + "]"
|
||||
|
||||
url_widget.value = url;
|
||||
};
|
||||
},
|
||||
|
||||
this.updateInputBuffer = function (buffer)
|
||||
updateInputBuffer: function (buffer)
|
||||
{
|
||||
if (!buffer || typeof buffer != "string")
|
||||
buffer = "";
|
||||
|
||||
inputbuffer_widget.value = buffer;
|
||||
};
|
||||
},
|
||||
|
||||
this.updateProgress = function (progress)
|
||||
updateProgress: function (progress)
|
||||
{
|
||||
if (!progress)
|
||||
progress = "";
|
||||
@@ -1166,10 +1176,10 @@ vimperator.StatusLine = function () //{{{
|
||||
}
|
||||
progress_widget.value = progress_str;
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
// 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")
|
||||
cur_index = vimperator.tabs.index() + 1;
|
||||
@@ -1177,10 +1187,10 @@ vimperator.StatusLine = function () //{{{
|
||||
total_tabs = vimperator.tabs.count();
|
||||
|
||||
tabcount_widget.value = "[" + cur_index + "/" + total_tabs + "]";
|
||||
};
|
||||
},
|
||||
|
||||
// percent is given between 0 and 1
|
||||
this.updateBufferPosition = function (percent)
|
||||
updateBufferPosition: function (percent)
|
||||
{
|
||||
if (!percent || typeof percent != "number")
|
||||
{
|
||||
@@ -1197,6 +1207,8 @@ vimperator.StatusLine = function () //{{{
|
||||
else bufferposition_str = percent + "%";
|
||||
|
||||
bufferposition_widget.value = bufferposition_str;
|
||||
}
|
||||
|
||||
};
|
||||
//}}}
|
||||
} //}}}
|
||||
|
||||
@@ -584,37 +584,37 @@ const vimperator = (function () //{{{
|
||||
vimperator.log("Loading module commands...", 3);
|
||||
vimperator.commands = new vimperator.Commands();
|
||||
vimperator.log("Loading module bookmarks...", 3);
|
||||
vimperator.bookmarks = new vimperator.Bookmarks();
|
||||
vimperator.bookmarks = vimperator.Bookmarks();
|
||||
vimperator.log("Loading module history...", 3);
|
||||
vimperator.history = new vimperator.History();
|
||||
vimperator.history = vimperator.History();
|
||||
vimperator.log("Loading module commandline...", 3);
|
||||
vimperator.commandline = new vimperator.CommandLine();
|
||||
vimperator.commandline = vimperator.CommandLine();
|
||||
vimperator.log("Loading module search...", 3);
|
||||
vimperator.search = new vimperator.Search();
|
||||
vimperator.search = vimperator.Search();
|
||||
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.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.mappings = new vimperator.Mappings();
|
||||
vimperator.log("Loading module statusline...", 3);
|
||||
vimperator.statusline = new vimperator.StatusLine();
|
||||
vimperator.statusline = vimperator.StatusLine();
|
||||
vimperator.log("Loading module buffer...", 3);
|
||||
vimperator.buffer = new vimperator.Buffer();
|
||||
vimperator.buffer = vimperator.Buffer();
|
||||
vimperator.log("Loading module editor...", 3);
|
||||
vimperator.editor = new vimperator.Editor();
|
||||
vimperator.editor = vimperator.Editor();
|
||||
vimperator.log("Loading module tabs...", 3);
|
||||
vimperator.tabs = new vimperator.Tabs();
|
||||
vimperator.log("Loading module marks...", 3);
|
||||
vimperator.marks = new vimperator.Marks();
|
||||
vimperator.marks = vimperator.Marks();
|
||||
vimperator.log("Loading module quickmarks...", 3);
|
||||
vimperator.quickmarks = new vimperator.QuickMarks();
|
||||
vimperator.quickmarks = vimperator.QuickMarks();
|
||||
vimperator.log("Loading module hints...", 3);
|
||||
vimperator.hints = new vimperator.Hints();
|
||||
vimperator.log("Loading module io...", 3);
|
||||
vimperator.io = new vimperator.IO();
|
||||
vimperator.io = vimperator.IO();
|
||||
vimperator.log("Loading module completion...", 3);
|
||||
vimperator.completion = new vimperator.Completion();
|
||||
vimperator.completion = vimperator.Completion();
|
||||
vimperator.log("All modules loaded", 3);
|
||||
|
||||
vimperator.echo = function (str, flags) { vimperator.commandline.echo(str, vimperator.commandline.HL_NORMAL, flags); };
|
||||
|
||||
Reference in New Issue
Block a user