Skip to content

Commit

Permalink
Added emacs like imcreamental search command
Browse files Browse the repository at this point in the history
- Added command.isearchForwardKs command
  This command behaves more similar to Emacs's one

- command.isearchForwardKs コマンドを追加
  command.isearchForward よりもより Emacs に近い動きをする
  • Loading branch information
mooz committed Dec 20, 2009
1 parent e4d6dd2 commit 39a61df
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 12 deletions.
Binary file modified chrome/keysnail.jar
Binary file not shown.
38 changes: 32 additions & 6 deletions content/modules/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ KeySnail.Command = {
modules: null,

/**
* Will be overridden with the kill object in killring.jsm
* will be assigned by the killring.js
*/
kill: null,

get gFindBar() {
return typeof(gFindBar) == 'undefined' ?
return typeof gFindBar === 'undefined' ?
document.getElementById('FindToolbar') : gFindBar;
},
get autoCompleteController() {
Expand All @@ -31,7 +31,7 @@ KeySnail.Command = {
}

// for window which does not have goDoCommand()
if (typeof(goDoCommand) == 'undefined')
if (typeof goDoCommand === 'undefined')
{
document.defaultView.goDoCommand = function (aCommand)
{
Expand Down Expand Up @@ -64,7 +64,7 @@ KeySnail.Command = {
{
var cand = global[aModuleName][property];

if (typeof(cand) == 'function')
if (typeof cand === 'function')
{
var arg = this.getArgList(cand);
commandList.push(aModuleName + "." + property + arg + ";");
Expand Down Expand Up @@ -124,10 +124,12 @@ KeySnail.Command = {
{
prompt.substrMatch = false;
prompt.read("Eval:",
function (aStr) {
function (code) {
try
{
Function("with (KeySnail.modules) { " + aStr + "; }")();
eval("with (KeySnail.modules) {" +
code +
" } ");
}
catch (x)
{
Expand Down Expand Up @@ -290,6 +292,26 @@ KeySnail.Command = {
this.gFindBar.close();
},

iSearchForwardKs: function (aEvent) {
if (this.gFindBar.hidden)
this.gFindBar.open();
else if (aEvent.target == this.gFindBar)
this.gFindBar.onFindAgainCommand(false);

this.gFindBar._findField.focus();
goDoCommand("cmd_selectAll");
},

iSearchBackwardKs: function (aEvent) {
if (this.gFindBar.hidden)
this.gFindBar.open();
else if (aEvent.target == this.gFindBar)
this.gFindBar.onFindAgainCommand(true);

this.gFindBar._findField.focus();
goDoCommand("cmd_selectAll");
},

iSearchForward: function () {
// this.findCommand(false);
if (this.gFindBar.hidden)
Expand Down Expand Up @@ -1235,6 +1257,10 @@ KeySnail.Command = {
goDoCommand("cmd_deleteWordForward");
},

// Behavior of these methods it's name end with *Ks is
// similar to Emacs. But the multibyte charactors will not be
// processed properly.

forwardWordKs: function (aEvent) {
this.processWord(aEvent.originalTarget, this.getForwardWord,
function (input, subword, selected, current) {
Expand Down
Binary file modified keysnail.xpi
Binary file not shown.
2 changes: 2 additions & 0 deletions locale/en-US/functions.properties
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ open_the_bookmark_toolbar_item=Open the bookmark toolbar item
copy_selected_text=Copy selected text
incremental_search_forward=Incremental search forward
incremental_search_backward=Incremental search backward
incremental_search_forward_emacs=Emacs like incremental search forward
incremental_search_backward_emacs=Emacs like incremental search backward
select_next_tab=Select next tab
select_previous_tab=Select previous tab
undo_closed_tab=Undo closed tab
Expand Down
2 changes: 2 additions & 0 deletions locale/ja/functions.properties
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ open_the_bookmark_toolbar_item=ブックマークツールバーのアイテム
copy_selected_text=選択中のテキストをコピー
incremental_search_forward=インクリメンタル検索
incremental_search_backward=逆方向インクリメンタル検索
incremental_search_forward_emacs=Emacs ライクなインクリメンタル検索
incremental_search_backward_emacs=Emacs ライクな逆方向インクリメンタル検索
select_next_tab=ひとつ右のタブへ
select_previous_tab=ひとつ左のタブへ
undo_closed_tab=閉じたタブを元に戻す
Expand Down
4 changes: 2 additions & 2 deletions schemes/00-emacs.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ SCHEME.keybindings["global"] = [
[["C-x", "s"], "focus_to_the_first_button", true],
// For Mac users, this will affect
["M-w", "copy_selected_text", true],
["C-s", "incremental_search_forward", true],
["C-r", "incremental_search_backward", true],
["C-s", "incremental_search_forward_emacs", true],
["C-r", "incremental_search_backward_emacs", true],
// Tab / Window
[["C-x", "k"], "close_tab_window"],
[["C-x", "K"], "close_the_window"],
Expand Down
4 changes: 2 additions & 2 deletions schemes/01-emacs-lightweight-osx.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ SCHEME.keybindings["global"] = [
[["C-x", "s"], "focus_to_the_first_button", true],
// For Mac users, this will affect
// ["M-w", "copy_selected_text", true],
["C-s", "incremental_search_forward", true],
["C-r", "incremental_search_backward", true],
["C-s", "incremental_search_forward_emacs", true],
["C-r", "incremental_search_backward_emacs", true],
// Tab / Window
[["C-x", "k"], "close_tab_window"],
[["C-x", "K"], "close_the_window"],
Expand Down
14 changes: 12 additions & 2 deletions share/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,22 @@ var ksBuiltin = {
incremental_search_forward: [
function() {
command.iSearchForward();
}, false],
}, true],

incremental_search_backward: [
function() {
command.iSearchBackward();
}, false],
}, true],

incremental_search_forward_emacs: [
function(ev) {
command.iSearchForwardKs(ev);
}, true],

incremental_search_backward_emacs: [
function(ev) {
command.iSearchBackwardKs(ev);
}, true],

open_the_bookmark_toolbar_item: [
function(aEvent, arg) {
Expand Down

0 comments on commit 39a61df

Please sign in to comment.