1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-06 05:14:11 +01:00

initial buffer implementation

This commit is contained in:
Doug Kearns
2007-08-07 14:19:20 +00:00
parent 4c919b8ea0
commit ad44a9160c
8 changed files with 369 additions and 266 deletions

View File

@@ -402,98 +402,6 @@ const vimperator = (function() //{{{
.quit(nsIAppStartup.eRestart | nsIAppStartup.eAttemptQuit);
},
// TODO: allow callback for filtering out unwanted frames? User defined?
shiftFrameFocus: function(count, forward)
{
try
{
var frames = [];
// find all frames - depth-first search
(function(frame)
{
if (frame.document.body.localName.toLowerCase() == "body")
frames.push(frame);
for (var i = 0; i < frame.frames.length; i++)
arguments.callee(frame.frames[i])
})(window.content);
if (frames.length == 0) // currently top is always included
return;
// remove all unfocusable frames
// TODO: find a better way to do this
var start = document.commandDispatcher.focusedWindow;
frames = frames.filter(function(frame) {
frame.focus();
if (document.commandDispatcher.focusedWindow == frame)
return frame;
});
start.focus();
// find the currently focused frame index
// TODO: If the window is a frameset then the first _frame_ should be
// focused. Since this is not the current FF behaviour,
// we initalise current to -1 so the first call takes us to the
// first frame.
var current = -1;
for (var i = 0; i < frames.length; i++)
{
if (frames[i] == document.commandDispatcher.focusedWindow)
{
var current = i;
break;
}
}
// calculate the next frame to focus
var next = current;
if (forward)
{
if (count > 1)
next = current + count;
else
next++;
if (next > frames.length - 1)
next = frames.length - 1;
}
else
{
if (count > 1)
next = current - count;
else
next--;
if (next < 0)
next = 0;
}
// focus next frame and scroll into view
frames[next].focus();
if (frames[next] != window.content)
frames[next].frameElement.scrollIntoView(false);
// add the frame indicator
var doc = frames[next].document;
var indicator = doc.createElement("div");
indicator.id = "vimperator-frame-indicator";
// NOTE: need to set a high z-index - it's a crapshoot!
var style = "background-color: red; opacity: 0.5; z-index: 999;" +
"position: fixed; top: 0; bottom: 0; left: 0; right: 0;";
indicator.setAttribute("style", style);
doc.body.appendChild(indicator);
// remove the frame indicator
setTimeout(function() { doc.body.removeChild(indicator); }, 500);
}
catch (e)
{
//vimperator.echoerr(e);
// FIXME: fail silently here for now
}
},
// files which end in .js are sourced as pure javascript files,
// no need (actually forbidden) to add: js <<EOF ... EOF around those files
source: function(filename, silent)
@@ -607,6 +515,8 @@ const vimperator = (function() //{{{
vimperator.mappings = new Mappings();
vimperator.log("Loading module statusline...", 3);
vimperator.statusline = new StatusLine();
vimperator.log("Loading module buffer...", 3);
vimperator.buffer = new Buffer();
vimperator.log("Loading module tabs...", 3);
vimperator.tabs = new Tabs();
vimperator.log("Loading module marks...", 3);
@@ -669,42 +579,7 @@ const vimperator = (function() //{{{
vimperator.events.destroy();
vimperator.options.destroy();
vimperator.quickmarks.destroy();
},
// @param value MUST be a string, it can have the following form: "+20%", "200%", "-30"
// @return false if argument could not be parsed or zoom level too high
zoom: function(value)
{
if (typeof value != "string")
return false;
var zoomMgr = ZoomManager.prototype.getInstance();
var new_zoom_value = 100;
var matches = value.match(/^\s*(\+|-)?(\d+)(%)?\s*/);
if (!matches || !matches[2])
return false;
if (matches[1] == "+")
new_zoom_value = zoomMgr.textZoom + parseInt(matches[2]);
else if (matches[1] == "-")
new_zoom_value = zoomMgr.textZoom - parseInt(matches[2]);
else
new_zoom_value = parseInt(matches[2]);
if (new_zoom_value < 25 || new_zoom_value > 500)
{
vimperator.echoerr("Zoom value must be between 25% and 500%");
vimperator.beep();
return false;
}
zoomMgr.textZoom = new_zoom_value;
vimperator.hints.reshowHints();
vimperator.echo("Zoom value: " + new_zoom_value + "%");
}
} //}}}
})(); //}}}