1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-21 19:17:59 +01:00

added goUp() and isDirectory(uri) functions

gu and gU mappings for going up
This commit is contained in:
Martin Stubenschrott
2007-04-28 12:14:37 +00:00
parent 17cbe30053
commit 4019129519
4 changed files with 68 additions and 8 deletions

View File

@@ -1,9 +1,12 @@
<pre>
date:
* version 0.4
* extension GUID was changed to 'vimperator@mozdev.net' -> YOU WILL HAVE
TO UNINSTALL ANY OLD VIMPERATOR INSTALLATION BEFORE INSTALLING THIS VERSION
* support for 'wildmode' completion setting
* changed regexp search to normal text search for completion -> massive speedup, but limited functionality
* support for :open ./ , :open .. and :open ... (patch from Lee Hinman)
'gu' and <BackSpace> goes up a directory component, gU and <C-BackSpace> to the root directory
* Esc now doesn't stop loading the webpage, use Ctrl-c instead, :stop command added
* changed hinttags to work with dict.leo.org and hintstyle to work with digg.com
* :back! goes to beginning of history now
@@ -13,6 +16,7 @@ date:
(patch from Viktor Kojouharov)
* :source support, and auto-sourcing ~/.vimperatorrc on startup
* :javascript <<EOF support to execute multiline javascript code
also changed :exec to behave more vim like
* fixed saving of session
* fixed hints display when zooming in/out of a web page
* added 'B' command for continous buffer display
@@ -27,6 +31,7 @@ date:
* Support for space/shift-space/alt-left/alt-right keys without beeping
* :open without argument reloads current page, :tabopen opens an empty tab
* added 'n' and 'N' to repeat a search
* many small bug fixes
17/04/2007:
* version 0.3

3
TODO
View File

@@ -40,10 +40,9 @@ FEATURES:
6 Shift-Insert in textboxes pastes selection contents
6 page info support (ctrl-g, g<C-g>)
5 Use arrow keys in preview window, and ctrl-w+j/k to switch to from preview window
5 Sort :open completion by date?
5 Sort :open completion by date? (use 'wildsort')
5 make use of the ] and [ keys to e.g. jump to the next heading ]], next image ]i, previous textbox [t and so on
5 add tag support to adding/deleting bookmarks
4 change :exec to behave more vim like, and add a seperate :javascript << EOF command
4 Support multiple top-level windows?
3 Splitting Windows with [:sp :vsp ctrl-w,s ctrl-w,v] and closing with [ctrl-w,q], moving with [ctrl-w,w or tab]
have a look into the split browser extension

View File

@@ -124,7 +124,7 @@ var g_commands = [/*{{{*/
[
["buffers", "files", "ls"],
["buffers"],
"Shows a list of all buffers",
"Show a list of all buffers",
"If the list is already shown, close the preview window.",
buffer_preview_toggle,
null
@@ -157,7 +157,7 @@ var g_commands = [/*{{{*/
[
["execute", "exe"],
["exe[cute] {expr1} [ ... ]"],
"Executes the string that results from the evaluation of {expr1} as an Ex command.",
"Execute the string that results from the evaluation of {expr1} as an Ex command.",
"<code>:execute &#34;echo test&#34;</code> would show a message with the text &#34;test&#34;.<br/>",
execute,
null
@@ -772,6 +772,20 @@ var g_mappings = [/*{{{*/
"Count is supported, <code class=mapping>3L</code> goes forward 3 steps.",
function(count) { stepInHistory(count > 0 ? count : 1); }
],
[
["gu", "<BackSpace>"],
["{count}gu", "{count}<BackSpace>"],
"Go up one directory component",
"Count is supported, <code class=mapping>2gu</code> on <code>http://www.example.com/dir1/dir2/file.htm</code> would open <code>http://www.example.com/dir1/</code>",
goUp
],
[
["gU", "<C-BackSpace>"],
["gU", "<C-BackSpace>"],
"Go up one directory component",
"<code class=mapping>gU</code> on <code>http://www.example.com/dir1/dir2/file.htm</code> opens <code>http://www.example.com/</code>",
function(count) { openURLs("..."); }
],
/* hint managment */
[
@@ -1325,6 +1339,30 @@ function stringToURLs(str)
return urls;
}
/* returns true if the currently loaded URI is
* a directory or false if it is a file
* if passed 'url' is null, use current directory
*/
function isDirectory(url)
{
if (url.match(/^file:\/\//) || url.match(/^\//))
{
var stripedFilename = url.replace(/^(file:\/\/)?(.*)/, "$2");
var file = fopen(stripedFilename, '<');
if (!file)
return false;
if (file.localFile.isDirectory())
return true;
else
return false;
}
// for all other locations just check if the URL ends with /
if (url.match(/\/$/))
return true;
else
return false;
}
////////////////////////////////////////////////////////////////////////
// frame related functions //////////////////////////////////////// {{{1
////////////////////////////////////////////////////////////////////////
@@ -1381,6 +1419,23 @@ function getCurrentLocation()
return content.document.location.href;
}
function goUp(count)
{
var gocmd = "";
if (isDirectory(getCurrentLocation()))
gocmd = "../";
else
gocmd = "./";
if (count < 1)
count = 1;
for(var i=0; i<count-1; i--)
gocmd += "../";
openURLs(gocmd);
}
function yankCurrentLocation()
{
var loc = getCurrentLocation();

View File

@@ -41,20 +41,20 @@ function help(section, easter)
var style = "<style type='text/css'>\
table.vimperator {\
border-width: 1px 1px 1px 1px;\
border-spacing: 5px;\
/*border-spacing: 5px;*/\
border-style: dotted dotted dotted dotted;\
border-color: gray gray gray gray;\
border-collapse: separate;\
background-color: white;\
}\
table.vimperator th {\
border-width: 1px 1px 1px 1px;\
padding: 3px 3px 3px 3px;\
border-width: 0px 0px 0px 0px;\
/*padding: 3px 3px 3px 3px;*/\
border-style: hidden hidden hidden hidden;\
border-color: gray gray gray gray;\
}\
table.vimperator td {\
border-width: 1px 1px 1px 1px;\
border-width: 0px 0px 0px 0px;\
padding: 3px 3px 3px 3px;\
border-style: hidden hidden hidden hidden;\
border-color: gray gray gray gray;\
@@ -76,6 +76,7 @@ td.usage code {\
tr.tag code {\
font-weight: bold;\
font-size: 1opx;\
font-color: red;\
margin-left: 2em;\
}\
tr.desciption {\