mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-22 21:27:58 +01:00
use camel case for all indentifiers
This commit is contained in:
@@ -33,15 +33,15 @@ vimperator.Bookmarks = function () //{{{
|
|||||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
const history_service = Components.classes["@mozilla.org/browser/nav-history-service;1"]
|
const historyService = 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 bookmarksService = Components.classes["@mozilla.org/browser/nav-bookmarks-service;1"]
|
||||||
.getService(Components.interfaces.nsINavBookmarksService);
|
.getService(Components.interfaces.nsINavBookmarksService);
|
||||||
const tagging_service = Components.classes["@mozilla.org/browser/tagging-service;1"]
|
const taggingService = Components.classes["@mozilla.org/browser/tagging-service;1"]
|
||||||
.getService(Components.interfaces.nsITaggingService);
|
.getService(Components.interfaces.nsITaggingService);
|
||||||
const search_service = Components.classes["@mozilla.org/browser/search-service;1"]
|
const searchService = Components.classes["@mozilla.org/browser/search-service;1"]
|
||||||
.getService(Components.interfaces.nsIBrowserSearchService);
|
.getService(Components.interfaces.nsIBrowserSearchService);
|
||||||
const io_service = Components.classes["@mozilla.org/network/io-service;1"]
|
const ioService = Components.classes["@mozilla.org/network/io-service;1"]
|
||||||
.getService(Components.interfaces.nsIIOService);
|
.getService(Components.interfaces.nsIIOService);
|
||||||
|
|
||||||
var bookmarks = null;
|
var bookmarks = null;
|
||||||
@@ -55,18 +55,18 @@ vimperator.Bookmarks = function () //{{{
|
|||||||
// update our bookmark cache
|
// update our bookmark cache
|
||||||
bookmarks = []; // also clear our bookmark cache
|
bookmarks = []; // also clear our bookmark cache
|
||||||
keywords = [];
|
keywords = [];
|
||||||
var root = bookmarks_service.bookmarksRoot;
|
var root = bookmarksService.bookmarksRoot;
|
||||||
|
|
||||||
var folders = [root];
|
var folders = [root];
|
||||||
var query = history_service.getNewQuery();
|
var query = historyService.getNewQuery();
|
||||||
var options = history_service.getNewQueryOptions();
|
var options = historyService.getNewQueryOptions();
|
||||||
// query.searchTerms = "test";
|
// query.searchTerms = "test";
|
||||||
while (folders.length > 0)
|
while (folders.length > 0)
|
||||||
{
|
{
|
||||||
//comment out the next line for now; the bug hasn't been fixed; final version should include the next line
|
//comment out the next line for now; the bug hasn't been fixed; final version should include the next line
|
||||||
//options.setGroupingMode(options.GROUP_BY_FOLDER);
|
//options.setGroupingMode(options.GROUP_BY_FOLDER);
|
||||||
query.setFolders(folders, 1);
|
query.setFolders(folders, 1);
|
||||||
var result = history_service.executeQuery(query, options);
|
var result = historyService.executeQuery(query, options);
|
||||||
//result.sortingMode = options.SORT_BY_DATE_DESCENDING;
|
//result.sortingMode = options.SORT_BY_DATE_DESCENDING;
|
||||||
result.sortingMode = options.SORT_BY_VISITCOUNT_DESCENDING;
|
result.sortingMode = options.SORT_BY_VISITCOUNT_DESCENDING;
|
||||||
var rootNode = result.root;
|
var rootNode = result.root;
|
||||||
@@ -81,11 +81,11 @@ vimperator.Bookmarks = function () //{{{
|
|||||||
folders.push(node.itemId);
|
folders.push(node.itemId);
|
||||||
else if (node.type == node.RESULT_TYPE_URI) // bookmark
|
else if (node.type == node.RESULT_TYPE_URI) // bookmark
|
||||||
{
|
{
|
||||||
var kw = bookmarks_service.getKeywordForBookmark(node.itemId);
|
var kw = bookmarksService.getKeywordForBookmark(node.itemId);
|
||||||
if (kw)
|
if (kw)
|
||||||
keywords.push([kw, node.title, node.uri]);
|
keywords.push([kw, node.title, node.uri]);
|
||||||
|
|
||||||
var tags = tagging_service.getTagsForURI(io_service.newURI(node.uri, null, null));
|
var tags = taggingService.getTagsForURI(ioService.newURI(node.uri, null, null));
|
||||||
bookmarks.push([node.uri, node.title, kw, tags]);
|
bookmarks.push([node.uri, node.title, kw, tags]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -101,12 +101,12 @@ vimperator.Bookmarks = function () //{{{
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
||||||
// if "bypass_cache" is true, it will force a reload of the bookmarks database
|
// if "bypassCache" 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
|
||||||
get: function (filter, tags, bypass_cache)
|
get: function (filter, tags, bypassCache)
|
||||||
{
|
{
|
||||||
if (!bookmarks || bypass_cache)
|
if (!bookmarks || bypassCache)
|
||||||
load();
|
load();
|
||||||
|
|
||||||
return vimperator.completion.filterURLArray(bookmarks, filter, tags);
|
return vimperator.completion.filterURLArray(bookmarks, filter, tags);
|
||||||
@@ -123,19 +123,19 @@ vimperator.Bookmarks = function () //{{{
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var uri = io_service.newURI(url, null, null);
|
var uri = ioService.newURI(url, null, null);
|
||||||
var id = bookmarks_service.insertBookmark(bookmarks_service.bookmarksRoot, uri, -1, title);
|
var id = bookmarksService.insertBookmark(bookmarksService.bookmarksRoot, uri, -1, title);
|
||||||
if (!id)
|
if (!id)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (keyword)
|
if (keyword)
|
||||||
{
|
{
|
||||||
bookmarks_service.setKeywordForBookmark(id, keyword);
|
bookmarksService.setKeywordForBookmark(id, keyword);
|
||||||
keywords.unshift([keyword, title, url]);
|
keywords.unshift([keyword, title, url]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tags)
|
if (tags)
|
||||||
tagging_service.tagURI(uri, tags);
|
taggingService.tagURI(uri, tags);
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
@@ -178,12 +178,12 @@ vimperator.Bookmarks = function () //{{{
|
|||||||
var i = 0;
|
var i = 0;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var uri = io_service.newURI(url, null, null);
|
var uri = ioService.newURI(url, null, null);
|
||||||
var count = {};
|
var count = {};
|
||||||
var bmarks = bookmarks_service.getBookmarkIdsForURI(uri, count);
|
var bmarks = bookmarksService.getBookmarkIdsForURI(uri, count);
|
||||||
|
|
||||||
for (; i < bmarks.length; i++)
|
for (; i < bmarks.length; i++)
|
||||||
bookmarks_service.removeItem(bmarks[i]);
|
bookmarksService.removeItem(bmarks[i]);
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
@@ -203,33 +203,33 @@ vimperator.Bookmarks = function () //{{{
|
|||||||
// also ensures that each search engine has a Vimperator-friendly alias
|
// also ensures that each search engine has a Vimperator-friendly alias
|
||||||
getSearchEngines: function ()
|
getSearchEngines: function ()
|
||||||
{
|
{
|
||||||
var search_engines = [];
|
var searchEngines = [];
|
||||||
var firefox_engines = search_service.getVisibleEngines({ });
|
var firefoxEngines = searchService.getVisibleEngines({ });
|
||||||
for (var i in firefox_engines)
|
for (var i in firefoxEngines)
|
||||||
{
|
{
|
||||||
var alias = firefox_engines[i].alias;
|
var alias = firefoxEngines[i].alias;
|
||||||
if (!alias || !/^[a-z0-9_-]+$/.test(alias))
|
if (!alias || !/^[a-z0-9_-]+$/.test(alias))
|
||||||
alias = firefox_engines[i].name.replace(/^\W*([a-zA-Z_-]+).*/, "$1").toLowerCase();
|
alias = firefoxEngines[i].name.replace(/^\W*([a-zA-Z_-]+).*/, "$1").toLowerCase();
|
||||||
if (!alias)
|
if (!alias)
|
||||||
alias = "search"; // for search engines which we can't find a suitable alias
|
alias = "search"; // for search engines which we can't find a suitable alias
|
||||||
|
|
||||||
// make sure we can use search engines which would have the same alias (add numbers at the end)
|
// make sure we can use search engines which would have the same alias (add numbers at the end)
|
||||||
var newalias = alias;
|
var newAlias = alias;
|
||||||
for (var j = 1; j <= 10; j++) // <=10 is intentional
|
for (var j = 1; j <= 10; j++) // <=10 is intentional
|
||||||
{
|
{
|
||||||
if (!search_engines.some(function (item) { return (item[0] == newalias); }))
|
if (!searchEngines.some(function (item) { return (item[0] == newAlias); }))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
newalias = alias + j;
|
newAlias = alias + j;
|
||||||
}
|
}
|
||||||
// only write when it changed, writes are really slow
|
// only write when it changed, writes are really slow
|
||||||
if (firefox_engines[i].alias != newalias)
|
if (firefoxEngines[i].alias != newAlias)
|
||||||
firefox_engines[i].alias = newalias;
|
firefoxEngines[i].alias = newAlias;
|
||||||
|
|
||||||
search_engines.push([firefox_engines[i].alias, firefox_engines[i].description]);
|
searchEngines.push([firefoxEngines[i].alias, firefoxEngines[i].description]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return search_engines;
|
return searchEngines;
|
||||||
},
|
},
|
||||||
|
|
||||||
// TODO: add filtering
|
// TODO: add filtering
|
||||||
@@ -243,29 +243,29 @@ vimperator.Bookmarks = function () //{{{
|
|||||||
return keywords;
|
return keywords;
|
||||||
},
|
},
|
||||||
|
|
||||||
// if @param engine_name is null, it uses the default search engine
|
// if @param engineName 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
|
||||||
getSearchURL: function (text, engine_name)
|
getSearchURL: function (text, engineName)
|
||||||
{
|
{
|
||||||
var url = null;
|
var url = null;
|
||||||
var postdata = null;
|
var postData = null;
|
||||||
if (!engine_name)
|
if (!engineName)
|
||||||
engine_name = vimperator.options["defsearch"];
|
engineName = vimperator.options["defsearch"];
|
||||||
|
|
||||||
// we need to make sure our custom alias have been set, even if the user
|
// we need to make sure our custom alias have been set, even if the user
|
||||||
// did not :open <tab> once before
|
// did not :open <tab> once before
|
||||||
this.getSearchEngines();
|
this.getSearchEngines();
|
||||||
|
|
||||||
// first checks the search engines for a match
|
// first checks the search engines for a match
|
||||||
var engine = search_service.getEngineByAlias(engine_name);
|
var engine = searchService.getEngineByAlias(engineName);
|
||||||
if (engine)
|
if (engine)
|
||||||
{
|
{
|
||||||
if (text)
|
if (text)
|
||||||
{
|
{
|
||||||
var submission = engine.getSubmission(text, null);
|
var submission = engine.getSubmission(text, null);
|
||||||
url = submission.uri.spec;
|
url = submission.uri.spec;
|
||||||
postdata = submission.postData;
|
postData = submission.postData;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
url = engine.searchForm;
|
url = engine.searchForm;
|
||||||
@@ -277,7 +277,7 @@ vimperator.Bookmarks = function () //{{{
|
|||||||
|
|
||||||
for (var i in keywords)
|
for (var i in keywords)
|
||||||
{
|
{
|
||||||
if (keywords[i][0] == engine_name)
|
if (keywords[i][0] == engineName)
|
||||||
{
|
{
|
||||||
if (text == null)
|
if (text == null)
|
||||||
text = "";
|
text = "";
|
||||||
@@ -287,9 +287,9 @@ vimperator.Bookmarks = function () //{{{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we came here, the engine_name is neither a search engine or URL
|
// if we came here, the engineName is neither a search engine or URL
|
||||||
if (postdata)
|
if (postData)
|
||||||
return [url, postdata];
|
return [url, postData];
|
||||||
else
|
else
|
||||||
return url; // can be null
|
return url; // can be null
|
||||||
},
|
},
|
||||||
@@ -359,7 +359,7 @@ vimperator.History = function () //{{{
|
|||||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
const history_service = Components.classes["@mozilla.org/browser/nav-history-service;1"]
|
const historyService = Components.classes["@mozilla.org/browser/nav-history-service;1"]
|
||||||
.getService(Components.interfaces.nsINavHistoryService);
|
.getService(Components.interfaces.nsINavHistoryService);
|
||||||
|
|
||||||
var history = null;
|
var history = null;
|
||||||
@@ -373,11 +373,11 @@ vimperator.History = function () //{{{
|
|||||||
|
|
||||||
// no query parameters will get all history
|
// no query parameters will get all history
|
||||||
// XXX default sorting is... ?
|
// XXX default sorting is... ?
|
||||||
var options = history_service.getNewQueryOptions();
|
var options = historyService.getNewQueryOptions();
|
||||||
var query = history_service.getNewQuery();
|
var query = historyService.getNewQuery();
|
||||||
|
|
||||||
// execute the query
|
// execute the query
|
||||||
var result = history_service.executeQuery(query, options);
|
var result = historyService.executeQuery(query, options);
|
||||||
var rootNode = result.root;
|
var rootNode = result.root;
|
||||||
rootNode.containerOpen = true;
|
rootNode.containerOpen = true;
|
||||||
// iterate over the immediate children of this folder
|
// iterate over the immediate children of this folder
|
||||||
@@ -513,24 +513,24 @@ vimperator.Marks = function () //{{{
|
|||||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
var local_marks = {};
|
var localMarks = {};
|
||||||
var url_marks = {};
|
var urlMarks = {};
|
||||||
var pending_jumps = [];
|
var pendingJumps = [];
|
||||||
var appcontent = document.getElementById("appcontent");
|
var appContent = document.getElementById("appcontent");
|
||||||
|
|
||||||
if (appcontent)
|
if (appContent)
|
||||||
appcontent.addEventListener("load", onPageLoad, true);
|
appContent.addEventListener("load", onPageLoad, true);
|
||||||
|
|
||||||
function onPageLoad(event)
|
function onPageLoad(event)
|
||||||
{
|
{
|
||||||
var win = event.originalTarget.defaultView;
|
var win = event.originalTarget.defaultView;
|
||||||
for (var i = 0, length = pending_jumps.length; i < length; i++)
|
for (var i = 0, length = pendingJumps.length; i < length; i++)
|
||||||
{
|
{
|
||||||
var mark = pending_jumps[i];
|
var mark = pendingJumps[i];
|
||||||
if (win.location.href == mark.location)
|
if (win.location.href == mark.location)
|
||||||
{
|
{
|
||||||
win.scrollTo(mark.position.x * win.scrollMaxX, mark.position.y * win.scrollMaxY);
|
win.scrollTo(mark.position.x * win.scrollMaxX, mark.position.y * win.scrollMaxY);
|
||||||
pending_jumps.splice(i, 1);
|
pendingJumps.splice(i, 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -538,17 +538,17 @@ vimperator.Marks = function () //{{{
|
|||||||
|
|
||||||
function removeLocalMark(mark)
|
function removeLocalMark(mark)
|
||||||
{
|
{
|
||||||
if (mark in local_marks)
|
if (mark in localMarks)
|
||||||
{
|
{
|
||||||
var win = window.content;
|
var win = window.content;
|
||||||
for (var i = 0; i < local_marks[mark].length; i++)
|
for (var i = 0; i < localMarks[mark].length; i++)
|
||||||
{
|
{
|
||||||
if (local_marks[mark][i].location == win.location.href)
|
if (localMarks[mark][i].location == win.location.href)
|
||||||
{
|
{
|
||||||
vimperator.log("Deleting local mark: " + mark + " | " + local_marks[mark][i].location + " | (" + local_marks[mark][i].position.x + ", " + local_marks[mark][i].position.y + ") | tab: " + vimperator.tabs.index(local_marks[mark][i].tab), 5);
|
vimperator.log("Deleting local mark: " + mark + " | " + localMarks[mark][i].location + " | (" + localMarks[mark][i].position.x + ", " + localMarks[mark][i].position.y + ") | tab: " + vimperator.tabs.index(localMarks[mark][i].tab), 5);
|
||||||
local_marks[mark].splice(i, 1);
|
localMarks[mark].splice(i, 1);
|
||||||
if (local_marks[mark].length == 0)
|
if (localMarks[mark].length == 0)
|
||||||
delete local_marks[mark];
|
delete localMarks[mark];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -557,10 +557,10 @@ vimperator.Marks = function () //{{{
|
|||||||
|
|
||||||
function removeURLMark(mark)
|
function removeURLMark(mark)
|
||||||
{
|
{
|
||||||
if (mark in url_marks)
|
if (mark in urlMarks)
|
||||||
{
|
{
|
||||||
vimperator.log("Deleting URL mark: " + mark + " | " + url_marks[mark].location + " | (" + url_marks[mark].position.x + ", " + url_marks[mark].position.y + ") | tab: " + vimperator.tabs.index(url_marks[mark].tab), 5);
|
vimperator.log("Deleting URL mark: " + mark + " | " + urlMarks[mark].location + " | (" + urlMarks[mark].position.x + ", " + urlMarks[mark].position.y + ") | tab: " + vimperator.tabs.index(urlMarks[mark].tab), 5);
|
||||||
delete url_marks[mark];
|
delete urlMarks[mark];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -579,12 +579,12 @@ vimperator.Marks = function () //{{{
|
|||||||
// local marks
|
// local marks
|
||||||
var lmarks = [];
|
var lmarks = [];
|
||||||
|
|
||||||
for (var mark in local_marks)
|
for (var mark in localMarks)
|
||||||
{
|
{
|
||||||
for (var i = 0; i < local_marks[mark].length; i++)
|
for (var i = 0; i < localMarks[mark].length; i++)
|
||||||
{
|
{
|
||||||
if (local_marks[mark][i].location == window.content.location.href)
|
if (localMarks[mark][i].location == window.content.location.href)
|
||||||
lmarks.push([mark, local_marks[mark][i]]);
|
lmarks.push([mark, localMarks[mark][i]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lmarks.sort();
|
lmarks.sort();
|
||||||
@@ -592,8 +592,8 @@ vimperator.Marks = function () //{{{
|
|||||||
// URL marks
|
// URL marks
|
||||||
var umarks = [];
|
var umarks = [];
|
||||||
|
|
||||||
for (var mark in url_marks)
|
for (var mark in urlMarks)
|
||||||
umarks.push([mark, url_marks[mark]]);
|
umarks.push([mark, urlMarks[mark]]);
|
||||||
// FIXME: why does umarks.sort() cause a "Component is not available =
|
// FIXME: why does umarks.sort() cause a "Component is not available =
|
||||||
// NS_ERROR_NOT_AVAILABLE" exception when used here?
|
// NS_ERROR_NOT_AVAILABLE" exception when used here?
|
||||||
umarks.sort(function (a, b) {
|
umarks.sort(function (a, b) {
|
||||||
@@ -632,16 +632,16 @@ vimperator.Marks = function () //{{{
|
|||||||
if (isURLMark(mark))
|
if (isURLMark(mark))
|
||||||
{
|
{
|
||||||
vimperator.log("Adding URL mark: " + mark + " | " + win.location.href + " | (" + position.x + ", " + position.y + ") | tab: " + vimperator.tabs.index(vimperator.tabs.getTab()), 5);
|
vimperator.log("Adding URL mark: " + mark + " | " + win.location.href + " | (" + position.x + ", " + position.y + ") | tab: " + vimperator.tabs.index(vimperator.tabs.getTab()), 5);
|
||||||
url_marks[mark] = { location: win.location.href, position: position, tab: vimperator.tabs.getTab() };
|
urlMarks[mark] = { location: win.location.href, position: position, tab: vimperator.tabs.getTab() };
|
||||||
}
|
}
|
||||||
else if (isLocalMark(mark))
|
else if (isLocalMark(mark))
|
||||||
{
|
{
|
||||||
// remove any previous mark of the same name for this location
|
// remove any previous mark of the same name for this location
|
||||||
removeLocalMark(mark);
|
removeLocalMark(mark);
|
||||||
if (!local_marks[mark])
|
if (!localMarks[mark])
|
||||||
local_marks[mark] = [];
|
localMarks[mark] = [];
|
||||||
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 });
|
localMarks[mark].push({ location: win.location.href, position: position });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -650,18 +650,18 @@ vimperator.Marks = function () //{{{
|
|||||||
if (special)
|
if (special)
|
||||||
{
|
{
|
||||||
// :delmarks! only deletes a-z marks
|
// :delmarks! only deletes a-z marks
|
||||||
for (var mark in local_marks)
|
for (var mark in localMarks)
|
||||||
removeLocalMark(mark);
|
removeLocalMark(mark);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var pattern = new RegExp("[" + filter.replace(/\s+/g, "") + "]");
|
var pattern = new RegExp("[" + filter.replace(/\s+/g, "") + "]");
|
||||||
for (var mark in url_marks)
|
for (var mark in urlMarks)
|
||||||
{
|
{
|
||||||
if (pattern.test(mark))
|
if (pattern.test(mark))
|
||||||
removeURLMark(mark);
|
removeURLMark(mark);
|
||||||
}
|
}
|
||||||
for (var mark in local_marks)
|
for (var mark in localMarks)
|
||||||
{
|
{
|
||||||
if (pattern.test(mark))
|
if (pattern.test(mark))
|
||||||
removeLocalMark(mark);
|
removeLocalMark(mark);
|
||||||
@@ -675,12 +675,12 @@ vimperator.Marks = function () //{{{
|
|||||||
|
|
||||||
if (isURLMark(mark))
|
if (isURLMark(mark))
|
||||||
{
|
{
|
||||||
var slice = url_marks[mark];
|
var slice = urlMarks[mark];
|
||||||
if (slice && slice.tab && slice.tab.linkedBrowser)
|
if (slice && slice.tab && slice.tab.linkedBrowser)
|
||||||
{
|
{
|
||||||
if (!slice.tab.parentNode)
|
if (!slice.tab.parentNode)
|
||||||
{
|
{
|
||||||
pending_jumps.push(slice);
|
pendingJumps.push(slice);
|
||||||
// NOTE: this obviously won't work on generated pages using
|
// NOTE: this obviously won't work on generated pages using
|
||||||
// non-unique URLs, like Vimperator's help :(
|
// non-unique URLs, like Vimperator's help :(
|
||||||
vimperator.open(slice.location, vimperator.NEW_TAB);
|
vimperator.open(slice.location, vimperator.NEW_TAB);
|
||||||
@@ -693,7 +693,7 @@ vimperator.Marks = function () //{{{
|
|||||||
var win = slice.tab.linkedBrowser.contentWindow;
|
var win = slice.tab.linkedBrowser.contentWindow;
|
||||||
if (win.location.href != slice.location)
|
if (win.location.href != slice.location)
|
||||||
{
|
{
|
||||||
pending_jumps.push(slice);
|
pendingJumps.push(slice);
|
||||||
win.location.href = slice.location;
|
win.location.href = slice.location;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -706,7 +706,7 @@ vimperator.Marks = function () //{{{
|
|||||||
else if (isLocalMark(mark))
|
else if (isLocalMark(mark))
|
||||||
{
|
{
|
||||||
var win = window.content;
|
var win = window.content;
|
||||||
var slice = local_marks[mark] || [];
|
var slice = localMarks[mark] || [];
|
||||||
|
|
||||||
for (var i = 0; i < slice.length; i++)
|
for (var i = 0; i < slice.length; i++)
|
||||||
{
|
{
|
||||||
@@ -773,12 +773,12 @@ vimperator.QuickMarks = function () //{{{
|
|||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
var qmarks = {};
|
var qmarks = {};
|
||||||
var saved_marks = vimperator.options.getPref("quickmarks", "").split("\n");
|
var savedMarks = vimperator.options.getPref("quickmarks", "").split("\n");
|
||||||
|
|
||||||
// load the saved quickmarks -- TODO: change to sqlite
|
// load the saved quickmarks -- TODO: change to sqlite
|
||||||
for (var i = 0; i < saved_marks.length - 1; i += 2)
|
for (var i = 0; i < savedMarks.length - 1; i += 2)
|
||||||
{
|
{
|
||||||
qmarks[saved_marks[i]] = saved_marks[i + 1];
|
qmarks[savedMarks[i]] = savedMarks[i + 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
@@ -861,15 +861,15 @@ vimperator.QuickMarks = function () //{{{
|
|||||||
destroy: function ()
|
destroy: function ()
|
||||||
{
|
{
|
||||||
// save the quickmarks
|
// save the quickmarks
|
||||||
var saved_qmarks = "";
|
var savedQuickMarks = "";
|
||||||
|
|
||||||
for (var i in qmarks)
|
for (var i in qmarks)
|
||||||
{
|
{
|
||||||
saved_qmarks += i + "\n";
|
savedQuickMarks += i + "\n";
|
||||||
saved_qmarks += qmarks[i] + "\n";
|
savedQuickMarks += qmarks[i] + "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
vimperator.options.setPref("quickmarks", saved_qmarks);
|
vimperator.options.setPref("quickmarks", savedQuickMarks);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
//}}}
|
//}}}
|
||||||
|
|||||||
@@ -35,10 +35,10 @@ vimperator.Buffer = function () //{{{
|
|||||||
// 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;
|
||||||
var zoom_levels = [ 1, 10, 25, 50, 75, 90, 100,
|
var zoomLevels = [ 1, 10, 25, 50, 75, 90, 100,
|
||||||
120, 150, 200, 300, 500, 1000, 2000 ];
|
120, 150, 200, 300, 500, 1000, 2000 ];
|
||||||
|
|
||||||
function setZoom(value, full_zoom)
|
function setZoom(value, fullZoom)
|
||||||
{
|
{
|
||||||
if (value < 1 || value > 2000)
|
if (value < 1 || value > 2000)
|
||||||
{
|
{
|
||||||
@@ -46,12 +46,12 @@ vimperator.Buffer = function () //{{{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (full_zoom)
|
if (fullZoom)
|
||||||
getBrowser().mCurrentBrowser.markupDocumentViewer.fullZoom = value / 100.0;
|
getBrowser().mCurrentBrowser.markupDocumentViewer.fullZoom = value / 100.0;
|
||||||
else
|
else
|
||||||
getBrowser().mCurrentBrowser.markupDocumentViewer.textZoom = value / 100.0;
|
getBrowser().mCurrentBrowser.markupDocumentViewer.textZoom = value / 100.0;
|
||||||
|
|
||||||
vimperator.echo((full_zoom ? "Full zoom: " : "Text zoom: ") + value + "%");
|
vimperator.echo((fullZoom ? "Full zoom: " : "Text zoom: ") + value + "%");
|
||||||
|
|
||||||
// TODO: shouldn't this just recalculate hint coords, rather than
|
// TODO: shouldn't this just recalculate hint coords, rather than
|
||||||
// unsuccessfully attempt to reshow hints? i.e. isn't it just relying
|
// unsuccessfully attempt to reshow hints? i.e. isn't it just relying
|
||||||
@@ -60,9 +60,9 @@ vimperator.Buffer = function () //{{{
|
|||||||
// vimperator.hints.reshowHints();
|
// vimperator.hints.reshowHints();
|
||||||
}
|
}
|
||||||
|
|
||||||
function bumpZoomLevel(steps, full_zoom)
|
function bumpZoomLevel(steps, fullZoom)
|
||||||
{
|
{
|
||||||
if (full_zoom)
|
if (fullZoom)
|
||||||
var value = getBrowser().mCurrentBrowser.markupDocumentViewer.fullZoom * 100.0;
|
var value = getBrowser().mCurrentBrowser.markupDocumentViewer.fullZoom * 100.0;
|
||||||
else
|
else
|
||||||
var value = getBrowser().mCurrentBrowser.markupDocumentViewer.textZoom * 100.0;
|
var value = getBrowser().mCurrentBrowser.markupDocumentViewer.textZoom * 100.0;
|
||||||
@@ -70,9 +70,9 @@ vimperator.Buffer = function () //{{{
|
|||||||
var index = -1;
|
var index = -1;
|
||||||
if (steps <= 0)
|
if (steps <= 0)
|
||||||
{
|
{
|
||||||
for (var i = zoom_levels.length - 1; i >= 0; i--)
|
for (var i = zoomLevels.length - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
if ((zoom_levels[i] + 0.01) < value) // 0.01 for float comparison
|
if ((zoomLevels[i] + 0.01) < value) // 0.01 for float comparison
|
||||||
{
|
{
|
||||||
index = i + 1 + steps;
|
index = i + 1 + steps;
|
||||||
break;
|
break;
|
||||||
@@ -81,21 +81,21 @@ vimperator.Buffer = function () //{{{
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (var i = 0; i < zoom_levels.length; i++)
|
for (var i = 0; i < zoomLevels.length; i++)
|
||||||
{
|
{
|
||||||
if ((zoom_levels[i] - 0.01) > value) // 0.01 for float comparison
|
if ((zoomLevels[i] - 0.01) > value) // 0.01 for float comparison
|
||||||
{
|
{
|
||||||
index = i - 1 + steps;
|
index = i - 1 + steps;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (index < 0 || index >= zoom_levels.length)
|
if (index < 0 || index >= zoomLevels.length)
|
||||||
{
|
{
|
||||||
vimperator.beep();
|
vimperator.beep();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setZoom(zoom_levels[index], full_zoom);
|
setZoom(zoomLevels[index], fullZoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkScrollYBounds(win, direction)
|
function checkScrollYBounds(win, direction)
|
||||||
@@ -203,26 +203,26 @@ vimperator.Buffer = function () //{{{
|
|||||||
offsetX = offsetX || 1;
|
offsetX = offsetX || 1;
|
||||||
offsetY = offsetY || 1;
|
offsetY = offsetY || 1;
|
||||||
|
|
||||||
var new_tab = false, new_window = false;
|
var newTab = false, newWindow = false;
|
||||||
switch (where)
|
switch (where)
|
||||||
{
|
{
|
||||||
case vimperator.NEW_TAB:
|
case vimperator.NEW_TAB:
|
||||||
case vimperator.NEW_BACKGROUND_TAB:
|
case vimperator.NEW_BACKGROUND_TAB:
|
||||||
new_tab = true;
|
newTab = true;
|
||||||
break;
|
break;
|
||||||
case vimperator.NEW_WINDOW:
|
case vimperator.NEW_WINDOW:
|
||||||
new_window = true;
|
newWindow = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
vimperator.log("Invalid where argument for followLink()");
|
vimperator.log("Invalid where argument for followLink()");
|
||||||
}
|
}
|
||||||
|
|
||||||
var evt = doc.createEvent("MouseEvents");
|
var evt = doc.createEvent("MouseEvents");
|
||||||
evt.initMouseEvent("mousedown", true, true, view, 1, offsetX, offsetY, 0, 0, /*ctrl*/ new_tab, /*event.altKey*/0, /*event.shiftKey*/ new_window, /*event.metaKey*/ new_tab, 0, null);
|
evt.initMouseEvent("mousedown", true, true, view, 1, offsetX, offsetY, 0, 0, /*ctrl*/ newTab, /*event.altKey*/0, /*event.shiftKey*/ newWindow, /*event.metaKey*/ newTab, 0, null);
|
||||||
elem.dispatchEvent(evt);
|
elem.dispatchEvent(evt);
|
||||||
|
|
||||||
//var evt = doc.createEvent("MouseEvents");
|
//var evt = doc.createEvent("MouseEvents");
|
||||||
evt.initMouseEvent("click", true, true, view, 1, offsetX, offsetY, 0, 0, /*ctrl*/ new_tab, /*event.altKey*/0, /*event.shiftKey*/ new_window, /*event.metaKey*/ new_tab, 0, null);
|
evt.initMouseEvent("click", true, true, view, 1, offsetX, offsetY, 0, 0, /*ctrl*/ newTab, /*event.altKey*/0, /*event.shiftKey*/ newWindow, /*event.metaKey*/ newTab, 0, null);
|
||||||
elem.dispatchEvent(evt);
|
elem.dispatchEvent(evt);
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -235,14 +235,14 @@ vimperator.Buffer = function () //{{{
|
|||||||
|
|
||||||
if (!selection)
|
if (!selection)
|
||||||
{
|
{
|
||||||
var selection_controller = getBrowser().docShell
|
var selectionController = getBrowser().docShell
|
||||||
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||||
.getInterface(Components.interfaces.nsISelectionDisplay)
|
.getInterface(Components.interfaces.nsISelectionDisplay)
|
||||||
.QueryInterface(Components.interfaces.nsISelectionController);
|
.QueryInterface(Components.interfaces.nsISelectionController);
|
||||||
|
|
||||||
selection_controller.setCaretEnabled(true);
|
selectionController.setCaretEnabled(true);
|
||||||
selection_controller.wordMove(false, false);
|
selectionController.wordMove(false, false);
|
||||||
selection_controller.wordMove(true, true);
|
selectionController.wordMove(true, true);
|
||||||
selection = window.content.getSelection().toString();
|
selection = window.content.getSelection().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,7 +260,7 @@ vimperator.Buffer = function () //{{{
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var items = vimperator.completion.get_buffer_completions("");
|
var items = vimperator.completion.getBufferCompletions("");
|
||||||
vimperator.bufferwindow.show(items);
|
vimperator.bufferwindow.show(items);
|
||||||
vimperator.bufferwindow.selectItem(getBrowser().mTabContainer.selectedIndex);
|
vimperator.bufferwindow.selectItem(getBrowser().mTabContainer.selectedIndex);
|
||||||
}
|
}
|
||||||
@@ -268,7 +268,7 @@ vimperator.Buffer = function () //{{{
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// TODO: move this to vimperator.buffers.get()
|
// TODO: move this to vimperator.buffers.get()
|
||||||
var items = vimperator.completion.get_buffer_completions("");
|
var items = vimperator.completion.getBufferCompletions("");
|
||||||
var number, indicator, title, url;
|
var number, indicator, title, url;
|
||||||
|
|
||||||
var list = ":" + vimperator.util.escapeHTML(vimperator.commandline.getCommand()) + "<br/>" + "<table>";
|
var list = ":" + vimperator.util.escapeHTML(vimperator.commandline.getCommand()) + "<br/>" + "<table>";
|
||||||
@@ -451,7 +451,7 @@ vimperator.Buffer = function () //{{{
|
|||||||
if (!vimperator.bufferwindow.visible())
|
if (!vimperator.bufferwindow.visible())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var items = vimperator.completion.get_buffer_completions("");
|
var items = vimperator.completion.getBufferCompletions("");
|
||||||
vimperator.bufferwindow.show(items);
|
vimperator.bufferwindow.show(items);
|
||||||
vimperator.bufferwindow.selectItem(getBrowser().mTabContainer.selectedIndex);
|
vimperator.bufferwindow.selectItem(getBrowser().mTabContainer.selectedIndex);
|
||||||
},
|
},
|
||||||
@@ -484,7 +484,7 @@ vimperator.Buffer = function () //{{{
|
|||||||
return vimperator.tabs.select(parseInt(match[1], 10) - 1, false); // make it zero-based
|
return vimperator.tabs.select(parseInt(match[1], 10) - 1, false); // make it zero-based
|
||||||
|
|
||||||
var matches = [];
|
var matches = [];
|
||||||
var lower_buffer = buffer.toLowerCase();
|
var lowerBuffer = buffer.toLowerCase();
|
||||||
var first = vimperator.tabs.index() + (reverse ? 0 : 1);
|
var first = vimperator.tabs.index() + (reverse ? 0 : 1);
|
||||||
for (var i = 0; i < getBrowser().browsers.length; i++)
|
for (var i = 0; i < getBrowser().browsers.length; i++)
|
||||||
{
|
{
|
||||||
@@ -494,7 +494,7 @@ vimperator.Buffer = function () //{{{
|
|||||||
if (url == buffer)
|
if (url == buffer)
|
||||||
return vimperator.tabs.select(index, false);
|
return vimperator.tabs.select(index, false);
|
||||||
|
|
||||||
if (url.indexOf(buffer) >= 0 || title.indexOf(lower_buffer) >= 0)
|
if (url.indexOf(buffer) >= 0 || title.indexOf(lowerBuffer) >= 0)
|
||||||
matches.push(index);
|
matches.push(index);
|
||||||
}
|
}
|
||||||
if (matches.length == 0)
|
if (matches.length == 0)
|
||||||
@@ -516,14 +516,14 @@ vimperator.Buffer = function () //{{{
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
zoomIn: function (steps, full_zoom)
|
zoomIn: function (steps, fullZoom)
|
||||||
{
|
{
|
||||||
bumpZoomLevel(steps, full_zoom);
|
bumpZoomLevel(steps, fullZoom);
|
||||||
},
|
},
|
||||||
|
|
||||||
zoomOut: function (steps, full_zoom)
|
zoomOut: function (steps, fullZoom)
|
||||||
{
|
{
|
||||||
bumpZoomLevel(-steps, full_zoom);
|
bumpZoomLevel(-steps, fullZoom);
|
||||||
},
|
},
|
||||||
|
|
||||||
pageInfo: function (verbose)
|
pageInfo: function (verbose)
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -29,11 +29,11 @@ the terms of any one of the MPL, the GPL or the LGPL.
|
|||||||
vimperator.Completion = function () // {{{
|
vimperator.Completion = function () // {{{
|
||||||
{
|
{
|
||||||
// The completion substrings, used for showing the longest common match
|
// The completion substrings, used for showing the longest common match
|
||||||
var g_substrings = [];
|
var substrings = [];
|
||||||
|
|
||||||
// function uses smartcase
|
// function uses smartcase
|
||||||
// list = [ [['com1', 'com2'], 'text'], [['com3', 'com4'], 'text'] ]
|
// list = [ [['com1', 'com2'], 'text'], [['com3', 'com4'], 'text'] ]
|
||||||
function build_longest_common_substring(list, filter) //{{{
|
function buildLongestCommonSubstring(list, filter) //{{{
|
||||||
{
|
{
|
||||||
var filtered = [];
|
var filtered = [];
|
||||||
var ignorecase = false;
|
var ignorecase = false;
|
||||||
@@ -51,19 +51,19 @@ vimperator.Completion = function () // {{{
|
|||||||
if (item.indexOf(filter) == -1)
|
if (item.indexOf(filter) == -1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (g_substrings.length == 0)
|
if (substrings.length == 0)
|
||||||
{
|
{
|
||||||
var last_index = item.lastIndexOf(filter);
|
var lastIndex = item.lastIndexOf(filter);
|
||||||
var length = item.length;
|
var length = item.length;
|
||||||
for (var k = item.indexOf(filter); k != -1 && k <= last_index; k = item.indexOf(filter, k + 1))
|
for (var k = item.indexOf(filter); k != -1 && k <= lastIndex; k = item.indexOf(filter, k + 1))
|
||||||
{
|
{
|
||||||
for (var l = k + filter.length; l <= length; l++)
|
for (var l = k + filter.length; l <= length; l++)
|
||||||
g_substrings.push(list[i][0][j].substring(k, l));
|
substrings.push(list[i][0][j].substring(k, l));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_substrings = g_substrings.filter(function ($_) {
|
substrings = substrings.filter(function ($_) {
|
||||||
return list[i][0][j].indexOf($_) >= 0;
|
return list[i][0][j].indexOf($_) >= 0;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -75,7 +75,7 @@ vimperator.Completion = function () // {{{
|
|||||||
} //}}}
|
} //}}}
|
||||||
|
|
||||||
/* this function is case sensitive and should be documented about input and output ;) */
|
/* this function is case sensitive and should be documented about input and output ;) */
|
||||||
function build_longest_starting_substring(list, filter) //{{{
|
function buildLongestStartingSubstring(list, filter) //{{{
|
||||||
{
|
{
|
||||||
var filtered = [];
|
var filtered = [];
|
||||||
for (var i = 0; i < list.length; i++)
|
for (var i = 0; i < list.length; i++)
|
||||||
@@ -85,15 +85,15 @@ vimperator.Completion = function () // {{{
|
|||||||
if (list[i][0][j].indexOf(filter) != 0)
|
if (list[i][0][j].indexOf(filter) != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (g_substrings.length == 0)
|
if (substrings.length == 0)
|
||||||
{
|
{
|
||||||
var length = list[i][0][j].length;
|
var length = list[i][0][j].length;
|
||||||
for (var k = filter.length; k <= length; k++)
|
for (var k = filter.length; k <= length; k++)
|
||||||
g_substrings.push(list[i][0][j].substring(0, k));
|
substrings.push(list[i][0][j].substring(0, k));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_substrings = g_substrings.filter(function ($_) {
|
substrings = substrings.filter(function ($_) {
|
||||||
return list[i][0][j].indexOf($_) == 0;
|
return list[i][0][j].indexOf($_) == 0;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -109,23 +109,23 @@ vimperator.Completion = function () // {{{
|
|||||||
* returns the longest common substring
|
* returns the longest common substring
|
||||||
* used for the 'longest' setting for wildmode
|
* used for the 'longest' setting for wildmode
|
||||||
*/
|
*/
|
||||||
get_longest_substring: function () //{{{
|
getLongestSubstring: function () //{{{
|
||||||
{
|
{
|
||||||
if (g_substrings.length == 0)
|
if (substrings.length == 0)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
var longest = g_substrings[0];
|
var longest = substrings[0];
|
||||||
for (var i = 1; i < g_substrings.length; i++)
|
for (var i = 1; i < substrings.length; i++)
|
||||||
{
|
{
|
||||||
if (g_substrings[i].length > longest.length)
|
if (substrings[i].length > longest.length)
|
||||||
longest = g_substrings[i];
|
longest = substrings[i];
|
||||||
}
|
}
|
||||||
return longest;
|
return longest;
|
||||||
}, //}}}
|
}, //}}}
|
||||||
|
|
||||||
dialog: function (filter) //{{{
|
dialog: function (filter) //{{{
|
||||||
{
|
{
|
||||||
g_substrings = [];
|
substrings = [];
|
||||||
var nodes = [
|
var nodes = [
|
||||||
["about", "About Firefox"],
|
["about", "About Firefox"],
|
||||||
["addbookmark", "Add bookmarks for the current page"],
|
["addbookmark", "Add bookmarks for the current page"],
|
||||||
@@ -155,7 +155,7 @@ vimperator.Completion = function () // {{{
|
|||||||
return [[node[0]], node[1]];
|
return [[node[0]], node[1]];
|
||||||
});
|
});
|
||||||
|
|
||||||
return build_longest_common_substring(mapped, filter);
|
return buildLongestCommonSubstring(mapped, filter);
|
||||||
}, //}}}
|
}, //}}}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -165,29 +165,29 @@ vimperator.Completion = function () // {{{
|
|||||||
* depending on the 'complete' option
|
* depending on the 'complete' option
|
||||||
* if the 'complete' argument is passed like "h", it temporarily overrides the complete option
|
* if the 'complete' argument is passed like "h", it temporarily overrides the complete option
|
||||||
*/
|
*/
|
||||||
get_url_completions: function (filter, complete) //{{{
|
getUrlCompletions: function (filter, complete) //{{{
|
||||||
{
|
{
|
||||||
var completions = [];
|
var completions = [];
|
||||||
g_substrings = [];
|
substrings = [];
|
||||||
|
|
||||||
var cpt = complete || vimperator.options["complete"];
|
var cpt = complete || vimperator.options["complete"];
|
||||||
// join all completion arrays together
|
// join all completion arrays together
|
||||||
for (var i = 0; i < cpt.length; i++)
|
for (var i = 0; i < cpt.length; i++)
|
||||||
{
|
{
|
||||||
if (cpt[i] == "s")
|
if (cpt[i] == "s")
|
||||||
completions = completions.concat(this.get_search_completions(filter));
|
completions = completions.concat(this.getSearchCompletions(filter));
|
||||||
else if (cpt[i] == "b")
|
else if (cpt[i] == "b")
|
||||||
completions = completions.concat(vimperator.bookmarks.get(filter));
|
completions = completions.concat(vimperator.bookmarks.get(filter));
|
||||||
else if (cpt[i] == "h")
|
else if (cpt[i] == "h")
|
||||||
completions = completions.concat(vimperator.history.get(filter));
|
completions = completions.concat(vimperator.history.get(filter));
|
||||||
else if (cpt[i] == "f")
|
else if (cpt[i] == "f")
|
||||||
completions = completions.concat(this.get_file_completions(filter, true));
|
completions = completions.concat(this.getFileCompletions(filter, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
return completions;
|
return completions;
|
||||||
}, //}}}
|
}, //}}}
|
||||||
|
|
||||||
get_search_completions: function (filter) //{{{
|
getSearchCompletions: function (filter) //{{{
|
||||||
{
|
{
|
||||||
var engines = vimperator.bookmarks.getSearchEngines().concat(vimperator.bookmarks.getKeywords());
|
var engines = vimperator.bookmarks.getSearchEngines().concat(vimperator.bookmarks.getKeywords());
|
||||||
|
|
||||||
@@ -197,16 +197,16 @@ vimperator.Completion = function () // {{{
|
|||||||
var mapped = engines.map(function (engine) {
|
var mapped = engines.map(function (engine) {
|
||||||
return [[engine[0]], engine[1]];
|
return [[engine[0]], engine[1]];
|
||||||
});
|
});
|
||||||
return build_longest_common_substring(mapped, filter);
|
return buildLongestCommonSubstring(mapped, filter);
|
||||||
}, //}}}
|
}, //}}}
|
||||||
|
|
||||||
// TODO: support file:// and \ or / path separators on both platforms
|
// TODO: support file:// and \ or / path separators on both platforms
|
||||||
get_file_completions: function (filter)
|
getFileCompletions: function (filter)
|
||||||
{
|
{
|
||||||
// this is now also used as part of the url completion, so the
|
// this is now also used as part of the url completion, so the
|
||||||
// substrings shouldn't be cleared for that case
|
// substrings shouldn't be cleared for that case
|
||||||
if (!arguments[1])
|
if (!arguments[1])
|
||||||
g_substrings = [];
|
substrings = [];
|
||||||
|
|
||||||
var matches = filter.match(/^(.*[\/\\])(.*?)$/);
|
var matches = filter.match(/^(.*[\/\\])(.*?)$/);
|
||||||
var dir;
|
var dir;
|
||||||
@@ -230,56 +230,56 @@ vimperator.Completion = function () // {{{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return build_longest_starting_substring(mapped, filter);
|
return buildLongestStartingSubstring(mapped, filter);
|
||||||
},
|
},
|
||||||
|
|
||||||
get_help_completions: function (filter) //{{{
|
getHelpCompletions: function (filter) //{{{
|
||||||
{
|
{
|
||||||
var help_array = [[["introduction"], "Introductory text"],
|
var helpArray = [[["introduction"], "Introductory text"],
|
||||||
[["initialization"], "Initialization and startup"],
|
[["initialization"], "Initialization and startup"],
|
||||||
[["mappings"], "Normal mode commands"],
|
[["mappings"], "Normal mode commands"],
|
||||||
[["commands"], "Ex commands"],
|
[["commands"], "Ex commands"],
|
||||||
[["options"], "Configuration options"]]; // TODO: hardcoded until we have proper 'pages'
|
[["options"], "Configuration options"]]; // TODO: hardcoded until we have proper 'pages'
|
||||||
g_substrings = [];
|
substrings = [];
|
||||||
for (var command in vimperator.commands)
|
for (var command in vimperator.commands)
|
||||||
help_array.push([command.long_names.map(function ($_) { return ":" + $_; }), command.short_help]);
|
helpArray.push([command.longNames.map(function ($_) { return ":" + $_; }), command.shortHelp]);
|
||||||
options = this.get_options_completions(filter, true);
|
options = this.getOptionCompletions(filter, true);
|
||||||
help_array = help_array.concat(options.map(function ($_) {
|
helpArray = helpArray.concat(options.map(function ($_) {
|
||||||
return [
|
return [
|
||||||
$_[0].map(function ($_) { return "'" + $_ + "'"; }),
|
$_[0].map(function ($_) { return "'" + $_ + "'"; }),
|
||||||
$_[1]
|
$_[1]
|
||||||
];
|
];
|
||||||
}));
|
}));
|
||||||
for (var map in vimperator.mappings)
|
for (var map in vimperator.mappings)
|
||||||
help_array.push([map.names, map.short_help]);
|
helpArray.push([map.names, map.shortHelp]);
|
||||||
|
|
||||||
if (!filter) return help_array.map(function ($_) {
|
if (!filter) return helpArray.map(function ($_) {
|
||||||
return [$_[0][0], $_[1]]; // unfiltered, use the first command
|
return [$_[0][0], $_[1]]; // unfiltered, use the first command
|
||||||
});
|
});
|
||||||
|
|
||||||
return build_longest_common_substring(help_array, filter);
|
return buildLongestCommonSubstring(helpArray, filter);
|
||||||
}, //}}}
|
}, //}}}
|
||||||
|
|
||||||
get_command_completions: function (filter) //{{{
|
getCommandCompletions: function (filter) //{{{
|
||||||
{
|
{
|
||||||
g_substrings = [];
|
substrings = [];
|
||||||
var completions = [];
|
var completions = [];
|
||||||
if (!filter)
|
if (!filter)
|
||||||
{
|
{
|
||||||
for (var command in vimperator.commands)
|
for (var command in vimperator.commands)
|
||||||
completions.push([command.name, command.short_help]);
|
completions.push([command.name, command.shortHelp]);
|
||||||
return completions;
|
return completions;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var command in vimperator.commands)
|
for (var command in vimperator.commands)
|
||||||
completions.push([command.long_names, command.short_help]);
|
completions.push([command.longNames, command.shortHelp]);
|
||||||
return build_longest_starting_substring(completions, filter);
|
return buildLongestStartingSubstring(completions, filter);
|
||||||
}, //}}}
|
}, //}}}
|
||||||
|
|
||||||
get_options_completions: function (filter, unfiltered) //{{{
|
getOptionCompletions: function (filter, unfiltered) //{{{
|
||||||
{
|
{
|
||||||
g_substrings = [];
|
substrings = [];
|
||||||
var options_completions = [];
|
var optionCompletions = [];
|
||||||
var prefix = filter.match(/^no|inv/) || "";
|
var prefix = filter.match(/^no|inv/) || "";
|
||||||
|
|
||||||
if (prefix)
|
if (prefix)
|
||||||
@@ -292,7 +292,7 @@ vimperator.Completion = function () // {{{
|
|||||||
{
|
{
|
||||||
if (prefix && option.type != "boolean")
|
if (prefix && option.type != "boolean")
|
||||||
continue;
|
continue;
|
||||||
options.push([option.names, option.short_help]);
|
options.push([option.names, option.shortHelp]);
|
||||||
}
|
}
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
@@ -304,7 +304,7 @@ vimperator.Completion = function () // {{{
|
|||||||
{
|
{
|
||||||
if (prefix && option.type != "boolean")
|
if (prefix && option.type != "boolean")
|
||||||
continue;
|
continue;
|
||||||
options.push([prefix + option.name, option.short_help]);
|
options.push([prefix + option.name, option.shortHelp]);
|
||||||
}
|
}
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
@@ -316,15 +316,15 @@ vimperator.Completion = function () // {{{
|
|||||||
{
|
{
|
||||||
if (option.hasName(filter))
|
if (option.hasName(filter))
|
||||||
{
|
{
|
||||||
options_completions.push([filter + "=" + option.value, ""]);
|
optionCompletions.push([filter + "=" + option.value, ""]);
|
||||||
return options_completions;
|
return optionCompletions;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return options_completions;
|
return optionCompletions;
|
||||||
}
|
}
|
||||||
|
|
||||||
// can't use b_l_s_s, since this has special requirements (the prefix)
|
// can't use b_l_s_s, since this has special requirements (the prefix)
|
||||||
var filter_length = filter.length;
|
var filterLength = filter.length;
|
||||||
for (var option in vimperator.options)
|
for (var option in vimperator.options)
|
||||||
{
|
{
|
||||||
if (prefix && option.type != "boolean")
|
if (prefix && option.type != "boolean")
|
||||||
@@ -335,29 +335,29 @@ vimperator.Completion = function () // {{{
|
|||||||
if (option.names[j].indexOf(filter) != 0)
|
if (option.names[j].indexOf(filter) != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (g_substrings.length == 0)
|
if (substrings.length == 0)
|
||||||
{
|
{
|
||||||
var length = option.names[j].length;
|
var length = option.names[j].length;
|
||||||
for (var k = filter_length; k <= length; k++)
|
for (var k = filterLength; k <= length; k++)
|
||||||
g_substrings.push(prefix + option.names[j].substring(0, k));
|
substrings.push(prefix + option.names[j].substring(0, k));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_substrings = g_substrings.filter(function ($_) {
|
substrings = substrings.filter(function ($_) {
|
||||||
return option.names[j].indexOf($_) == 0;
|
return option.names[j].indexOf($_) == 0;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
options_completions.push([prefix + option.names[j], option.short_help]);
|
optionCompletions.push([prefix + option.names[j], option.shortHelp]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return options_completions;
|
return optionCompletions;
|
||||||
}, //}}}
|
}, //}}}
|
||||||
|
|
||||||
get_buffer_completions: function (filter) //{{{
|
getBufferCompletions: function (filter) //{{{
|
||||||
{
|
{
|
||||||
g_substrings = [];
|
substrings = [];
|
||||||
var items = [];
|
var items = [];
|
||||||
var num = getBrowser().browsers.length;
|
var num = getBrowser().browsers.length;
|
||||||
var title, url;
|
var title, url;
|
||||||
@@ -388,12 +388,12 @@ vimperator.Completion = function () // {{{
|
|||||||
if (!filter) return items.map(function ($_) {
|
if (!filter) return items.map(function ($_) {
|
||||||
return [$_[0][0], $_[1]];
|
return [$_[0][0], $_[1]];
|
||||||
});
|
});
|
||||||
return build_longest_common_substring(items, filter);
|
return buildLongestCommonSubstring(items, filter);
|
||||||
}, //}}}
|
}, //}}}
|
||||||
|
|
||||||
get_sidebar_completions: function (filter) //{{{
|
getSidebarCompletions: function (filter) //{{{
|
||||||
{
|
{
|
||||||
g_substrings = [];
|
substrings = [];
|
||||||
var menu = document.getElementById("viewSidebarMenu");
|
var menu = document.getElementById("viewSidebarMenu");
|
||||||
var nodes = [];
|
var nodes = [];
|
||||||
|
|
||||||
@@ -407,12 +407,12 @@ vimperator.Completion = function () // {{{
|
|||||||
return [[node[0]], node[1]];
|
return [[node[0]], node[1]];
|
||||||
});
|
});
|
||||||
|
|
||||||
return build_longest_common_substring(mapped, filter);
|
return buildLongestCommonSubstring(mapped, filter);
|
||||||
}, //}}}
|
}, //}}}
|
||||||
|
|
||||||
javascript: function (str) // {{{
|
javascript: function (str) // {{{
|
||||||
{
|
{
|
||||||
g_substrings = [];
|
substrings = [];
|
||||||
var matches = str.match(/^(.*?)(\s*\.\s*)?(\w*)$/);
|
var matches = str.match(/^(.*?)(\s*\.\s*)?(\w*)$/);
|
||||||
var objects = [];
|
var objects = [];
|
||||||
var filter = matches[3] || "";
|
var filter = matches[3] || "";
|
||||||
@@ -483,7 +483,7 @@ vimperator.Completion = function () // {{{
|
|||||||
completions = [];
|
completions = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return build_longest_starting_substring(completions, filter);
|
return buildLongestStartingSubstring(completions, filter);
|
||||||
}, // }}}
|
}, // }}}
|
||||||
|
|
||||||
// discard all entries in the 'urls' array, which don't match 'filter
|
// discard all entries in the 'urls' array, which don't match 'filter
|
||||||
@@ -494,7 +494,7 @@ vimperator.Completion = function () // {{{
|
|||||||
var filtered = [];
|
var filtered = [];
|
||||||
// completions which don't match the url but just the description
|
// completions which don't match the url but just the description
|
||||||
// list them add the end of the array
|
// list them add the end of the array
|
||||||
var additional_completions = [];
|
var additionalCompletions = [];
|
||||||
|
|
||||||
if (urls.length == 0)
|
if (urls.length == 0)
|
||||||
return [];
|
return [];
|
||||||
@@ -519,7 +519,7 @@ vimperator.Completion = function () // {{{
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Longest Common Subsequence
|
* Longest Common Subsequence
|
||||||
* This shouldn't use build_longest_common_substring
|
* This shouldn't use buildLongestCommonSubstring
|
||||||
* for performance reasons, so as not to cycle through the urls twice
|
* for performance reasons, so as not to cycle through the urls twice
|
||||||
*/
|
*/
|
||||||
outer:
|
outer:
|
||||||
@@ -553,28 +553,28 @@ vimperator.Completion = function () // {{{
|
|||||||
if (filter.split(/\s+/).every(function (token) {
|
if (filter.split(/\s+/).every(function (token) {
|
||||||
return (url.indexOf(token) > -1 || title.indexOf(token) > -1);
|
return (url.indexOf(token) > -1 || title.indexOf(token) > -1);
|
||||||
}))
|
}))
|
||||||
additional_completions.push(urls[i]);
|
additionalCompletions.push(urls[i]);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: refactor out? And just build if wildmode contains longest?
|
// TODO: refactor out? And just build if wildmode contains longest?
|
||||||
if (g_substrings.length == 0) // Build the substrings
|
if (substrings.length == 0) // Build the substrings
|
||||||
{
|
{
|
||||||
var last_index = url.lastIndexOf(filter);
|
var lastIndex = url.lastIndexOf(filter);
|
||||||
var url_length = url.length;
|
var urlLength = url.length;
|
||||||
if (last_index >= 0 && last_index < url_length) // do not build substrings, if we don't match filter
|
if (lastIndex >= 0 && lastIndex < urlLength) // do not build substrings, if we don't match filter
|
||||||
{
|
{
|
||||||
for (var k = url.indexOf(filter); k != -1 && k <= last_index; k = url.indexOf(filter, k + 1))
|
for (var k = url.indexOf(filter); k != -1 && k <= lastIndex; k = url.indexOf(filter, k + 1))
|
||||||
{
|
{
|
||||||
for (var l = k + filter.length; l <= url_length; l++)
|
for (var l = k + filter.length; l <= urlLength; l++)
|
||||||
g_substrings.push(url.substring(k, l));
|
substrings.push(url.substring(k, l));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_substrings = g_substrings.filter(function ($_) {
|
substrings = substrings.filter(function ($_) {
|
||||||
return url.indexOf($_) >= 0;
|
return url.indexOf($_) >= 0;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -582,24 +582,24 @@ vimperator.Completion = function () // {{{
|
|||||||
filtered.push(urls[i]);
|
filtered.push(urls[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return filtered.concat(additional_completions);
|
return filtered.concat(additionalCompletions);
|
||||||
}, //}}}
|
}, //}}}
|
||||||
|
|
||||||
// generic helper function which checks if the given "items" array pass "filter"
|
// generic helper function which checks if the given "items" array pass "filter"
|
||||||
// items must be an array of strings
|
// items must be an array of strings
|
||||||
match: function (items, filter, case_sensitive)
|
match: function (items, filter, caseSensitive)
|
||||||
{
|
{
|
||||||
if (typeof filter != "string" || !items)
|
if (typeof filter != "string" || !items)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var items_str = items.join(" ");
|
var itemsStr = items.join(" ");
|
||||||
if (!case_sensitive)
|
if (!caseSensitive)
|
||||||
{
|
{
|
||||||
filter = filter.toLowerCase();
|
filter = filter.toLowerCase();
|
||||||
items_str = items_str.toLowerCase();
|
itemsStr = itemsStr.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter.split(/\s+/).every(function (str) { return items_str.indexOf(str) > -1; }))
|
if (filter.split(/\s+/).every(function (str) { return itemsStr.indexOf(str) > -1; }))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -616,7 +616,7 @@ vimperator.Completion = function () // {{{
|
|||||||
var matches = str.match(/^(:*\d*)\w*$/);
|
var matches = str.match(/^(:*\d*)\w*$/);
|
||||||
if (matches)
|
if (matches)
|
||||||
{
|
{
|
||||||
completions = this.get_command_completions(cmd);
|
completions = this.getCommandCompletions(cmd);
|
||||||
start = matches[1].length;
|
start = matches[1].length;
|
||||||
}
|
}
|
||||||
else // dynamically get completions as specified with the command's completer function
|
else // dynamically get completions as specified with the command's completer function
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ the terms of any one of the MPL, the GPL or the LGPL.
|
|||||||
vimperator.Editor = function () //{{{
|
vimperator.Editor = function () //{{{
|
||||||
{
|
{
|
||||||
// store our last search with f, F, t or T
|
// store our last search with f, F, t or T
|
||||||
var last_findChar = null;
|
var lastFindChar = null;
|
||||||
var last_findChar_func = null;
|
var lastFindCharFunc = null;
|
||||||
var abbrev = {}; // abbrev["lhr"][0]["{i,c,!}","rhs"]
|
var abbrev = {}; // abbrev["lhr"][0]["{i,c,!}","rhs"]
|
||||||
|
|
||||||
function editor()
|
function editor()
|
||||||
@@ -120,7 +120,7 @@ vimperator.Editor = function () //{{{
|
|||||||
if (typeof count != "number" || count < 1)
|
if (typeof count != "number" || count < 1)
|
||||||
count = 1;
|
count = 1;
|
||||||
|
|
||||||
var did_command = false;
|
var didCommand = false;
|
||||||
while (count--)
|
while (count--)
|
||||||
{
|
{
|
||||||
// some commands need this try/catch workaround, because a cmd_charPrevious triggered
|
// some commands need this try/catch workaround, because a cmd_charPrevious triggered
|
||||||
@@ -129,11 +129,11 @@ vimperator.Editor = function () //{{{
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
controller.doCommand(cmd);
|
controller.doCommand(cmd);
|
||||||
did_command = true;
|
didCommand = true;
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
if (!did_command)
|
if (!didCommand)
|
||||||
vimperator.beep();
|
vimperator.beep();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -269,8 +269,8 @@ vimperator.Editor = function () //{{{
|
|||||||
if (!editor())
|
if (!editor())
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
last_findChar = ch;
|
lastFindChar = ch;
|
||||||
last_findChar_func = this.findCharForward;
|
lastFindCharFunc = this.findCharForward;
|
||||||
|
|
||||||
var text = editor().value;
|
var text = editor().value;
|
||||||
if (!typeof count == "number" || count < 1)
|
if (!typeof count == "number" || count < 1)
|
||||||
@@ -296,8 +296,8 @@ vimperator.Editor = function () //{{{
|
|||||||
if (!editor())
|
if (!editor())
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
last_findChar = ch;
|
lastFindChar = ch;
|
||||||
last_findChar_func = this.findCharBackward;
|
lastFindCharFunc = this.findCharBackward;
|
||||||
|
|
||||||
var text = editor().value;
|
var text = editor().value;
|
||||||
if (!typeof count == "number" || count < 1)
|
if (!typeof count == "number" || count < 1)
|
||||||
@@ -630,11 +630,11 @@ vimperator.Editor = function () //{{{
|
|||||||
{
|
{
|
||||||
// if found, replace accordingly
|
// if found, replace accordingly
|
||||||
var len = foundWord.length;
|
var len = foundWord.length;
|
||||||
var abbr_text = abbrev[lhs][i][1];
|
var abbrText = abbrev[lhs][i][1];
|
||||||
text = text.substring(0, currStart - len) + abbr_text + text.substring(currStart);
|
text = text.substring(0, currStart - len) + abbrText + text.substring(currStart);
|
||||||
textbox.value = text;
|
textbox.value = text;
|
||||||
textbox.selectionStart = currStart - len + abbr_text.length;
|
textbox.selectionStart = currStart - len + abbrText.length;
|
||||||
textbox.selectionEnd = currEnd - len + abbr_text.length;
|
textbox.selectionEnd = currEnd - len + abbrText.length;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ vimperator.Events = function () //{{{
|
|||||||
|
|
||||||
/////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////
|
||||||
// track if a popup is open or the menubar is active
|
// track if a popup is open or the menubar is active
|
||||||
var active_menubar = false;
|
var activeMenubar = false;
|
||||||
function enterPopupMode(event)
|
function enterPopupMode(event)
|
||||||
{
|
{
|
||||||
if (event.originalTarget.localName == "tooltip" || event.originalTarget.id == "vimperator-visualbell")
|
if (event.originalTarget.localName == "tooltip" || event.originalTarget.id == "vimperator-visualbell")
|
||||||
@@ -89,17 +89,17 @@ vimperator.Events = function () //{{{
|
|||||||
function exitPopupMode()
|
function exitPopupMode()
|
||||||
{
|
{
|
||||||
// gContextMenu is set to NULL by firefox, when a context menu is closed
|
// gContextMenu is set to NULL by firefox, when a context menu is closed
|
||||||
if (!gContextMenu && !active_menubar)
|
if (!gContextMenu && !activeMenubar)
|
||||||
vimperator.modes.remove(vimperator.modes.MENU);
|
vimperator.modes.remove(vimperator.modes.MENU);
|
||||||
}
|
}
|
||||||
function enterMenuMode()
|
function enterMenuMode()
|
||||||
{
|
{
|
||||||
active_menubar = true;
|
activeMenubar = true;
|
||||||
vimperator.modes.add(vimperator.modes.MENU);
|
vimperator.modes.add(vimperator.modes.MENU);
|
||||||
}
|
}
|
||||||
function exitMenuMode()
|
function exitMenuMode()
|
||||||
{
|
{
|
||||||
active_menubar = false;
|
activeMenubar = false;
|
||||||
vimperator.modes.remove(vimperator.modes.MENU);
|
vimperator.modes.remove(vimperator.modes.MENU);
|
||||||
}
|
}
|
||||||
window.addEventListener("popupshown", enterPopupMode, true);
|
window.addEventListener("popupshown", enterPopupMode, true);
|
||||||
@@ -468,14 +468,14 @@ vimperator.Events = function () //{{{
|
|||||||
|
|
||||||
onSelectionChange: function (event)
|
onSelectionChange: function (event)
|
||||||
{
|
{
|
||||||
var could_copy = false;
|
var couldCopy = false;
|
||||||
var controller = document.commandDispatcher.getControllerForCommand("cmd_copy");
|
var controller = document.commandDispatcher.getControllerForCommand("cmd_copy");
|
||||||
if (controller && controller.isCommandEnabled("cmd_copy"))
|
if (controller && controller.isCommandEnabled("cmd_copy"))
|
||||||
could_copy = true;
|
couldCopy = true;
|
||||||
|
|
||||||
if (vimperator.mode != vimperator.modes.VISUAL)
|
if (vimperator.mode != vimperator.modes.VISUAL)
|
||||||
{
|
{
|
||||||
if (could_copy)
|
if (couldCopy)
|
||||||
{
|
{
|
||||||
if ((vimperator.mode == vimperator.modes.TEXTAREA || (vimperator.modes.extended & vimperator.modes.TEXTAREA))
|
if ((vimperator.mode == vimperator.modes.TEXTAREA || (vimperator.modes.extended & vimperator.modes.TEXTAREA))
|
||||||
&& !vimperator.options["insertmode"])
|
&& !vimperator.options["insertmode"])
|
||||||
@@ -486,7 +486,7 @@ vimperator.Events = function () //{{{
|
|||||||
}
|
}
|
||||||
//else
|
//else
|
||||||
//{
|
//{
|
||||||
// if (!could_copy && vimperator.modes.extended & vimperator.modes.CARET)
|
// if (!couldCopy && vimperator.modes.extended & vimperator.modes.CARET)
|
||||||
// vimperator.mode = vimperator.modes.CARET;
|
// vimperator.mode = vimperator.modes.CARET;
|
||||||
//}
|
//}
|
||||||
},
|
},
|
||||||
@@ -642,13 +642,13 @@ vimperator.Events = function () //{{{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var count_str = vimperator.input.buffer.match(/^[0-9]*/)[0];
|
var countStr = vimperator.input.buffer.match(/^[0-9]*/)[0];
|
||||||
var candidate_command = (vimperator.input.buffer + key).replace(count_str, "");
|
var candidateCommand = (vimperator.input.buffer + key).replace(countStr, "");
|
||||||
var map;
|
var map;
|
||||||
if (event.noremap)
|
if (event.noremap)
|
||||||
map = vimperator.mappings.getDefaultMap(vimperator.mode, candidate_command);
|
map = vimperator.mappings.getDefaultMap(vimperator.mode, candidateCommand);
|
||||||
else
|
else
|
||||||
map = vimperator.mappings.get(vimperator.mode, candidate_command);
|
map = vimperator.mappings.get(vimperator.mode, candidateCommand);
|
||||||
|
|
||||||
// counts must be at the start of a complete mapping (10j -> go 10 lines down)
|
// counts must be at the start of a complete mapping (10j -> go 10 lines down)
|
||||||
if (/^[1-9][0-9]*$/.test(vimperator.input.buffer + key))
|
if (/^[1-9][0-9]*$/.test(vimperator.input.buffer + key))
|
||||||
@@ -670,7 +670,7 @@ vimperator.Events = function () //{{{
|
|||||||
}
|
}
|
||||||
else if (map)
|
else if (map)
|
||||||
{
|
{
|
||||||
vimperator.input.count = parseInt(count_str, 10);
|
vimperator.input.count = parseInt(countStr, 10);
|
||||||
if (isNaN(vimperator.input.count))
|
if (isNaN(vimperator.input.count))
|
||||||
vimperator.input.count = -1;
|
vimperator.input.count = -1;
|
||||||
if (map.flags & vimperator.Mappings.flags.ARGUMENT)
|
if (map.flags & vimperator.Mappings.flags.ARGUMENT)
|
||||||
@@ -682,7 +682,7 @@ vimperator.Events = function () //{{{
|
|||||||
{
|
{
|
||||||
if (key != "<Esc>" && key != "<C-[>")
|
if (key != "<Esc>" && key != "<C-[>")
|
||||||
{
|
{
|
||||||
vimperator.input.pendingMotionMap.execute(candidate_command, vimperator.input.count, null);
|
vimperator.input.pendingMotionMap.execute(candidateCommand, vimperator.input.count, null);
|
||||||
}
|
}
|
||||||
vimperator.input.pendingMotionMap = null;
|
vimperator.input.pendingMotionMap = null;
|
||||||
vimperator.input.buffer = "";
|
vimperator.input.buffer = "";
|
||||||
@@ -701,7 +701,7 @@ vimperator.Events = function () //{{{
|
|||||||
stop = false;
|
stop = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (vimperator.mappings.getCandidates(vimperator.mode, candidate_command).length > 0)
|
else if (vimperator.mappings.getCandidates(vimperator.mode, candidateCommand).length > 0)
|
||||||
{
|
{
|
||||||
vimperator.input.buffer += key;
|
vimperator.input.buffer += key;
|
||||||
}
|
}
|
||||||
@@ -729,8 +729,8 @@ vimperator.Events = function () //{{{
|
|||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
}
|
}
|
||||||
|
|
||||||
var motion_map = (vimperator.input.pendingMotionMap && vimperator.input.pendingMotionMap.names[0]) || "";
|
var motionMap = (vimperator.input.pendingMotionMap && vimperator.input.pendingMotionMap.names[0]) || "";
|
||||||
vimperator.statusline.updateInputBuffer(motion_map + vimperator.input.buffer);
|
vimperator.statusline.updateInputBuffer(motionMap + vimperator.input.buffer);
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -40,16 +40,16 @@ the terms of any one of the MPL, the GPL or the LGPL.
|
|||||||
vimperator.Search = function () //{{{
|
vimperator.Search = function () //{{{
|
||||||
{
|
{
|
||||||
// FIXME:
|
// FIXME:
|
||||||
//var self = this; // needed for callbacks since "this" is the "vimperator" object in a callback
|
//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 searchString = ""; // current search string (without modifiers)
|
||||||
var search_pattern = ""; // current search string (includes modifiers)
|
var searchPattern = ""; // current search string (includes modifiers)
|
||||||
var last_search_pattern = ""; // the last searched pattern (includes modifiers)
|
var lastSearchPattern = ""; // the last searched pattern (includes modifiers)
|
||||||
var last_search_string = ""; // the last searched string (without modifiers)
|
var lastSearchString = ""; // the last searched string (without modifiers)
|
||||||
var last_search_backwards = false; // like "backwards", but for the last search, so if you cancel a search with <esc> this is not set
|
var lastSearchBackwards = false; // like "backwards", but for the last search, so if you cancel a search with <esc> this is not set
|
||||||
var case_sensitive = false; // search string is case sensitive
|
var caseSensitive = false; // search string is case sensitive
|
||||||
var links_only = false; // search is limited to link text only
|
var linksOnly = 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) { vimperator.search.searchKeyPressed(command); });
|
vimperator.registerCallback("change", vimperator.modes.SEARCH_FORWARD, function (command) { vimperator.search.searchKeyPressed(command); });
|
||||||
@@ -60,7 +60,7 @@ vimperator.Search = function () //{{{
|
|||||||
vimperator.registerCallback("submit", vimperator.modes.SEARCH_BACKWARD, function (command) { vimperator.search.searchSubmitted(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(); });
|
vimperator.registerCallback("cancel", vimperator.modes.SEARCH_BACKWARD, function () { vimperator.search.searchCanceled(); });
|
||||||
|
|
||||||
// set search_string, search_pattern, case_sensitive, links_only
|
// set searchString, searchPattern, caseSensitive, linksOnly
|
||||||
function processUserPattern(pattern)
|
function processUserPattern(pattern)
|
||||||
{
|
{
|
||||||
// strip off pattern terminator and offset
|
// strip off pattern terminator and offset
|
||||||
@@ -69,32 +69,32 @@ vimperator.Search = function () //{{{
|
|||||||
else
|
else
|
||||||
pattern = pattern.replace(/\/.*/, "");
|
pattern = pattern.replace(/\/.*/, "");
|
||||||
|
|
||||||
search_pattern = pattern;
|
searchPattern = pattern;
|
||||||
|
|
||||||
// links only search - \l wins if both modifiers specified
|
// links only search - \l wins if both modifiers specified
|
||||||
if (/\\l/.test(pattern))
|
if (/\\l/.test(pattern))
|
||||||
links_only = false;
|
linksOnly = false;
|
||||||
else if (/\L/.test(pattern))
|
else if (/\L/.test(pattern))
|
||||||
links_only = true;
|
linksOnly = true;
|
||||||
else if (vimperator.options["linksearch"])
|
else if (vimperator.options["linksearch"])
|
||||||
links_only = true;
|
linksOnly = true;
|
||||||
else
|
else
|
||||||
links_only = false;
|
linksOnly = false;
|
||||||
|
|
||||||
// strip links-only modifiers
|
// strip links-only modifiers
|
||||||
pattern = pattern.replace(/(\\)?\\[lL]/g, function ($0, $1) { return $1 ? $0 : ""; });
|
pattern = pattern.replace(/(\\)?\\[lL]/g, function ($0, $1) { return $1 ? $0 : ""; });
|
||||||
|
|
||||||
// case sensitivity - \c wins if both modifiers specified
|
// case sensitivity - \c wins if both modifiers specified
|
||||||
if (/\c/.test(pattern))
|
if (/\c/.test(pattern))
|
||||||
case_sensitive = false;
|
caseSensitive = false;
|
||||||
else if (/\C/.test(pattern))
|
else if (/\C/.test(pattern))
|
||||||
case_sensitive = true;
|
caseSensitive = true;
|
||||||
else if (vimperator.options["ignorecase"] && vimperator.options["smartcase"] && /[A-Z]/.test(pattern))
|
else if (vimperator.options["ignorecase"] && vimperator.options["smartcase"] && /[A-Z]/.test(pattern))
|
||||||
case_sensitive = true;
|
caseSensitive = true;
|
||||||
else if (vimperator.options["ignorecase"])
|
else if (vimperator.options["ignorecase"])
|
||||||
case_sensitive = false;
|
caseSensitive = false;
|
||||||
else
|
else
|
||||||
case_sensitive = true;
|
caseSensitive = true;
|
||||||
|
|
||||||
// strip case-sensitive modifiers
|
// strip case-sensitive modifiers
|
||||||
pattern = pattern.replace(/(\\)?\\[cC]/g, function ($0, $1) { return $1 ? $0 : ""; });
|
pattern = pattern.replace(/(\\)?\\[cC]/g, function ($0, $1) { return $1 ? $0 : ""; });
|
||||||
@@ -102,7 +102,7 @@ vimperator.Search = function () //{{{
|
|||||||
// remove any modifer escape \
|
// remove any modifer escape \
|
||||||
pattern = pattern.replace(/\\(\\[cClL])/g, "$1");
|
pattern = pattern.replace(/\\(\\[cClL])/g, "$1");
|
||||||
|
|
||||||
search_string = pattern;
|
searchString = pattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -133,11 +133,11 @@ vimperator.Search = function () //{{{
|
|||||||
|
|
||||||
processUserPattern(str);
|
processUserPattern(str);
|
||||||
|
|
||||||
fastFind.caseSensitive = case_sensitive;
|
fastFind.caseSensitive = caseSensitive;
|
||||||
found = fastFind.find(search_string, links_only) != Components.interfaces.nsITypeAheadFind.FIND_NOTFOUND;
|
found = fastFind.find(searchString, linksOnly) != Components.interfaces.nsITypeAheadFind.FIND_NOTFOUND;
|
||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
vimperator.echoerr("E486: Pattern not found: " + search_pattern);
|
vimperator.echoerr("E486: Pattern not found: " + searchPattern);
|
||||||
|
|
||||||
return found;
|
return found;
|
||||||
},
|
},
|
||||||
@@ -148,15 +148,15 @@ vimperator.Search = function () //{{{
|
|||||||
// 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
|
||||||
// readonly we have to call find() again to update it.
|
// readonly we have to call find() again to update it.
|
||||||
if (getBrowser().fastFind.searchString != last_search_string)
|
if (getBrowser().fastFind.searchString != lastSearchString)
|
||||||
this.find(last_search_string, false);
|
this.find(lastSearchString, false);
|
||||||
|
|
||||||
var up = reverse ? !last_search_backwards : last_search_backwards;
|
var up = reverse ? !lastSearchBackwards : lastSearchBackwards;
|
||||||
var result = getBrowser().fastFind.findAgain(up, links_only);
|
var result = getBrowser().fastFind.findAgain(up, linksOnly);
|
||||||
|
|
||||||
if (result == Components.interfaces.nsITypeAheadFind.FIND_NOTFOUND)
|
if (result == Components.interfaces.nsITypeAheadFind.FIND_NOTFOUND)
|
||||||
{
|
{
|
||||||
vimperator.echoerr("E486: Pattern not found: " + last_search_pattern);
|
vimperator.echoerr("E486: Pattern not found: " + lastSearchPattern);
|
||||||
}
|
}
|
||||||
else if (result == Components.interfaces.nsITypeAheadFind.FIND_WRAPPED)
|
else if (result == Components.interfaces.nsITypeAheadFind.FIND_WRAPPED)
|
||||||
{
|
{
|
||||||
@@ -171,10 +171,10 @@ vimperator.Search = function () //{{{
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vimperator.echo((up ? "?" : "/") + last_search_pattern, null, vimperator.commandline.FORCE_SINGLELINE);
|
vimperator.echo((up ? "?" : "/") + lastSearchPattern, null, vimperator.commandline.FORCE_SINGLELINE);
|
||||||
|
|
||||||
if (vimperator.options["hlsearch"])
|
if (vimperator.options["hlsearch"])
|
||||||
this.highlight(last_search_string);
|
this.highlight(lastSearchString);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -186,22 +186,22 @@ vimperator.Search = function () //{{{
|
|||||||
},
|
},
|
||||||
|
|
||||||
// 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 forcedBackward if you call this function directly
|
||||||
searchSubmitted: function (command, forced_backward)
|
searchSubmitted: function (command, forcedBackward)
|
||||||
{
|
{
|
||||||
if (typeof forced_backward === "boolean")
|
if (typeof forcedBackward === "boolean")
|
||||||
backwards = forced_backward;
|
backwards = forcedBackward;
|
||||||
|
|
||||||
// use the last pattern if none specified
|
// use the last pattern if none specified
|
||||||
if (!command)
|
if (!command)
|
||||||
command = last_search_pattern;
|
command = lastSearchPattern;
|
||||||
|
|
||||||
this.clear();
|
this.clear();
|
||||||
this.find(command, backwards);
|
this.find(command, backwards);
|
||||||
|
|
||||||
last_search_backwards = backwards;
|
lastSearchBackwards = backwards;
|
||||||
last_search_pattern = command.replace(backwards ? /\?.*/ : /\/.*/, ""); // XXX
|
lastSearchPattern = command.replace(backwards ? /\?.*/ : /\/.*/, ""); // XXX
|
||||||
last_search_string = search_string;
|
lastSearchString = searchString;
|
||||||
|
|
||||||
// TODO: move to find() when reverse incremental searching is kludged in
|
// TODO: move to find() when reverse incremental searching is kludged in
|
||||||
// need to find again for reverse searching
|
// need to find again for reverse searching
|
||||||
@@ -209,7 +209,7 @@ vimperator.Search = function () //{{{
|
|||||||
setTimeout(function () { self.findAgain(false); }, 0);
|
setTimeout(function () { self.findAgain(false); }, 0);
|
||||||
|
|
||||||
if (vimperator.options["hlsearch"])
|
if (vimperator.options["hlsearch"])
|
||||||
this.highlight(search_string);
|
this.highlight(searchString);
|
||||||
|
|
||||||
vimperator.modes.reset();
|
vimperator.modes.reset();
|
||||||
},
|
},
|
||||||
@@ -230,9 +230,9 @@ vimperator.Search = function () //{{{
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (!text)
|
if (!text)
|
||||||
text = last_search_string;
|
text = lastSearchString;
|
||||||
|
|
||||||
gFindBar._setCaseSensitivity(case_sensitive);
|
gFindBar._setCaseSensitivity(caseSensitive);
|
||||||
gFindBar._highlightDoc("white", "black", text);
|
gFindBar._highlightDoc("white", "black", text);
|
||||||
|
|
||||||
// TODO: seems fast enough for now...just
|
// TODO: seems fast enough for now...just
|
||||||
@@ -246,7 +246,7 @@ vimperator.Search = function () //{{{
|
|||||||
})(window.content);
|
})(window.content);
|
||||||
|
|
||||||
// recreate selection since _highlightDoc collapses the selection backwards
|
// recreate selection since _highlightDoc collapses the selection backwards
|
||||||
getBrowser().fastFind.findAgain(false, links_only);
|
getBrowser().fastFind.findAgain(false, linksOnly);
|
||||||
|
|
||||||
// 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"])
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -72,10 +72,10 @@ vimperator.help = function (section, easter) //{{{
|
|||||||
ret += '</td><td valign="top">';
|
ret += '</td><td valign="top">';
|
||||||
|
|
||||||
// the actual help text with the first line in bold
|
// the actual help text with the first line in bold
|
||||||
if (command.short_help)
|
if (command.shortHelp)
|
||||||
{
|
{
|
||||||
ret += '<span class="shorthelp">';
|
ret += '<span class="shorthelp">';
|
||||||
ret += command.short_help; // the help description
|
ret += command.shortHelp; // the help description
|
||||||
ret += "</span><br/>";
|
ret += "</span><br/>";
|
||||||
if (func) // for options we print default values here, e.g.
|
if (func) // for options we print default values here, e.g.
|
||||||
{
|
{
|
||||||
@@ -95,9 +95,9 @@ vimperator.help = function (section, easter) //{{{
|
|||||||
var names = command.names;
|
var names = command.names;
|
||||||
for (var j=0; j < names.length; j++)
|
for (var j=0; j < names.length; j++)
|
||||||
{
|
{
|
||||||
var cmd_name = names[j];
|
var cmdName = names[j];
|
||||||
cmd_name = vimperator.util.escapeHTML(cmd_name);
|
cmdName = vimperator.util.escapeHTML(cmdName);
|
||||||
ret += '<code class="tag">' + beg + cmd_name + end + '</code><br/>';
|
ret += '<code class="tag">' + beg + cmdName + end + '</code><br/>';
|
||||||
}
|
}
|
||||||
ret += '</td></tr>';
|
ret += '</td></tr>';
|
||||||
|
|
||||||
@@ -114,17 +114,17 @@ vimperator.help = function (section, easter) //{{{
|
|||||||
ret = command.type + ' (default: ';
|
ret = command.type + ' (default: ';
|
||||||
if (command.type == "boolean")
|
if (command.type == "boolean")
|
||||||
{
|
{
|
||||||
if (command.default_value == true)
|
if (command.defaultValue == true)
|
||||||
ret += "on";
|
ret += "on";
|
||||||
else
|
else
|
||||||
ret += "off";
|
ret += "off";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (typeof command.default_value == "string" && command.default_value.length == 0)
|
if (typeof command.defaultValue == "string" && command.defaultValue.length == 0)
|
||||||
ret += "''";
|
ret += "''";
|
||||||
else
|
else
|
||||||
ret += command.default_value;
|
ret += command.defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret += ")<br/>";
|
ret += ")<br/>";
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ vimperator.Hints = function () //{{{
|
|||||||
|
|
||||||
// hints[] = [elem, text, span, imgspan, elem.style.backgroundColor, elem.style.color]
|
// hints[] = [elem, text, span, imgspan, elem.style.backgroundColor, elem.style.color]
|
||||||
var hints = [];
|
var hints = [];
|
||||||
var valid_hints = []; // store the indices of the "hints" array with valid elements
|
var validHints = []; // store the indices of the "hints" array with valid elements
|
||||||
|
|
||||||
var escapeNumbers = false ; // escape mode for numbers. true -> treated as hint-text
|
var escapeNumbers = false ; // escape mode for numbers. true -> treated as hint-text
|
||||||
var activeTimeout = null; // needed for hinttimeout > 0
|
var activeTimeout = null; // needed for hinttimeout > 0
|
||||||
@@ -57,7 +57,7 @@ vimperator.Hints = function () //{{{
|
|||||||
hintNumber = 0;
|
hintNumber = 0;
|
||||||
usedTabKey = false;
|
usedTabKey = false;
|
||||||
hints = [];
|
hints = [];
|
||||||
valid_hints = [];
|
validHints = [];
|
||||||
canUpdate = false;
|
canUpdate = false;
|
||||||
docs = [];
|
docs = [];
|
||||||
escapeNumbers = false;
|
escapeNumbers = false;
|
||||||
@@ -78,11 +78,11 @@ vimperator.Hints = function () //{{{
|
|||||||
// for javascript links
|
// for javascript links
|
||||||
function openHint(where)
|
function openHint(where)
|
||||||
{
|
{
|
||||||
if (valid_hints.length < 1)
|
if (validHints.length < 1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var x = 1, y = 1;
|
var x = 1, y = 1;
|
||||||
var elem = valid_hints[hintNumber - 1] || valid_hints[0];
|
var elem = validHints[hintNumber - 1] || validHints[0];
|
||||||
var elemTagName = elem.localName.toLowerCase();
|
var elemTagName = elem.localName.toLowerCase();
|
||||||
elem.focus();
|
elem.focus();
|
||||||
if (elemTagName == "frame" || elemTagName == "iframe")
|
if (elemTagName == "frame" || elemTagName == "iframe")
|
||||||
@@ -102,10 +102,10 @@ vimperator.Hints = function () //{{{
|
|||||||
|
|
||||||
function focusHint()
|
function focusHint()
|
||||||
{
|
{
|
||||||
if (valid_hints.length < 1)
|
if (validHints.length < 1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var elem = valid_hints[hintNumber - 1] || valid_hints[0];
|
var elem = validHints[hintNumber - 1] || validHints[0];
|
||||||
var doc = window.content.document;
|
var doc = window.content.document;
|
||||||
var elemTagName = elem.localName.toLowerCase();
|
var elemTagName = elem.localName.toLowerCase();
|
||||||
if (elemTagName == "frame" || elemTagName == "iframe")
|
if (elemTagName == "frame" || elemTagName == "iframe")
|
||||||
@@ -135,10 +135,10 @@ vimperator.Hints = function () //{{{
|
|||||||
|
|
||||||
function yankHint(text)
|
function yankHint(text)
|
||||||
{
|
{
|
||||||
if (valid_hints.length < 1)
|
if (validHints.length < 1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var elem = valid_hints[hintNumber - 1] || valid_hints[0];
|
var elem = validHints[hintNumber - 1] || validHints[0];
|
||||||
if (text)
|
if (text)
|
||||||
var loc = elem.textContent;
|
var loc = elem.textContent;
|
||||||
else
|
else
|
||||||
@@ -148,12 +148,12 @@ vimperator.Hints = function () //{{{
|
|||||||
vimperator.echo("Yanked " + loc, vimperator.commandline.FORCE_SINGLELINE);
|
vimperator.echo("Yanked " + loc, vimperator.commandline.FORCE_SINGLELINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveHint(skip_prompt)
|
function saveHint(skipPrompt)
|
||||||
{
|
{
|
||||||
if (valid_hints.length < 1)
|
if (validHints.length < 1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var elem = valid_hints[hintNumber - 1] || valid_hints[0];
|
var elem = validHints[hintNumber - 1] || validHints[0];
|
||||||
var doc = elem.ownerDocument;
|
var doc = elem.ownerDocument;
|
||||||
var url = makeURLAbsolute(elem.baseURI, elem.href);
|
var url = makeURLAbsolute(elem.baseURI, elem.href);
|
||||||
var text = elem.textContent;
|
var text = elem.textContent;
|
||||||
@@ -161,7 +161,7 @@ vimperator.Hints = function () //{{{
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
urlSecurityCheck(url, doc.nodePrincipal);
|
urlSecurityCheck(url, doc.nodePrincipal);
|
||||||
saveURL(url, text, null, true, skip_prompt, makeURI(url, doc.characterSet));
|
saveURL(url, text, null, true, skipPrompt, makeURI(url, doc.characterSet));
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
@@ -247,11 +247,11 @@ vimperator.Hints = function () //{{{
|
|||||||
// TODO: make it aware of imgspans
|
// TODO: make it aware of imgspans
|
||||||
function showActiveHint(newID, oldID)
|
function showActiveHint(newID, oldID)
|
||||||
{
|
{
|
||||||
var oldElem = valid_hints[oldID - 1];
|
var oldElem = validHints[oldID - 1];
|
||||||
if (oldElem)
|
if (oldElem)
|
||||||
oldElem.style.backgroundColor = "yellow";
|
oldElem.style.backgroundColor = "yellow";
|
||||||
|
|
||||||
var newElem = valid_hints[newID - 1];
|
var newElem = validHints[newID - 1];
|
||||||
if (newElem)
|
if (newElem)
|
||||||
newElem.style.backgroundColor = "#88FF00";
|
newElem.style.backgroundColor = "#88FF00";
|
||||||
}
|
}
|
||||||
@@ -267,9 +267,9 @@ vimperator.Hints = function () //{{{
|
|||||||
|
|
||||||
var elem, tagname, text, rect, span, imgspan;
|
var elem, tagname, text, rect, span, imgspan;
|
||||||
var hintnum = 1;
|
var hintnum = 1;
|
||||||
var find_tokens = hintString.split(/ +/);
|
var findTokens = hintString.split(/ +/);
|
||||||
var activeHint = hintNumber || 1;
|
var activeHint = hintNumber || 1;
|
||||||
valid_hints = [];
|
validHints = [];
|
||||||
|
|
||||||
for (var j = 0; j < docs.length; j++)
|
for (var j = 0; j < docs.length; j++)
|
||||||
{
|
{
|
||||||
@@ -287,9 +287,9 @@ vimperator.Hints = function () //{{{
|
|||||||
span = hints[i][2];
|
span = hints[i][2];
|
||||||
imgspan = hints[i][3];
|
imgspan = hints[i][3];
|
||||||
|
|
||||||
for (var k = 0; k < find_tokens.length; k++)
|
for (var k = 0; k < findTokens.length; k++)
|
||||||
{
|
{
|
||||||
if (text.indexOf(find_tokens[k]) < 0)
|
if (text.indexOf(findTokens[k]) < 0)
|
||||||
{
|
{
|
||||||
span.style.display = "none";
|
span.style.display = "none";
|
||||||
if (imgspan)
|
if (imgspan)
|
||||||
@@ -331,7 +331,7 @@ vimperator.Hints = function () //{{{
|
|||||||
elem.style.color = "black";
|
elem.style.color = "black";
|
||||||
span.textContent = "" + (hintnum++);
|
span.textContent = "" + (hintnum++);
|
||||||
span.style.display = "inline";
|
span.style.display = "inline";
|
||||||
valid_hints.push(elem);
|
validHints.push(elem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -341,7 +341,7 @@ vimperator.Hints = function () //{{{
|
|||||||
|
|
||||||
function removeHints(timeout)
|
function removeHints(timeout)
|
||||||
{
|
{
|
||||||
var firstElem = valid_hints[0] || null;
|
var firstElem = validHints[0] || null;
|
||||||
var firstElemBgColor = "";
|
var firstElemBgColor = "";
|
||||||
var firstElemColor = "";
|
var firstElemColor = "";
|
||||||
|
|
||||||
@@ -411,7 +411,7 @@ vimperator.Hints = function () //{{{
|
|||||||
|
|
||||||
function processHints(followFirst)
|
function processHints(followFirst)
|
||||||
{
|
{
|
||||||
if (valid_hints.length == 0)
|
if (validHints.length == 0)
|
||||||
{
|
{
|
||||||
vimperator.beep();
|
vimperator.beep();
|
||||||
return false;
|
return false;
|
||||||
@@ -419,18 +419,18 @@ vimperator.Hints = function () //{{{
|
|||||||
|
|
||||||
if (!followFirst)
|
if (!followFirst)
|
||||||
{
|
{
|
||||||
var first_href = valid_hints[0].getAttribute("href") || null;
|
var firstHref = validHints[0].getAttribute("href") || null;
|
||||||
if (first_href)
|
if (firstHref)
|
||||||
{
|
{
|
||||||
if (valid_hints.some(function (e) { return e.getAttribute("href") != first_href; }))
|
if (validHints.some(function (e) { return e.getAttribute("href") != firstHref; }))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (valid_hints.length > 1)
|
else if (validHints.length > 1)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var activeNum = hintNumber || 1;
|
var activeNum = hintNumber || 1;
|
||||||
var loc = valid_hints[activeNum - 1].href || "";
|
var loc = validHints[activeNum - 1].href || "";
|
||||||
switch (submode)
|
switch (submode)
|
||||||
{
|
{
|
||||||
case ";": focusHint(); break;
|
case ";": focusHint(); break;
|
||||||
@@ -502,13 +502,13 @@ vimperator.Hints = function () //{{{
|
|||||||
canUpdate = true;
|
canUpdate = true;
|
||||||
showHints();
|
showHints();
|
||||||
|
|
||||||
if (valid_hints.length == 0)
|
if (validHints.length == 0)
|
||||||
{
|
{
|
||||||
vimperator.beep();
|
vimperator.beep();
|
||||||
vimperator.modes.reset();
|
vimperator.modes.reset();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (valid_hints.length == 1)
|
else if (validHints.length == 1)
|
||||||
{
|
{
|
||||||
processHints(true);
|
processHints(true);
|
||||||
return false;
|
return false;
|
||||||
@@ -554,13 +554,13 @@ vimperator.Hints = function () //{{{
|
|||||||
var oldID = hintNumber;
|
var oldID = hintNumber;
|
||||||
if (key == "<Tab>")
|
if (key == "<Tab>")
|
||||||
{
|
{
|
||||||
if (++hintNumber > valid_hints.length)
|
if (++hintNumber > validHints.length)
|
||||||
hintNumber = 1;
|
hintNumber = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (--hintNumber < 1)
|
if (--hintNumber < 1)
|
||||||
hintNumber = valid_hints.length;
|
hintNumber = validHints.length;
|
||||||
}
|
}
|
||||||
showActiveHint(hintNumber, oldID);
|
showActiveHint(hintNumber, oldID);
|
||||||
return;
|
return;
|
||||||
@@ -638,7 +638,7 @@ vimperator.Hints = function () //{{{
|
|||||||
}
|
}
|
||||||
showActiveHint(hintNumber, oldHintNumber || 1);
|
showActiveHint(hintNumber, oldHintNumber || 1);
|
||||||
|
|
||||||
if (hintNumber == 0 || hintNumber > valid_hints.length)
|
if (hintNumber == 0 || hintNumber > validHints.length)
|
||||||
{
|
{
|
||||||
vimperator.beep();
|
vimperator.beep();
|
||||||
return;
|
return;
|
||||||
@@ -646,7 +646,7 @@ vimperator.Hints = function () //{{{
|
|||||||
|
|
||||||
// if we write a numeric part like 3, but we have 45 hints, only follow
|
// if we write a numeric part like 3, but we have 45 hints, only follow
|
||||||
// the hint after a timeout, as the user might have wanted to follow link 34
|
// the hint after a timeout, as the user might have wanted to follow link 34
|
||||||
if (hintNumber > 0 && hintNumber * 10 <= valid_hints.length)
|
if (hintNumber > 0 && hintNumber * 10 <= validHints.length)
|
||||||
{
|
{
|
||||||
var timeout = vimperator.options["hinttimeout"];
|
var timeout = vimperator.options["hinttimeout"];
|
||||||
if (timeout > 0)
|
if (timeout > 0)
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ the terms of any one of the MPL, the GPL or the LGPL.
|
|||||||
|
|
||||||
vimperator.IO = function ()
|
vimperator.IO = function ()
|
||||||
{
|
{
|
||||||
var environment_service = Components.classes["@mozilla.org/process/environment;1"]
|
var environmentService = Components.classes["@mozilla.org/process/environment;1"]
|
||||||
.getService(Components.interfaces.nsIEnvironment);
|
.getService(Components.interfaces.nsIEnvironment);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -54,30 +54,30 @@ vimperator.IO = function ()
|
|||||||
// expand "~" to VIMPERATOR_HOME or HOME (USERPROFILE or HOMEDRIVE\HOMEPATH on Windows if HOME is not set)
|
// expand "~" to VIMPERATOR_HOME or HOME (USERPROFILE or HOMEDRIVE\HOMEPATH on Windows if HOME is not set)
|
||||||
if (/^~/.test(path))
|
if (/^~/.test(path))
|
||||||
{
|
{
|
||||||
var home = environment_service.get("VIMPERATOR_HOME");
|
var home = environmentService.get("VIMPERATOR_HOME");
|
||||||
|
|
||||||
if (!home)
|
if (!home)
|
||||||
home = environment_service.get("HOME");
|
home = environmentService.get("HOME");
|
||||||
|
|
||||||
if (WINDOWS && !home)
|
if (WINDOWS && !home)
|
||||||
home = environment_service.get("USERPROFILE") ||
|
home = environmentService.get("USERPROFILE") ||
|
||||||
environment_service.get("HOMEDRIVE") + environment_service.get("HOMEPATH");
|
environmentService.get("HOMEDRIVE") + environmentService.get("HOMEPATH");
|
||||||
|
|
||||||
path = path.replace("~", home);
|
path = path.replace("~", home);
|
||||||
}
|
}
|
||||||
|
|
||||||
// expand any $ENV vars
|
// expand any $ENV vars
|
||||||
var env_vars = path.match(/\$\w+\b/g); // this is naive but so is Vim and we like to be compatible
|
var envVars = path.match(/\$\w+\b/g); // this is naive but so is Vim and we like to be compatible
|
||||||
|
|
||||||
if (env_vars)
|
if (envVars)
|
||||||
{
|
{
|
||||||
var expansion;
|
var expansion;
|
||||||
|
|
||||||
for (var i = 0; i < env_vars.length; i++)
|
for (var i = 0; i < envVars.length; i++)
|
||||||
{
|
{
|
||||||
expansion = environment_service.get(env_vars[i].replace("$", ""));
|
expansion = environmentService.get(envVars[i].replace("$", ""));
|
||||||
if (expansion)
|
if (expansion)
|
||||||
path = path.replace(env_vars[i], expansion);
|
path = path.replace(envVars[i], expansion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,30 +86,30 @@ vimperator.IO = function ()
|
|||||||
|
|
||||||
getPluginDir: function ()
|
getPluginDir: function ()
|
||||||
{
|
{
|
||||||
var plugin_dir;
|
var pluginDir;
|
||||||
|
|
||||||
if (navigator.platform == "Win32")
|
if (navigator.platform == "Win32")
|
||||||
plugin_dir = "~/vimperator/plugin";
|
pluginDir = "~/vimperator/plugin";
|
||||||
else
|
else
|
||||||
plugin_dir = "~/.vimperator/plugin";
|
pluginDir = "~/.vimperator/plugin";
|
||||||
|
|
||||||
plugin_dir = this.getFile(this.expandPath(plugin_dir));
|
pluginDir = this.getFile(this.expandPath(pluginDir));
|
||||||
|
|
||||||
return plugin_dir.exists() && plugin_dir.isDirectory() ? plugin_dir : null;
|
return pluginDir.exists() && pluginDir.isDirectory() ? pluginDir : null;
|
||||||
},
|
},
|
||||||
|
|
||||||
getRCFile: function ()
|
getRCFile: function ()
|
||||||
{
|
{
|
||||||
var rc_file1 = this.getFile(this.expandPath("~/.vimperatorrc"));
|
var rcFile1 = this.getFile(this.expandPath("~/.vimperatorrc"));
|
||||||
var rc_file2 = this.getFile(this.expandPath("~/_vimperatorrc"));
|
var rcFile2 = this.getFile(this.expandPath("~/_vimperatorrc"));
|
||||||
|
|
||||||
if (navigator.platform == "Win32")
|
if (navigator.platform == "Win32")
|
||||||
[rc_file1, rc_file2] = [rc_file2, rc_file1]
|
[rcFile1, rcFile2] = [rcFile2, rcFile1]
|
||||||
|
|
||||||
if (rc_file1.exists() && rc_file1.isFile())
|
if (rcFile1.exists() && rcFile1.isFile())
|
||||||
return rc_file1;
|
return rcFile1;
|
||||||
else if (rc_file2.exists() && rc_file2.isFile())
|
else if (rcFile2.exists() && rcFile2.isFile())
|
||||||
return rc_file2;
|
return rcFile2;
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
@@ -133,12 +133,12 @@ vimperator.IO = function ()
|
|||||||
createInstance(Components.interfaces.nsILocalFile);
|
createInstance(Components.interfaces.nsILocalFile);
|
||||||
if (navigator.platform == "Win32")
|
if (navigator.platform == "Win32")
|
||||||
{
|
{
|
||||||
var dir = environment_service.get("TMP") || environment_service.get("TEMP") || "C:\\";
|
var dir = environmentService.get("TMP") || environmentService.get("TEMP") || "C:\\";
|
||||||
file.initWithPath(dir + "\\vimperator.tmp");
|
file.initWithPath(dir + "\\vimperator.tmp");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var dir = environment_service.get("TMP") || environment_service.get("TEMP") || "/tmp/";
|
var dir = environmentService.get("TMP") || environmentService.get("TEMP") || "/tmp/";
|
||||||
file.initWithPath(dir + "/vimperator.tmp");
|
file.initWithPath(dir + "/vimperator.tmp");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -75,12 +75,12 @@ vimperator.modes = (function ()
|
|||||||
// Usually you should only indicate to leave a special mode linke HINTS
|
// Usually you should only indicate to leave a special mode linke HINTS
|
||||||
// by calling vimperator.modes.reset() and adding the stuff which is needed
|
// by calling vimperator.modes.reset() and adding the stuff which is needed
|
||||||
// for its cleanup here
|
// for its cleanup here
|
||||||
function handleModeChange(oldmode, newmode)
|
function handleModeChange(oldMode, newMode)
|
||||||
{
|
{
|
||||||
// TODO: fix v.log() to work verbosity level
|
// TODO: fix v.log() to work verbosity level
|
||||||
// vimperator.log("switching from mode " + oldmode + " to mode " + newmode, 7);
|
// vimperator.log("switching from mode " + oldMode + " to mode " + newMode, 7);
|
||||||
|
|
||||||
switch (oldmode)
|
switch (oldMode)
|
||||||
{
|
{
|
||||||
case vimperator.modes.TEXTAREA:
|
case vimperator.modes.TEXTAREA:
|
||||||
case vimperator.modes.INSERT:
|
case vimperator.modes.INSERT:
|
||||||
@@ -88,7 +88,7 @@ vimperator.modes = (function ()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case vimperator.modes.VISUAL:
|
case vimperator.modes.VISUAL:
|
||||||
if (newmode == vimperator.modes.CARET)
|
if (newMode == vimperator.modes.CARET)
|
||||||
{
|
{
|
||||||
// clear any selection made
|
// clear any selection made
|
||||||
var selection = window.content.getSelection();
|
var selection = window.content.getSelection();
|
||||||
@@ -111,7 +111,7 @@ vimperator.modes = (function ()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newmode == vimperator.modes.NORMAL)
|
if (newMode == vimperator.modes.NORMAL)
|
||||||
{
|
{
|
||||||
// XXX: why this code?
|
// XXX: why this code?
|
||||||
var value = vimperator.options.getFirefoxPref("accessibility.browsewithcaret", false);
|
var value = vimperator.options.getFirefoxPref("accessibility.browsewithcaret", false);
|
||||||
@@ -169,21 +169,21 @@ vimperator.modes = (function ()
|
|||||||
|
|
||||||
// helper function to set both modes in one go
|
// helper function to set both modes in one go
|
||||||
// if silent == true, you also need to take care of the mode handling changes yourself
|
// if silent == true, you also need to take care of the mode handling changes yourself
|
||||||
set: function (main_mode, extended_mode, silent)
|
set: function (mainMode, extendedMode, silent)
|
||||||
{
|
{
|
||||||
// if a main mode is set, the extended is always cleared
|
// if a main mode is set, the extended is always cleared
|
||||||
if (typeof main_mode === "number")
|
if (typeof mainMode === "number")
|
||||||
{
|
{
|
||||||
if (!silent && main_mode != main)
|
if (!silent && mainMode != main)
|
||||||
handleModeChange(main, main_mode);
|
handleModeChange(main, mainMode);
|
||||||
|
|
||||||
main = main_mode;
|
main = mainMode;
|
||||||
if (!extended_mode)
|
if (!extendedMode)
|
||||||
extended = vimperator.modes.NONE;
|
extended = vimperator.modes.NONE;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (typeof extended_mode === "number")
|
if (typeof extendedMode === "number")
|
||||||
extended = extended_mode;
|
extended = extendedMode;
|
||||||
|
|
||||||
if (!silent)
|
if (!silent)
|
||||||
this.show();
|
this.show();
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ the provisions above, a recipient may use your version of this file under
|
|||||||
the terms of any one of the MPL, the GPL or the LGPL.
|
the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
}}} ***** END LICENSE BLOCK *****/
|
}}} ***** END LICENSE BLOCK *****/
|
||||||
|
|
||||||
vimperator.Option = function (names, type, extra_info) //{{{
|
vimperator.Option = function (names, type, extraInfo) //{{{
|
||||||
{
|
{
|
||||||
if (!names || !type)
|
if (!names || !type)
|
||||||
return null;
|
return null;
|
||||||
@@ -38,29 +38,29 @@ vimperator.Option = function (names, type, extra_info) //{{{
|
|||||||
this.usage = this.names;
|
this.usage = this.names;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
|
||||||
if (extra_info)
|
if (extraInfo)
|
||||||
{
|
{
|
||||||
if (extra_info.usage)
|
if (extraInfo.usage)
|
||||||
this.usage = extra_info.usage;
|
this.usage = extraInfo.usage;
|
||||||
|
|
||||||
this.help = extra_info.help || null;
|
this.help = extraInfo.help || null;
|
||||||
this.short_help = extra_info.short_help || null;
|
this.shortHelp = extraInfo.shortHelp || null;
|
||||||
|
|
||||||
// "", 0 are valid default values
|
// "", 0 are valid default values
|
||||||
if (extra_info.default_value !== undefined)
|
if (extraInfo.defaultValue !== undefined)
|
||||||
this.default_value = extra_info.default_value;
|
this.defaultValue = extraInfo.defaultValue;
|
||||||
else
|
else
|
||||||
this.default_value = null;
|
this.defaultValue = null;
|
||||||
|
|
||||||
value = this.default_value;
|
value = this.defaultValue;
|
||||||
|
|
||||||
if (extra_info.setter)
|
if (extraInfo.setter)
|
||||||
this.setter = extra_info.setter;
|
this.setter = extraInfo.setter;
|
||||||
if (extra_info.getter)
|
if (extraInfo.getter)
|
||||||
this.getter = extra_info.getter;
|
this.getter = extraInfo.getter;
|
||||||
|
|
||||||
this.completer = extra_info.completer || null;
|
this.completer = extraInfo.completer || null;
|
||||||
this.validator = extra_info.validator || null;
|
this.validator = extraInfo.validator || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// add noOPTION variant of boolean OPTION to this.names
|
// add noOPTION variant of boolean OPTION to this.names
|
||||||
@@ -85,9 +85,9 @@ vimperator.Option = function (names, type, extra_info) //{{{
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
this.__defineSetter__("value",
|
this.__defineSetter__("value",
|
||||||
function (new_value)
|
function (newValue)
|
||||||
{
|
{
|
||||||
value = new_value;
|
value = newValue;
|
||||||
if (this.setter)
|
if (this.setter)
|
||||||
this.setter.call(this, value);
|
this.setter.call(this, value);
|
||||||
}
|
}
|
||||||
@@ -116,7 +116,7 @@ vimperator.Option = function (names, type, extra_info) //{{{
|
|||||||
|
|
||||||
this.reset = function ()
|
this.reset = function ()
|
||||||
{
|
{
|
||||||
this.value = this.default_value;
|
this.value = this.defaultValue;
|
||||||
};
|
};
|
||||||
}; //}}}
|
}; //}}}
|
||||||
|
|
||||||
@@ -126,13 +126,13 @@ vimperator.Options = function () //{{{
|
|||||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
var firefox_prefs = Components.classes["@mozilla.org/preferences-service;1"]
|
var firefoxPrefs = Components.classes["@mozilla.org/preferences-service;1"]
|
||||||
.getService(Components.interfaces.nsIPrefBranch);
|
.getService(Components.interfaces.nsIPrefBranch);
|
||||||
var vimperator_prefs = firefox_prefs.getBranch("extensions.vimperator.");
|
var vimperatorPrefs = firefoxPrefs.getBranch("extensions.vimperator.");
|
||||||
var options = [];
|
var options = [];
|
||||||
|
|
||||||
// save if we already changed a GUI related option, used for setInitialGUI
|
// save if we already changed a GUI related option, used for setInitialGUI
|
||||||
var guioptions_done = false, showtabline_done = false, laststatus_done = false;
|
var guioptionsDone = false, showtablineDone = false, laststatusDone = false;
|
||||||
|
|
||||||
function optionsIterator()
|
function optionsIterator()
|
||||||
{
|
{
|
||||||
@@ -142,14 +142,14 @@ vimperator.Options = function () //{{{
|
|||||||
throw StopIteration;
|
throw StopIteration;
|
||||||
}
|
}
|
||||||
|
|
||||||
function storePreference(name, value, vimperator_branch)
|
function storePreference(name, value, vimperatorBranch)
|
||||||
{
|
{
|
||||||
var branch;
|
var branch;
|
||||||
|
|
||||||
if (vimperator_branch)
|
if (vimperatorBranch)
|
||||||
branch = vimperator_prefs;
|
branch = vimperatorPrefs;
|
||||||
else
|
else
|
||||||
branch = firefox_prefs;
|
branch = firefoxPrefs;
|
||||||
|
|
||||||
switch (typeof value)
|
switch (typeof value)
|
||||||
{
|
{
|
||||||
@@ -167,23 +167,23 @@ vimperator.Options = function () //{{{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadPreference(name, forced_default, vimperator_branch)
|
function loadPreference(name, forcedDefault, vimperatorBranch)
|
||||||
{
|
{
|
||||||
var default_value = null;
|
var defaultValue = null;
|
||||||
if (forced_default != null) // this argument sets defaults for non-user settable options (like comp_history)
|
if (forcedDefault != null) // this argument sets defaults for non-user settable options (like comp_history)
|
||||||
default_value = forced_default;
|
defaultValue = forcedDefault;
|
||||||
|
|
||||||
if (vimperator_branch)
|
if (vimperatorBranch)
|
||||||
{
|
{
|
||||||
branch = vimperator_prefs;
|
branch = vimperatorPrefs;
|
||||||
|
|
||||||
if (!forced_default) // this argument sets defaults for non-user settable options (like comp_history)
|
if (!forcedDefault) // this argument sets defaults for non-user settable options (like comp_history)
|
||||||
{
|
{
|
||||||
for (var i = 0; i < options.length; i++)
|
for (var i = 0; i < options.length; i++)
|
||||||
{
|
{
|
||||||
if (options[i].name == name) // only first name is searched
|
if (options[i].name == name) // only first name is searched
|
||||||
{
|
{
|
||||||
default_value = options[i].default_value;
|
defaultValue = options[i].defaultValue;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -191,12 +191,12 @@ vimperator.Options = function () //{{{
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
branch = firefox_prefs;
|
branch = firefoxPrefs;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
switch (typeof default_value)
|
switch (typeof defaultValue)
|
||||||
{
|
{
|
||||||
case "string":
|
case "string":
|
||||||
return branch.getCharPref(name);
|
return branch.getCharPref(name);
|
||||||
@@ -205,12 +205,12 @@ vimperator.Options = function () //{{{
|
|||||||
case "boolean":
|
case "boolean":
|
||||||
return branch.getBoolPref(name);
|
return branch.getBoolPref(name);
|
||||||
default:
|
default:
|
||||||
return default_value;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
return default_value;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,7 +226,7 @@ vimperator.Options = function () //{{{
|
|||||||
document.getElementById("PersonalToolbar").collapsed = value.indexOf("b") > -1 ? false : true;
|
document.getElementById("PersonalToolbar").collapsed = value.indexOf("b") > -1 ? false : true;
|
||||||
document.getElementById("PersonalToolbar").hidden = value.indexOf("b") > -1 ? false : true;
|
document.getElementById("PersonalToolbar").hidden = value.indexOf("b") > -1 ? false : true;
|
||||||
|
|
||||||
guioptions_done = true;
|
guioptionsDone = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setLastStatus(value)
|
function setLastStatus(value)
|
||||||
@@ -246,7 +246,7 @@ vimperator.Options = function () //{{{
|
|||||||
document.getElementById("status-bar").hidden = false;
|
document.getElementById("status-bar").hidden = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
laststatus_done = true;
|
laststatusDone = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setShowTabline(value)
|
function setShowTabline(value)
|
||||||
@@ -270,7 +270,7 @@ vimperator.Options = function () //{{{
|
|||||||
tabs.collapsed = false;
|
tabs.collapsed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
showtabline_done = true;
|
showtablineDone = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setTitleString(value)
|
function setTitleString(value)
|
||||||
@@ -297,9 +297,9 @@ vimperator.Options = function () //{{{
|
|||||||
//
|
//
|
||||||
|
|
||||||
// work around firefox popup blocker
|
// work around firefox popup blocker
|
||||||
var popup_allowed_events = loadPreference("dom.popup_allowed_events", "change click dblclick mouseup reset submit");
|
var popupAllowedEvents = loadPreference("dom.popup_allowed_events", "change click dblclick mouseup reset submit");
|
||||||
if (!/keypress/.test(popup_allowed_events))
|
if (!/keypress/.test(popupAllowedEvents))
|
||||||
storePreference("dom.popup_allowed_events", popup_allowed_events + " keypress");
|
storePreference("dom.popup_allowed_events", popupAllowedEvents + " keypress");
|
||||||
|
|
||||||
// TODO: shouldn't we be resetting these in destroy() as well?
|
// TODO: shouldn't we be resetting these in destroy() as well?
|
||||||
// we have our own typeahead find implementation
|
// we have our own typeahead find implementation
|
||||||
@@ -341,11 +341,11 @@ vimperator.Options = function () //{{{
|
|||||||
{
|
{
|
||||||
// reset some modified firefox prefs
|
// reset some modified firefox prefs
|
||||||
if (loadPreference("dom.popup_allowed_events", "change click dblclick mouseup reset submit")
|
if (loadPreference("dom.popup_allowed_events", "change click dblclick mouseup reset submit")
|
||||||
== popup_allowed_events + " keypress")
|
== popupAllowedEvents + " keypress")
|
||||||
storePreference("dom.popup_allowed_events", popup_allowed_events);
|
storePreference("dom.popup_allowed_events", popupAllowedEvents);
|
||||||
},
|
},
|
||||||
|
|
||||||
list: function (only_non_default)
|
list: function (onlyNondefault)
|
||||||
{
|
{
|
||||||
// TODO: columns like Vim?
|
// TODO: columns like Vim?
|
||||||
var list = ":" + vimperator.util.escapeHTML(vimperator.commandline.getCommand()) + "<br/>" +
|
var list = ":" + vimperator.util.escapeHTML(vimperator.commandline.getCommand()) + "<br/>" +
|
||||||
@@ -356,9 +356,9 @@ vimperator.Options = function () //{{{
|
|||||||
{
|
{
|
||||||
name = options[i].name;
|
name = options[i].name;
|
||||||
value = options[i].value;
|
value = options[i].value;
|
||||||
def = options[i].default_value;
|
def = options[i].defaultValue;
|
||||||
|
|
||||||
if (only_non_default && value == def)
|
if (onlyNondefault && value == def)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (options[i].type == "boolean")
|
if (options[i].type == "boolean")
|
||||||
@@ -390,11 +390,11 @@ vimperator.Options = function () //{{{
|
|||||||
// this hack is only needed, because we need to do asynchronous loading of the .vimperatorrc
|
// this hack is only needed, because we need to do asynchronous loading of the .vimperatorrc
|
||||||
setInitialGUI: function ()
|
setInitialGUI: function ()
|
||||||
{
|
{
|
||||||
if (!guioptions_done)
|
if (!guioptionsDone)
|
||||||
this.get("guioptions").reset();
|
this.get("guioptions").reset();
|
||||||
if (!laststatus_done)
|
if (!laststatusDone)
|
||||||
this.get("laststatus").reset();
|
this.get("laststatus").reset();
|
||||||
if (!showtabline_done)
|
if (!showtablineDone)
|
||||||
this.get("showtabline").reset();
|
this.get("showtabline").reset();
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -405,9 +405,9 @@ vimperator.Options = function () //{{{
|
|||||||
return storePreference(name, value, true);
|
return storePreference(name, value, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
getPref: function (name, forced_default)
|
getPref: function (name, forcedDefault)
|
||||||
{
|
{
|
||||||
return loadPreference(name, forced_default, true);
|
return loadPreference(name, forcedDefault, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
setFirefoxPref: function (name, value)
|
setFirefoxPref: function (name, value)
|
||||||
@@ -415,9 +415,9 @@ vimperator.Options = function () //{{{
|
|||||||
return storePreference(name, value);
|
return storePreference(name, value);
|
||||||
},
|
},
|
||||||
|
|
||||||
getFirefoxPref: function (name, forced_default)
|
getFirefoxPref: function (name, forcedDefault)
|
||||||
{
|
{
|
||||||
return loadPreference(name, forced_default);
|
return loadPreference(name, forcedDefault);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -433,7 +433,7 @@ vimperator.Options = function () //{{{
|
|||||||
|
|
||||||
optionManager.add(new vimperator.Option(["activate", "act"], "stringlist",
|
optionManager.add(new vimperator.Option(["activate", "act"], "stringlist",
|
||||||
{
|
{
|
||||||
short_help: "Define when tabs are automatically activated",
|
shortHelp: "Define when tabs are automatically activated",
|
||||||
help: "Available items:<br/>" +
|
help: "Available items:<br/>" +
|
||||||
"<ul>" +
|
"<ul>" +
|
||||||
"<li><b>homepage</b>: <code class=\"mapping\">gH</code> mapping</li>" +
|
"<li><b>homepage</b>: <code class=\"mapping\">gH</code> mapping</li>" +
|
||||||
@@ -441,7 +441,7 @@ vimperator.Options = function () //{{{
|
|||||||
"<li><b>tabopen</b>: <code class=\"command\">:tabopen[!]</code> command</li>" +
|
"<li><b>tabopen</b>: <code class=\"command\">:tabopen[!]</code> command</li>" +
|
||||||
"<li><b>paste</b>: <code class=\"mapping\">P</code> and <code class=\"mapping\">gP</code> mappings</li>" +
|
"<li><b>paste</b>: <code class=\"mapping\">P</code> and <code class=\"mapping\">gP</code> mappings</li>" +
|
||||||
"</ul>",
|
"</ul>",
|
||||||
default_value: "homepage,quickmark,tabopen,paste",
|
defaultValue: "homepage,quickmark,tabopen,paste",
|
||||||
validator: function (value)
|
validator: function (value)
|
||||||
{
|
{
|
||||||
return value.split(",").every(function (item) { return /^(homepage|quickmark|tabopen|paste|)$/.test(item); });
|
return value.split(",").every(function (item) { return /^(homepage|quickmark|tabopen|paste|)$/.test(item); });
|
||||||
@@ -450,7 +450,7 @@ vimperator.Options = function () //{{{
|
|||||||
));
|
));
|
||||||
optionManager.add(new vimperator.Option(["complete", "cpt"], "charlist",
|
optionManager.add(new vimperator.Option(["complete", "cpt"], "charlist",
|
||||||
{
|
{
|
||||||
short_help: "Items which are completed at the :[tab]open prompt",
|
shortHelp: "Items which are completed at the :[tab]open prompt",
|
||||||
help: "Available items:<br/>" +
|
help: "Available items:<br/>" +
|
||||||
"<ul>" +
|
"<ul>" +
|
||||||
"<li><b>s</b>: Search engines and keyword URLs</li>" +
|
"<li><b>s</b>: Search engines and keyword URLs</li>" +
|
||||||
@@ -460,52 +460,52 @@ vimperator.Options = function () //{{{
|
|||||||
"</ul>" +
|
"</ul>" +
|
||||||
"The order is important, so <code class=\"command\">:set complete=bs</code> would list bookmarks first, and then any available quick searches.<br/>" +
|
"The order is important, so <code class=\"command\">:set complete=bs</code> would list bookmarks first, and then any available quick searches.<br/>" +
|
||||||
"Add <code class=\"option\">'sort'</code> to the <code class=\"option\">'wildoptions'</code> option if you want all entries sorted.",
|
"Add <code class=\"option\">'sort'</code> to the <code class=\"option\">'wildoptions'</code> option if you want all entries sorted.",
|
||||||
default_value: "sfbh",
|
defaultValue: "sfbh",
|
||||||
validator: function (value) { return !/[^sfbh]/.test(value); }
|
validator: function (value) { return !/[^sfbh]/.test(value); }
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
optionManager.add(new vimperator.Option(["defsearch", "ds"], "string",
|
optionManager.add(new vimperator.Option(["defsearch", "ds"], "string",
|
||||||
{
|
{
|
||||||
short_help: "Set the default search engine",
|
shortHelp: "Set the default search engine",
|
||||||
help: "The default search engine is used in the <code class=\"command\">:[tab]open [arg]</code> command " +
|
help: "The default search engine is used in the <code class=\"command\">:[tab]open [arg]</code> command " +
|
||||||
"if [arg] neither looks like a URL or like a specified search engine/keyword.",
|
"if [arg] neither looks like a URL or like a specified search engine/keyword.",
|
||||||
default_value: "google"
|
defaultValue: "google"
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
optionManager.add(new vimperator.Option(["editor"], "string",
|
optionManager.add(new vimperator.Option(["editor"], "string",
|
||||||
{
|
{
|
||||||
short_help: "Set the external text editor",
|
shortHelp: "Set the external text editor",
|
||||||
help: "Sets the editor to run when <code class=\"mapping\"><C-i></code> " +
|
help: "Sets the editor to run when <code class=\"mapping\"><C-i></code> " +
|
||||||
"is pressed in INSERT and TEXTAREA modes. Note that Vimperator will " +
|
"is pressed in INSERT and TEXTAREA modes. Note that Vimperator will " +
|
||||||
"not behave correctly if the editor forks its own process, such as with "+
|
"not behave correctly if the editor forks its own process, such as with "+
|
||||||
"gvim without the -f argument.",
|
"gvim without the -f argument.",
|
||||||
default_value: "gvim -f"
|
defaultValue: "gvim -f"
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
optionManager.add(new vimperator.Option(["extendedhinttags", "eht"], "string",
|
optionManager.add(new vimperator.Option(["extendedhinttags", "eht"], "string",
|
||||||
{
|
{
|
||||||
short_help: "XPath string of hintable elements activated by ';'",
|
shortHelp: "XPath string of hintable elements activated by ';'",
|
||||||
default_value: DEFAULT_HINTTAGS
|
defaultValue: DEFAULT_HINTTAGS
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
optionManager.add(new vimperator.Option(["focusedhintstyle", "fhs"], "string",
|
optionManager.add(new vimperator.Option(["focusedhintstyle", "fhs"], "string",
|
||||||
{
|
{
|
||||||
short_help: "CSS specification of focused hints",
|
shortHelp: "CSS specification of focused hints",
|
||||||
default_value: "z-index:5000; font-family:monospace; font-size:12px; color:ButtonText; background-color:ButtonShadow; " +
|
defaultValue: "z-index:5000; font-family:monospace; font-size:12px; color:ButtonText; background-color:ButtonShadow; " +
|
||||||
"border-color:ButtonShadow; border-width:1px; border-style:solid; padding:0px 1px 0px 1px; position:absolute;"
|
"border-color:ButtonShadow; border-width:1px; border-style:solid; padding:0px 1px 0px 1px; position:absolute;"
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
optionManager.add(new vimperator.Option(["fullscreen", "fs"], "boolean",
|
optionManager.add(new vimperator.Option(["fullscreen", "fs"], "boolean",
|
||||||
{
|
{
|
||||||
short_help: "Show the current window fullscreen",
|
shortHelp: "Show the current window fullscreen",
|
||||||
setter: function (value) { window.fullScreen = value; },
|
setter: function (value) { window.fullScreen = value; },
|
||||||
getter: function () { return window.fullScreen; },
|
getter: function () { return window.fullScreen; },
|
||||||
default_value: false
|
defaultValue: false
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
optionManager.add(new vimperator.Option(["guioptions", "go"], "charlist",
|
optionManager.add(new vimperator.Option(["guioptions", "go"], "charlist",
|
||||||
{
|
{
|
||||||
short_help: "Show or hide the menu, toolbar and scrollbars",
|
shortHelp: "Show or hide the menu, toolbar and scrollbars",
|
||||||
help: "Supported characters:<br/>" +
|
help: "Supported characters:<br/>" +
|
||||||
"<ul>" +
|
"<ul>" +
|
||||||
"<li><b>m</b>: menubar</li>" +
|
"<li><b>m</b>: menubar</li>" +
|
||||||
@@ -513,68 +513,68 @@ vimperator.Options = function () //{{{
|
|||||||
"<li><b>b</b>: bookmark bar</li>" +
|
"<li><b>b</b>: bookmark bar</li>" +
|
||||||
"</ul>",
|
"</ul>",
|
||||||
setter: function (value) { setGuiOptions(value); },
|
setter: function (value) { setGuiOptions(value); },
|
||||||
default_value: "",
|
defaultValue: "",
|
||||||
validator: function (value) { return !/[^mTb]/.test(value); }
|
validator: function (value) { return !/[^mTb]/.test(value); }
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
optionManager.add(new vimperator.Option(["hinttimeout", "hto"], "number",
|
optionManager.add(new vimperator.Option(["hinttimeout", "hto"], "number",
|
||||||
{
|
{
|
||||||
short_help: "Automatically follow non unique numerical hint after {arg} ms",
|
shortHelp: "Automatically follow non unique numerical hint after {arg} ms",
|
||||||
help: "Set to 0 (the default) to only follow numeric hints after pressing <Return> or when the hint is unique.",
|
help: "Set to 0 (the default) to only follow numeric hints after pressing <Return> or when the hint is unique.",
|
||||||
default_value: 0,
|
defaultValue: 0,
|
||||||
validator: function (value) { return value >= 0; }
|
validator: function (value) { return value >= 0; }
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
optionManager.add(new vimperator.Option(["hintstyle", "hs"], "string",
|
optionManager.add(new vimperator.Option(["hintstyle", "hs"], "string",
|
||||||
{
|
{
|
||||||
short_help: "CSS specification of unfocused hints",
|
shortHelp: "CSS specification of unfocused hints",
|
||||||
default_value: "z-index:5000; font-family:monospace; font-size:12px; color:white; background-color:red; " +
|
defaultValue: "z-index:5000; font-family:monospace; font-size:12px; color:white; background-color:red; " +
|
||||||
"border-color:ButtonShadow; border-width:0px; border-style:solid; padding:0px 1px 0px 1px; position:absolute;"
|
"border-color:ButtonShadow; border-width:0px; border-style:solid; padding:0px 1px 0px 1px; position:absolute;"
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
optionManager.add(new vimperator.Option(["hinttags", "ht"], "string",
|
optionManager.add(new vimperator.Option(["hinttags", "ht"], "string",
|
||||||
{
|
{
|
||||||
short_help: "XPath string of hintable elements activated by <code class=\"mapping\">'f'</code> and <code class=\"mapping\">'F'</code>",
|
shortHelp: "XPath string of hintable elements activated by <code class=\"mapping\">'f'</code> and <code class=\"mapping\">'F'</code>",
|
||||||
default_value: DEFAULT_HINTTAGS
|
defaultValue: DEFAULT_HINTTAGS
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
optionManager.add(new vimperator.Option(["hlsearch", "hls"], "boolean",
|
optionManager.add(new vimperator.Option(["hlsearch", "hls"], "boolean",
|
||||||
{
|
{
|
||||||
short_help: "Highlight previous search pattern matches",
|
shortHelp: "Highlight previous search pattern matches",
|
||||||
setter: function (value) { if (value) vimperator.search.highlight(); else vimperator.search.clear(); },
|
setter: function (value) { if (value) vimperator.search.highlight(); else vimperator.search.clear(); },
|
||||||
default_value: false
|
defaultValue: false
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
optionManager.add(new vimperator.Option(["hlsearchstyle", "hlss"], "string",
|
optionManager.add(new vimperator.Option(["hlsearchstyle", "hlss"], "string",
|
||||||
{
|
{
|
||||||
short_help: "CSS specification of highlighted search items",
|
shortHelp: "CSS specification of highlighted search items",
|
||||||
default_value: "color: black; background-color: yellow; padding: 0; display: inline;"
|
defaultValue: "color: black; background-color: yellow; padding: 0; display: inline;"
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
optionManager.add(new vimperator.Option(["ignorecase", "ic"], "boolean",
|
optionManager.add(new vimperator.Option(["ignorecase", "ic"], "boolean",
|
||||||
{
|
{
|
||||||
short_help: "Ignore case in search patterns",
|
shortHelp: "Ignore case in search patterns",
|
||||||
default_value: true
|
defaultValue: true
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
optionManager.add(new vimperator.Option(["incsearch", "is"], "boolean",
|
optionManager.add(new vimperator.Option(["incsearch", "is"], "boolean",
|
||||||
{
|
{
|
||||||
short_help: "Show where the search pattern matches as it is typed",
|
shortHelp: "Show where the search pattern matches as it is typed",
|
||||||
help: "NOTE: Incremental searching currently only works in the forward direction.",
|
help: "NOTE: Incremental searching currently only works in the forward direction.",
|
||||||
default_value: true
|
defaultValue: true
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
optionManager.add(new vimperator.Option(["insertmode", "im"], "boolean",
|
optionManager.add(new vimperator.Option(["insertmode", "im"], "boolean",
|
||||||
{
|
{
|
||||||
short_help: "Use Insert mode as the default for text areas",
|
shortHelp: "Use Insert mode as the default for text areas",
|
||||||
help: "Makes Vimperator work in a way that Insert mode is the default mode for text areas. " +
|
help: "Makes Vimperator work in a way that Insert mode is the default mode for text areas. " +
|
||||||
"Useful if you want to use Vimperator as a modeless editor, keeping the known Firefox interface for editing text areas.",
|
"Useful if you want to use Vimperator as a modeless editor, keeping the known Firefox interface for editing text areas.",
|
||||||
default_value: true
|
defaultValue: true
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
optionManager.add(new vimperator.Option(["laststatus", "ls"], "number",
|
optionManager.add(new vimperator.Option(["laststatus", "ls"], "number",
|
||||||
{
|
{
|
||||||
short_help: "Show the status line",
|
shortHelp: "Show the status line",
|
||||||
help: "Determines when the last window will have a status line. " +
|
help: "Determines when the last window will have a status line. " +
|
||||||
"Possible values:<br/>" +
|
"Possible values:<br/>" +
|
||||||
"<ul>" +
|
"<ul>" +
|
||||||
@@ -583,27 +583,27 @@ vimperator.Options = function () //{{{
|
|||||||
"<li><b>2</b>: always</li>" +
|
"<li><b>2</b>: always</li>" +
|
||||||
"</ul>" +
|
"</ul>" +
|
||||||
"NOTE: laststatus=1 not implemented yet.",
|
"NOTE: laststatus=1 not implemented yet.",
|
||||||
default_value: 2,
|
defaultValue: 2,
|
||||||
setter: function (value) { setLastStatus(value); },
|
setter: function (value) { setLastStatus(value); },
|
||||||
validator: function (value) { return (value >= 0 && value <= 2); }
|
validator: function (value) { return (value >= 0 && value <= 2); }
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
optionManager.add(new vimperator.Option(["linksearch", "lks"], "boolean",
|
optionManager.add(new vimperator.Option(["linksearch", "lks"], "boolean",
|
||||||
{
|
{
|
||||||
short_help: "Limit the search to hyperlink text",
|
shortHelp: "Limit the search to hyperlink text",
|
||||||
help: "This includes (X)HTML elements with an \"href\" atrribute and XLink \"simple\" links.",
|
help: "This includes (X)HTML elements with an \"href\" atrribute and XLink \"simple\" links.",
|
||||||
default_value: false
|
defaultValue: false
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
optionManager.add(new vimperator.Option(["more"], "boolean",
|
optionManager.add(new vimperator.Option(["more"], "boolean",
|
||||||
{
|
{
|
||||||
short_help: "Pause the message list window when more than one screen of listings is displayed",
|
shortHelp: "Pause the message list window when more than one screen of listings is displayed",
|
||||||
default_value: true
|
defaultValue: true
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
optionManager.add(new vimperator.Option(["pageinfo", "pa"], "charlist",
|
optionManager.add(new vimperator.Option(["pageinfo", "pa"], "charlist",
|
||||||
{
|
{
|
||||||
short_help: "Desired info on :pa[geinfo]",
|
shortHelp: "Desired info on :pa[geinfo]",
|
||||||
help: "Available items:<br/>" +
|
help: "Available items:<br/>" +
|
||||||
"<ul>" +
|
"<ul>" +
|
||||||
"<li><b>g</b>: general info</li>" +
|
"<li><b>g</b>: general info</li>" +
|
||||||
@@ -611,13 +611,13 @@ vimperator.Options = function () //{{{
|
|||||||
"<li><b>m</b>: meta tags</li>" +
|
"<li><b>m</b>: meta tags</li>" +
|
||||||
"</ul>" +
|
"</ul>" +
|
||||||
"The order matters",
|
"The order matters",
|
||||||
default_value: "gfm",
|
defaultValue: "gfm",
|
||||||
validator: function (value) { return !(/[^gfm]/.test(value) || value.length > 3 || value.length < 1); }
|
validator: function (value) { return !(/[^gfm]/.test(value) || value.length > 3 || value.length < 1); }
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
optionManager.add(new vimperator.Option(["popups", "pps"], "number",
|
optionManager.add(new vimperator.Option(["popups", "pps"], "number",
|
||||||
{
|
{
|
||||||
short_help: "Where to show requested popup windows",
|
shortHelp: "Where to show requested popup windows",
|
||||||
help: "Define where to show requested popup windows. Does not apply to windows which are opened by middle clicking a link, they always open in a new tab. " +
|
help: "Define where to show requested popup windows. Does not apply to windows which are opened by middle clicking a link, they always open in a new tab. " +
|
||||||
"Possible values:<br/>" +
|
"Possible values:<br/>" +
|
||||||
"<ul>" +
|
"<ul>" +
|
||||||
@@ -627,48 +627,48 @@ vimperator.Options = function () //{{{
|
|||||||
"<li><b>3</b>: Always open in a new window</li>" +
|
"<li><b>3</b>: Always open in a new window</li>" +
|
||||||
"</ul>" +
|
"</ul>" +
|
||||||
"NOTE: This option does not change the popup blocker of Firefox in any way.",
|
"NOTE: This option does not change the popup blocker of Firefox in any way.",
|
||||||
default_value: 1,
|
defaultValue: 1,
|
||||||
setter: function (value) { setPopups(value); },
|
setter: function (value) { setPopups(value); },
|
||||||
validator: function (value) { return (value >= 0 && value <= 3); }
|
validator: function (value) { return (value >= 0 && value <= 3); }
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
optionManager.add(new vimperator.Option(["preload"], "boolean",
|
optionManager.add(new vimperator.Option(["preload"], "boolean",
|
||||||
{
|
{
|
||||||
short_help: "Speed up first time history/bookmark completion",
|
shortHelp: "Speed up first time history/bookmark completion",
|
||||||
help: "History access can be quite slow for a large history. Vimperator maintains a cache to speed it up significantly on subsequent access.<br/>" +
|
help: "History access can be quite slow for a large history. Vimperator maintains a cache to speed it up significantly on subsequent access.<br/>" +
|
||||||
"In order to also speed up first time access, it is cached at startup, if this option is set (recommended).",
|
"In order to also speed up first time access, it is cached at startup, if this option is set (recommended).",
|
||||||
default_value: true
|
defaultValue: true
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
optionManager.add(new vimperator.Option(["previewheight", "pvh"], "number",
|
optionManager.add(new vimperator.Option(["previewheight", "pvh"], "number",
|
||||||
{
|
{
|
||||||
short_help: "Default height for preview window",
|
shortHelp: "Default height for preview window",
|
||||||
help: "Value must be between 1 and 50. If the value is too high, completions may cover the command-line. " +
|
help: "Value must be between 1 and 50. If the value is too high, completions may cover the command-line. " +
|
||||||
"Close the preview window with <code class=\"command\">:pclose</code>.<br/>" +
|
"Close the preview window with <code class=\"command\">:pclose</code>.<br/>" +
|
||||||
"NOTE: Option currently disabled",
|
"NOTE: Option currently disabled",
|
||||||
default_value: 10,
|
defaultValue: 10,
|
||||||
validator: function (value) { return (value >= 1 && value <= 50); }
|
validator: function (value) { return (value >= 1 && value <= 50); }
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
optionManager.add(new vimperator.Option(["scroll", "scr"], "number",
|
optionManager.add(new vimperator.Option(["scroll", "scr"], "number",
|
||||||
{
|
{
|
||||||
short_help: "Number of lines to scroll with <code class=\"mapping\">C-u</code> and <code class=\"mapping\">C-d</code> commands",
|
shortHelp: "Number of lines to scroll with <code class=\"mapping\">C-u</code> and <code class=\"mapping\">C-d</code> commands",
|
||||||
help: "The number of lines scrolled defaults to half the window size. " +
|
help: "The number of lines scrolled defaults to half the window size. " +
|
||||||
"When a <code class=\"argument\">{count}</code> is specified to the <code class=\"mapping\"><C-u></code> or <code class=\"mapping\"><C-d></code> commands this is used to set the value of <code class=\"option\">'scroll'</code> and also used for the current command. " +
|
"When a <code class=\"argument\">{count}</code> is specified to the <code class=\"mapping\"><C-u></code> or <code class=\"mapping\"><C-d></code> commands this is used to set the value of <code class=\"option\">'scroll'</code> and also used for the current command. " +
|
||||||
"The value can be reset to half the window height with <code class=\"command\">:set scroll=0</code>.",
|
"The value can be reset to half the window height with <code class=\"command\">:set scroll=0</code>.",
|
||||||
default_value: 0,
|
defaultValue: 0,
|
||||||
validator: function (value) { return value >= 0; }
|
validator: function (value) { return value >= 0; }
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
optionManager.add(new vimperator.Option(["showmode", "smd"], "boolean",
|
optionManager.add(new vimperator.Option(["showmode", "smd"], "boolean",
|
||||||
{
|
{
|
||||||
short_help: "Show the current mode in the command line",
|
shortHelp: "Show the current mode in the command line",
|
||||||
default_value: true
|
defaultValue: true
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
optionManager.add(new vimperator.Option(["showstatuslinks", "ssli"], "number",
|
optionManager.add(new vimperator.Option(["showstatuslinks", "ssli"], "number",
|
||||||
{
|
{
|
||||||
short_help: "Show the destination of the link under the cursor in the status bar",
|
shortHelp: "Show the destination of the link under the cursor in the status bar",
|
||||||
help: "Also links which are focused by keyboard commands like <code class=\"mapping\"><Tab></code> are shown. " +
|
help: "Also links which are focused by keyboard commands like <code class=\"mapping\"><Tab></code> are shown. " +
|
||||||
"Possible values:<br/>" +
|
"Possible values:<br/>" +
|
||||||
"<ul>" +
|
"<ul>" +
|
||||||
@@ -676,13 +676,13 @@ vimperator.Options = function () //{{{
|
|||||||
"<li><b>1</b>: Show the link in the status line</li>" +
|
"<li><b>1</b>: Show the link in the status line</li>" +
|
||||||
"<li><b>2</b>: Show the link in the command line</li>" +
|
"<li><b>2</b>: Show the link in the command line</li>" +
|
||||||
"</ul>",
|
"</ul>",
|
||||||
default_value: 1,
|
defaultValue: 1,
|
||||||
validator: function (value) { return (value >= 0 && value <= 2); }
|
validator: function (value) { return (value >= 0 && value <= 2); }
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
optionManager.add(new vimperator.Option(["showtabline", "stal"], "number",
|
optionManager.add(new vimperator.Option(["showtabline", "stal"], "number",
|
||||||
{
|
{
|
||||||
short_help: "Control when to show the tab bar of opened web pages",
|
shortHelp: "Control when to show the tab bar of opened web pages",
|
||||||
help: "Possible values:<br/>" +
|
help: "Possible values:<br/>" +
|
||||||
"<ul>" +
|
"<ul>" +
|
||||||
"<li><b>0</b>: Never show tab bar</li>" +
|
"<li><b>0</b>: Never show tab bar</li>" +
|
||||||
@@ -690,55 +690,55 @@ vimperator.Options = function () //{{{
|
|||||||
"<li><b>2</b>: Always show tab bar</li>" +
|
"<li><b>2</b>: Always show tab bar</li>" +
|
||||||
"</ul>",
|
"</ul>",
|
||||||
setter: function (value) { setShowTabline(value); },
|
setter: function (value) { setShowTabline(value); },
|
||||||
default_value: 2,
|
defaultValue: 2,
|
||||||
validator: function (value) { return (value >= 0 && value <= 2); }
|
validator: function (value) { return (value >= 0 && value <= 2); }
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
optionManager.add(new vimperator.Option(["smartcase", "scs"], "boolean",
|
optionManager.add(new vimperator.Option(["smartcase", "scs"], "boolean",
|
||||||
{
|
{
|
||||||
short_help: "Override the 'ignorecase' option if the pattern contains uppercase characters",
|
shortHelp: "Override the 'ignorecase' option if the pattern contains uppercase characters",
|
||||||
help: "This is only used if the <code class=\"option\">'ignorecase'</code> option is set.",
|
help: "This is only used if the <code class=\"option\">'ignorecase'</code> option is set.",
|
||||||
default_value: true
|
defaultValue: true
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
optionManager.add(new vimperator.Option(["titlestring"], "string",
|
optionManager.add(new vimperator.Option(["titlestring"], "string",
|
||||||
{
|
{
|
||||||
short_help: "Change the title of the browser window",
|
shortHelp: "Change the title of the browser window",
|
||||||
help: "Vimperator changes the browser title from \"Title of web page - Mozilla Firefox\" to " +
|
help: "Vimperator changes the browser title from \"Title of web page - Mozilla Firefox\" to " +
|
||||||
"\"Title of web page - Vimperator\".<br/>If you don't like that, you can restore it with: " +
|
"\"Title of web page - Vimperator\".<br/>If you don't like that, you can restore it with: " +
|
||||||
"<code class=\"command\">:set titlestring=Mozilla Firefox</code>.",
|
"<code class=\"command\">:set titlestring=Mozilla Firefox</code>.",
|
||||||
setter: function (value) { setTitleString(value); },
|
setter: function (value) { setTitleString(value); },
|
||||||
default_value: "Vimperator"
|
defaultValue: "Vimperator"
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
optionManager.add(new vimperator.Option(["usermode", "um"], "boolean",
|
optionManager.add(new vimperator.Option(["usermode", "um"], "boolean",
|
||||||
{
|
{
|
||||||
short_help: "Show current website with a minimal style sheet to make it easily accessible",
|
shortHelp: "Show current website with a minimal style sheet to make it easily accessible",
|
||||||
help: "Note that this is a local option for now, later it may be split into a global and <code class=\"command\">:setlocal</code> part",
|
help: "Note that this is a local option for now, later it may be split into a global and <code class=\"command\">:setlocal</code> part",
|
||||||
setter: function (value) { getMarkupDocumentViewer().authorStyleDisabled = value; },
|
setter: function (value) { getMarkupDocumentViewer().authorStyleDisabled = value; },
|
||||||
getter: function () { return getMarkupDocumentViewer().authorStyleDisabled; },
|
getter: function () { return getMarkupDocumentViewer().authorStyleDisabled; },
|
||||||
default_value: false
|
defaultValue: false
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
optionManager.add(new vimperator.Option(["verbose", "vbs"], "number",
|
optionManager.add(new vimperator.Option(["verbose", "vbs"], "number",
|
||||||
{
|
{
|
||||||
short_help: "Define which type of messages are logged",
|
shortHelp: "Define which type of messages are logged",
|
||||||
help: "When bigger than zero, Vimperator will give messages about what it is doing. They are printed to the error console which can be shown with <code class=\"command\">:javascript!</code>.<br/>" +
|
help: "When bigger than zero, Vimperator will give messages about what it is doing. They are printed to the error console which can be shown with <code class=\"command\">:javascript!</code>.<br/>" +
|
||||||
"The highest value is 9, being the most verbose mode.",
|
"The highest value is 9, being the most verbose mode.",
|
||||||
default_value: 0,
|
defaultValue: 0,
|
||||||
validator: function (value) { return (value >= 0 && value <= 9); }
|
validator: function (value) { return (value >= 0 && value <= 9); }
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
optionManager.add(new vimperator.Option(["visualbell", "vb"], "boolean",
|
optionManager.add(new vimperator.Option(["visualbell", "vb"], "boolean",
|
||||||
{
|
{
|
||||||
short_help: "Use visual bell instead of beeping on errors",
|
shortHelp: "Use visual bell instead of beeping on errors",
|
||||||
setter: function (value) { vimperator.options.setFirefoxPref("accessibility.typeaheadfind.enablesound", !value); },
|
setter: function (value) { vimperator.options.setFirefoxPref("accessibility.typeaheadfind.enablesound", !value); },
|
||||||
default_value: false
|
defaultValue: false
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
optionManager.add(new vimperator.Option(["wildmode", "wim"], "stringlist",
|
optionManager.add(new vimperator.Option(["wildmode", "wim"], "stringlist",
|
||||||
{
|
{
|
||||||
short_help: "Define how command line completion works",
|
shortHelp: "Define how command line completion works",
|
||||||
help: "It is a comma-separated list of parts, where each part specifies " +
|
help: "It is a comma-separated list of parts, where each part specifies " +
|
||||||
"what to do for each consecutive use of the completion key. The first part " +
|
"what to do for each consecutive use of the completion key. The first part " +
|
||||||
"specifies the behavior for the first use of the completion key, the second part " +
|
"specifies the behavior for the first use of the completion key, the second part " +
|
||||||
@@ -753,7 +753,7 @@ vimperator.Options = function () //{{{
|
|||||||
"<tr><td><b>'list:longest'</b></td><td>When more than one match, list all matches and complete till the longest common string.</td></tr>" +
|
"<tr><td><b>'list:longest'</b></td><td>When more than one match, list all matches and complete till the longest common string.</td></tr>" +
|
||||||
"</table>" +
|
"</table>" +
|
||||||
"When there is only a single match, it is fully completed regardless of the case.",
|
"When there is only a single match, it is fully completed regardless of the case.",
|
||||||
default_value: "list:full",
|
defaultValue: "list:full",
|
||||||
validator: function (value)
|
validator: function (value)
|
||||||
{
|
{
|
||||||
return value.split(",").every(function (item) { return /^(full|longest|list|list:full|list:longest|)$/.test(item); });
|
return value.split(",").every(function (item) { return /^(full|longest|list|list:full|list:longest|)$/.test(item); });
|
||||||
@@ -762,30 +762,30 @@ vimperator.Options = function () //{{{
|
|||||||
));
|
));
|
||||||
optionManager.add(new vimperator.Option(["wildoptions", "wop"], "stringlist",
|
optionManager.add(new vimperator.Option(["wildoptions", "wop"], "stringlist",
|
||||||
{
|
{
|
||||||
short_help: "Change how command line completion is done",
|
shortHelp: "Change how command line completion is done",
|
||||||
help: "A list of words that change how command line completion is done.<br/>" +
|
help: "A list of words that change how command line completion is done.<br/>" +
|
||||||
"Currently only one word is allowed:<br/>" +
|
"Currently only one word is allowed:<br/>" +
|
||||||
"<table>" +
|
"<table>" +
|
||||||
"<tr><td><b>sort</b></td><td>Always sorts completion list, overriding the <code class=\"option\">'complete'</code> option.</td></tr>" +
|
"<tr><td><b>sort</b></td><td>Always sorts completion list, overriding the <code class=\"option\">'complete'</code> option.</td></tr>" +
|
||||||
"</table>",
|
"</table>",
|
||||||
default_value: "",
|
defaultValue: "",
|
||||||
validator: function (value) { return /^(sort|)$/.test(value); }
|
validator: function (value) { return /^(sort|)$/.test(value); }
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
optionManager.add(new vimperator.Option(["nextpattern"], "stringlist",
|
optionManager.add(new vimperator.Option(["nextpattern"], "stringlist",
|
||||||
{
|
{
|
||||||
short_help: "String to search when looking for 'next' page in document relation",
|
shortHelp: "String to search when looking for 'next' page in document relation",
|
||||||
help: "Change it to make it look for another string in links when pressing ]n<br/>" +
|
help: "Change it to make it look for another string in links when pressing ]n<br/>" +
|
||||||
"This value is case insensitive",
|
"This value is case insensitive",
|
||||||
default_value: "\\bnext,^>$"
|
defaultValue: "\\bnext,^>$"
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
optionManager.add(new vimperator.Option(["previouspattern"], "stringlist",
|
optionManager.add(new vimperator.Option(["previouspattern"], "stringlist",
|
||||||
{
|
{
|
||||||
short_help: "String to search when looking for 'prev' page in document relation",
|
shortHelp: "String to search when looking for 'prev' page in document relation",
|
||||||
help: "Change it to make it look for another string in links when pressing ]p<br/>" +
|
help: "Change it to make it look for another string in links when pressing ]p<br/>" +
|
||||||
"This value is case insensitive",
|
"This value is case insensitive",
|
||||||
default_value: "\\bprev,previous\\b,^<$"
|
defaultValue: "\\bprev,previous\\b,^<$"
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
//}}}
|
//}}}
|
||||||
@@ -795,7 +795,7 @@ vimperator.Options = function () //{{{
|
|||||||
setShowTabline(0);
|
setShowTabline(0);
|
||||||
setGuiOptions("");
|
setGuiOptions("");
|
||||||
setLastStatus(0);
|
setLastStatus(0);
|
||||||
guioptions_done = showtabline_done = laststatus_done = false;
|
guioptionsDone = showtablineDone = laststatusDone = false;
|
||||||
|
|
||||||
setTitleString(optionManager.titlestring);
|
setTitleString(optionManager.titlestring);
|
||||||
setPopups(optionManager.popups);
|
setPopups(optionManager.popups);
|
||||||
|
|||||||
@@ -145,9 +145,9 @@ vimperator.Tabs = function () //{{{
|
|||||||
getBrowser().moveTabTo(tab, index);
|
getBrowser().moveTabTo(tab, index);
|
||||||
},
|
},
|
||||||
|
|
||||||
// quit_on_last_tab = 1: quit without saving session
|
// quitOnLastTab = 1: quit without saving session
|
||||||
// quit_on_last_tab = 2: quit and save session
|
// quitOnLastTab = 2: quit and save session
|
||||||
remove: function (tab, count, focus_left_tab, quit_on_last_tab)
|
remove: function (tab, count, focusLeftTab, quitOnLastTab)
|
||||||
{
|
{
|
||||||
function removeOrBlankTab (tab)
|
function removeOrBlankTab (tab)
|
||||||
{
|
{
|
||||||
@@ -169,26 +169,26 @@ vimperator.Tabs = function () //{{{
|
|||||||
if (count < 1)
|
if (count < 1)
|
||||||
count = 1;
|
count = 1;
|
||||||
|
|
||||||
if (quit_on_last_tab >= 1 && getBrowser().mTabs.length <= count)
|
if (quitOnLastTab >= 1 && getBrowser().mTabs.length <= count)
|
||||||
{
|
{
|
||||||
if (vimperator.windows.length > 1)
|
if (vimperator.windows.length > 1)
|
||||||
window.close();
|
window.close();
|
||||||
else
|
else
|
||||||
vimperator.quit(quit_on_last_tab == 2);
|
vimperator.quit(quitOnLastTab == 2);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var index = this.index(tab);
|
var index = this.index(tab);
|
||||||
if (focus_left_tab)
|
if (focusLeftTab)
|
||||||
{
|
{
|
||||||
var last_removed_tab = 0;
|
var lastRemovedTab = 0;
|
||||||
for (var i = index; i > index - count && i >= 0; i--)
|
for (var i = index; i > index - count && i >= 0; i--)
|
||||||
{
|
{
|
||||||
removeOrBlankTab(this.getTab(i));
|
removeOrBlankTab(this.getTab(i));
|
||||||
last_removed_tab = i > 0 ? i : 1;
|
lastRemovedTab = i > 0 ? i : 1;
|
||||||
}
|
}
|
||||||
getBrowser().mTabContainer.selectedIndex = last_removed_tab - 1;
|
getBrowser().mTabContainer.selectedIndex = lastRemovedTab - 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -226,9 +226,9 @@ vimperator.Tabs = function () //{{{
|
|||||||
alternates = [this.getTab(), alternates[0]];
|
alternates = [this.getTab(), alternates[0]];
|
||||||
},
|
},
|
||||||
|
|
||||||
reload: function (tab, bypass_cache)
|
reload: function (tab, bypassCache)
|
||||||
{
|
{
|
||||||
if (bypass_cache)
|
if (bypassCache)
|
||||||
{
|
{
|
||||||
const nsIWebNavigation = Components.interfaces.nsIWebNavigation;
|
const nsIWebNavigation = Components.interfaces.nsIWebNavigation;
|
||||||
const flags = nsIWebNavigation.LOAD_FLAGS_BYPASS_PROXY | nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE;
|
const flags = nsIWebNavigation.LOAD_FLAGS_BYPASS_PROXY | nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE;
|
||||||
@@ -240,15 +240,15 @@ vimperator.Tabs = function () //{{{
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
reloadAll: function (bypass_cache)
|
reloadAll: function (bypassCache)
|
||||||
{
|
{
|
||||||
if (bypass_cache)
|
if (bypassCache)
|
||||||
{
|
{
|
||||||
for (var i = 0; i < getBrowser().mTabs.length; i++)
|
for (var i = 0; i < getBrowser().mTabs.length; i++)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.reload(getBrowser().mTabs[i], bypass_cache);
|
this.reload(getBrowser().mTabs[i], bypassCache);
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
|
|||||||
513
content/ui.js
513
content/ui.js
File diff suppressed because it is too large
Load Diff
@@ -27,6 +27,7 @@ the terms of any one of the MPL, the GPL or the LGPL.
|
|||||||
}}} ***** END LICENSE BLOCK *****/
|
}}} ***** END LICENSE BLOCK *****/
|
||||||
|
|
||||||
vimperator.util = {
|
vimperator.util = {
|
||||||
|
|
||||||
escapeHTML: function (str)
|
escapeHTML: function (str)
|
||||||
{
|
{
|
||||||
// XXX: the following code is _much_ slower than a simple .replace()
|
// XXX: the following code is _much_ slower than a simple .replace()
|
||||||
@@ -39,9 +40,9 @@ vimperator.util = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// TODO: use :highlight color groups
|
// TODO: use :highlight color groups
|
||||||
// if "process_strings" is true, any passed strings will be surrounded by " and
|
// if "processStrings" is true, any passed strings will be surrounded by " and
|
||||||
// any line breaks are displayed as \n
|
// any line breaks are displayed as \n
|
||||||
colorize: function (arg, process_strings)
|
colorize: function (arg, processStrings)
|
||||||
{
|
{
|
||||||
var type = typeof arg;
|
var type = typeof arg;
|
||||||
|
|
||||||
@@ -54,7 +55,7 @@ vimperator.util = {
|
|||||||
}
|
}
|
||||||
else if (type == "string")
|
else if (type == "string")
|
||||||
{
|
{
|
||||||
if (process_strings)
|
if (processStrings)
|
||||||
arg = '"' + vimperator.util.escapeHTML(arg.replace(/\n/, "\\n")) + '"';
|
arg = '"' + vimperator.util.escapeHTML(arg.replace(/\n/, "\\n")) + '"';
|
||||||
|
|
||||||
return "<span style=\"color: green;\">" + arg + "</span>";
|
return "<span style=\"color: green;\">" + arg + "</span>";
|
||||||
@@ -97,7 +98,7 @@ vimperator.util = {
|
|||||||
|
|
||||||
begin: for (var url = 0; url < urls.length; url++)
|
begin: for (var url = 0; url < urls.length; url++)
|
||||||
{
|
{
|
||||||
var new_url = vimperator.buffer.URL;
|
var newURL = vimperator.buffer.URL;
|
||||||
var matches;
|
var matches;
|
||||||
|
|
||||||
// strip each 'URL' - makes things simpler later on
|
// strip each 'URL' - makes things simpler later on
|
||||||
@@ -108,13 +109,13 @@ vimperator.util = {
|
|||||||
if (matches = urls[url].match(/^(?:\.$|\.\/(\S*))/))
|
if (matches = urls[url].match(/^(?:\.$|\.\/(\S*))/))
|
||||||
{
|
{
|
||||||
var tail = matches[1] || "";
|
var tail = matches[1] || "";
|
||||||
urls[url] = new_url.replace(/(.+\/)[^\/]*/, "$1" + tail); // NOTE: escape / in character sets so as not to break Vim syntax highlighting
|
urls[url] = newURL.replace(/(.+\/)[^\/]*/, "$1" + tail); // NOTE: escape / in character sets so as not to break Vim syntax highlighting
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (matches = urls[url].match(/^(?:\.\.$|\.\.\/(\S*))/))
|
else if (matches = urls[url].match(/^(?:\.\.$|\.\.\/(\S*))/))
|
||||||
{
|
{
|
||||||
var tail = matches[1] || "";
|
var tail = matches[1] || "";
|
||||||
urls[url] = new_url.replace(/(.+\/)[^\/]*/, "$1../" + tail);
|
urls[url] = newURL.replace(/(.+\/)[^\/]*/, "$1../" + tail);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (matches = urls[url].match(/^(?:\.\.\.$|\.\.\.\/(\S*))/))
|
else if (matches = urls[url].match(/^(?:\.\.\.$|\.\.\.\/(\S*))/))
|
||||||
@@ -142,18 +143,18 @@ vimperator.util = {
|
|||||||
// like the comments below ;-)
|
// like the comments below ;-)
|
||||||
|
|
||||||
// check if the first word is a search engine
|
// check if the first word is a search engine
|
||||||
var search_url = vimperator.bookmarks.getSearchURL(text, alias);
|
var searchURL = vimperator.bookmarks.getSearchURL(text, alias);
|
||||||
if (search_url/* && search_url.length >= 1*/)
|
if (searchURL/* && searchURL.length >= 1*/)
|
||||||
{
|
{
|
||||||
urls[url] = search_url;
|
urls[url] = searchURL;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else // the first word was not a search engine, search for the whole string in the default engine
|
else // the first word was not a search engine, search for the whole string in the default engine
|
||||||
{
|
{
|
||||||
search_url = vimperator.bookmarks.getSearchURL(urls[url], null);
|
searchURL = vimperator.bookmarks.getSearchURL(urls[url], null);
|
||||||
if (search_url/* && search_url.length >= 1*/)
|
if (searchURL/* && searchURL.length >= 1*/)
|
||||||
{
|
{
|
||||||
urls[url] = search_url;
|
urls[url] = searchURL;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -206,6 +207,7 @@ vimperator.util = {
|
|||||||
|
|
||||||
return strNum[0] + " " + unitVal[unitIndex];
|
return strNum[0] + " " + unitVal[unitIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// vim: set fdm=marker sw=4 ts=4 et:
|
// vim: set fdm=marker sw=4 ts=4 et:
|
||||||
|
|||||||
@@ -33,11 +33,11 @@ const vimperator = (function () //{{{
|
|||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
// our services
|
// our services
|
||||||
var sound_service = Components.classes["@mozilla.org/sound;1"]
|
var soundService = Components.classes["@mozilla.org/sound;1"]
|
||||||
.getService(Components.interfaces.nsISound);
|
.getService(Components.interfaces.nsISound);
|
||||||
var console_service = Components.classes["@mozilla.org/consoleservice;1"]
|
var consoleService = Components.classes["@mozilla.org/consoleservice;1"]
|
||||||
.getService(Components.interfaces.nsIConsoleService);
|
.getService(Components.interfaces.nsIConsoleService);
|
||||||
var environment_service = Components.classes["@mozilla.org/process/environment;1"]
|
var environmentService = Components.classes["@mozilla.org/process/environment;1"]
|
||||||
.getService(Components.interfaces.nsIEnvironment);
|
.getService(Components.interfaces.nsIEnvironment);
|
||||||
|
|
||||||
var callbacks = [];
|
var callbacks = [];
|
||||||
@@ -107,7 +107,7 @@ const vimperator = (function () //{{{
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sound_service.beep();
|
soundService.beep();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -296,7 +296,7 @@ const vimperator = (function () //{{{
|
|||||||
if (typeof msg == "object")
|
if (typeof msg == "object")
|
||||||
msg = this.objectToString(msg, false);
|
msg = this.objectToString(msg, false);
|
||||||
|
|
||||||
console_service.logStringMessage("vimperator: " + msg);
|
consoleService.logStringMessage("vimperator: " + msg);
|
||||||
},
|
},
|
||||||
|
|
||||||
// open one or more URLs
|
// open one or more URLs
|
||||||
@@ -369,9 +369,9 @@ const vimperator = (function () //{{{
|
|||||||
},
|
},
|
||||||
|
|
||||||
// quit vimperator, no matter how many tabs/windows are open
|
// quit vimperator, no matter how many tabs/windows are open
|
||||||
quit: function (save_session)
|
quit: function (saveSession)
|
||||||
{
|
{
|
||||||
if (save_session)
|
if (saveSession)
|
||||||
vimperator.options.setFirefoxPref("browser.startup.page", 3); // start with saved session
|
vimperator.options.setFirefoxPref("browser.startup.page", 3); // start with saved session
|
||||||
else
|
else
|
||||||
vimperator.options.setFirefoxPref("browser.startup.page", 1); // start with default homepage session
|
vimperator.options.setFirefoxPref("browser.startup.page", 1); // start with default homepage session
|
||||||
@@ -428,7 +428,7 @@ const vimperator = (function () //{{{
|
|||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
var dirs = environment_service.get("PATH").split(WINDOWS ? ";" : ":");
|
var dirs = environmentService.get("PATH").split(WINDOWS ? ";" : ":");
|
||||||
for (var i = 0; i < dirs.length; i++)
|
for (var i = 0; i < dirs.length; i++)
|
||||||
{
|
{
|
||||||
var path = dirs[i] + (WINDOWS ? "\\" : "/") + program;
|
var path = dirs[i] + (WINDOWS ? "\\" : "/") + program;
|
||||||
@@ -522,16 +522,16 @@ const vimperator = (function () //{{{
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
var heredoc = "";
|
var heredoc = "";
|
||||||
var heredoc_end = null; // the string which ends the heredoc
|
var heredocEnd = null; // the string which ends the heredoc
|
||||||
str.split("\n").forEach(function (line)
|
str.split("\n").forEach(function (line)
|
||||||
{
|
{
|
||||||
if (heredoc_end) // we already are in a heredoc
|
if (heredocEnd) // we already are in a heredoc
|
||||||
{
|
{
|
||||||
if (heredoc_end.test(line))
|
if (heredocEnd.test(line))
|
||||||
{
|
{
|
||||||
eval("with(vimperator){" + heredoc + "}");
|
eval("with(vimperator){" + heredoc + "}");
|
||||||
heredoc = "";
|
heredoc = "";
|
||||||
heredoc_end = null;
|
heredocEnd = null;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -548,7 +548,7 @@ const vimperator = (function () //{{{
|
|||||||
var matches = args.match(/(.*)<<\s*([^\s]+)$/);
|
var matches = args.match(/(.*)<<\s*([^\s]+)$/);
|
||||||
if (matches)
|
if (matches)
|
||||||
{
|
{
|
||||||
heredoc_end = new RegExp("^" + matches[2] + "$", "m");
|
heredocEnd = new RegExp("^" + matches[2] + "$", "m");
|
||||||
if (matches[1])
|
if (matches[1])
|
||||||
heredoc = matches[1] + "\n";
|
heredoc = matches[1] + "\n";
|
||||||
}
|
}
|
||||||
@@ -596,9 +596,9 @@ const vimperator = (function () //{{{
|
|||||||
vimperator.log("Loading module search...", 3);
|
vimperator.log("Loading module search...", 3);
|
||||||
vimperator.search = vimperator.Search();
|
vimperator.search = vimperator.Search();
|
||||||
vimperator.log("Loading module preview window...", 3);
|
vimperator.log("Loading module preview window...", 3);
|
||||||
vimperator.previewwindow = vimperator.InformationList("vimperator-previewwindow", { incremental_fill: false, max_items: 10 });
|
vimperator.previewwindow = vimperator.InformationList("vimperator-previewwindow", { incrementalFill: false, maxItems: 10 });
|
||||||
vimperator.log("Loading module buffer window...", 3);
|
vimperator.log("Loading module buffer window...", 3);
|
||||||
vimperator.bufferwindow = vimperator.InformationList("vimperator-bufferwindow", { incremental_fill: false, max_items: 10 });
|
vimperator.bufferwindow = vimperator.InformationList("vimperator-bufferwindow", { incrementalFill: false, maxItems: 10 });
|
||||||
vimperator.log("Loading module mappings...", 3);
|
vimperator.log("Loading module mappings...", 3);
|
||||||
vimperator.mappings = vimperator.Mappings();
|
vimperator.mappings = vimperator.Mappings();
|
||||||
vimperator.log("Loading module statusline...", 3);
|
vimperator.log("Loading module statusline...", 3);
|
||||||
@@ -650,20 +650,20 @@ const vimperator = (function () //{{{
|
|||||||
// make sourcing asynchronous, otherwise commands that open new tabs won't work
|
// make sourcing asynchronous, otherwise commands that open new tabs won't work
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
|
|
||||||
var rc_file = vimperator.io.getRCFile();
|
var rcFile = vimperator.io.getRCFile();
|
||||||
|
|
||||||
if (rc_file)
|
if (rcFile)
|
||||||
vimperator.source(rc_file.path, true);
|
vimperator.source(rcFile.path, true);
|
||||||
else
|
else
|
||||||
vimperator.log("No user RC file found", 3);
|
vimperator.log("No user RC file found", 3);
|
||||||
|
|
||||||
// also source plugins in ~/.vimperator/plugin/
|
// also source plugins in ~/.vimperator/plugin/
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var plugin_dir = vimperator.io.getPluginDir();
|
var pluginDir = vimperator.io.getPluginDir();
|
||||||
if (plugin_dir)
|
if (pluginDir)
|
||||||
{
|
{
|
||||||
var files = vimperator.io.readDirectory(plugin_dir.path);
|
var files = vimperator.io.readDirectory(pluginDir.path);
|
||||||
vimperator.log("Sourcing plugin directory...", 3);
|
vimperator.log("Sourcing plugin directory...", 3);
|
||||||
files.forEach(function (file) {
|
files.forEach(function (file) {
|
||||||
if (!file.isDirectory() && /\.(js|vimp)$/i.test(file.path))
|
if (!file.isDirectory() && /\.(js|vimp)$/i.test(file.path))
|
||||||
|
|||||||
Reference in New Issue
Block a user