From 0aeee25e659e22d1d612340c7b455d107b5ccd70 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Wed, 7 Jan 2009 17:38:57 -0500 Subject: [PATCH] Add standard 'mark' completer. Fix x/y transposition in :delm completion --- common/content/buffer.js | 15 +++------------ common/content/completion.js | 13 +++++++++++++ vimperator/content/bookmarks.js | 2 +- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/common/content/buffer.js b/common/content/buffer.js index 4bea55c2..7985778e 100644 --- a/common/content/buffer.js +++ b/common/content/buffer.js @@ -1653,18 +1653,7 @@ function Marks() //{{{ }, { bang: true, - completer: function (context) - { - let marks = getSortedMarks(); - - function markinfo( m ) - { - return Math.round(m.position.x * 100) + "% " + Math.round(m.position.y * 100) + "% " + m.location; - } - - context.title = ["Mark", "Line/Column/File"]; - context.completions = [[mark[0], markinfo(mark[1])] for each (mark in marks)]; - } + completer: function (context) completion.mark(context) }); commands.add(["ma[rk]"], @@ -1710,6 +1699,8 @@ function Marks() //{{{ return { + get all() getSortedMarks(), + /** * Add a named mark for the current buffer, at its current position. * If mark matches [A-Z], it's considered a URL mark, and will jump to diff --git a/common/content/completion.js b/common/content/completion.js index 2cf7aa1f..0c1c2dfe 100644 --- a/common/content/completion.js +++ b/common/content/completion.js @@ -1608,6 +1608,19 @@ function Completion() //{{{ context.completions = [item for (item in events.getMacros())]; }, + mark: function mark(context) + { + function percent(i) Math.round(i * 100); + + // FIXME: Line/Column doesn't make sense with % + context.title = ["Mark", "Line Column File"]; + context.keys = { + text: 0, + description: function ([,m]) percent(m.position.y) + "% " + percent(m.position.x) + "% " + m.location + }; + context.completions = marks.all; + }, + menuItem: function menuItem(filter) commands.get("emenu").completer(filter), // XXX option: function option(context, scope) diff --git a/vimperator/content/bookmarks.js b/vimperator/content/bookmarks.js index c8cb2247..7e89fe7d 100644 --- a/vimperator/content/bookmarks.js +++ b/vimperator/content/bookmarks.js @@ -967,7 +967,7 @@ function QuickMarks() //{{{ completer: function (context) { context.title = ["QuickMark", "URL"]; - context.completions = [[key, val] for ([key, val] in qmarks)]; + context.completions = qmarks; } });