aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2009-02-22 22:55:06 -0500
committermitchell <70453897+667e-11@users.noreply.github.com>2009-02-22 22:55:06 -0500
commitbf802c64d24f8e3a2cb71c6d7c1c07ac14b12bd4 (patch)
treedd2d2613707122ec535e95f3d3c2a9420d8ef92c
parent4a245bd4c1db90045988035facad3e55d2b6f45d (diff)
downloadtextadept-bf802c64d24f8e3a2cb71c6d7c1c07ac14b12bd4.tar.gz
textadept-bf802c64d24f8e3a2cb71c6d7c1c07ac14b12bd4.zip
Added key commands and menu items to navigate 'Find in Files' list.
-rw-r--r--core/ext/find.lua39
-rw-r--r--core/ext/key_commands.lua21
-rw-r--r--core/ext/menu.lua15
-rw-r--r--core/locale.conf20
4 files changed, 83 insertions, 12 deletions
diff --git a/core/ext/find.lua b/core/ext/find.lua
index bf72b833..6bbeba0b 100644
--- a/core/ext/find.lua
+++ b/core/ext/find.lua
@@ -254,11 +254,11 @@ function find.replace_all(ftext, rtext, flags)
end
---
--- When the user double-clicks a found file, go to the line in the file the text
--- was found at.
+-- [Local function] When the user double-clicks a found file, go to the line in
+-- the file the text was found at.
-- @param pos The position of the caret.
-- @param line_num The line double-clicked.
-function goto_file(pos, line_num)
+local function goto_file(pos, line_num)
if buffer._type == locale.FIND_FILES_FOUND_BUFFER then
line = buffer:get_line(line_num)
local file, file_line_num = line:match('^(.+):(%d+):.+$')
@@ -291,3 +291,36 @@ function goto_file(pos, line_num)
end
end
textadept.events.add_handler('double_click', goto_file)
+
+---
+-- [Local function] Goes to the next or previous file found relative to the file
+-- on the current line.
+-- @param next Flag indicating whether or not to go to the next file.
+function find.goto_file_in_list(next)
+ local orig_view = view
+ for _, buffer in ipairs(textadept.buffers) do
+ if buffer._type == locale.FIND_FILES_FOUND_BUFFER then
+ for _, view in ipairs(textadept.views) do
+ if view.doc_pointer == buffer.doc_pointer then
+ view:focus()
+ local orig_line = buffer:line_from_position(buffer.current_pos)
+ local line = orig_line
+ while true do
+ line = line + (next and 1 or -1)
+ if line > buffer.line_count - 1 then line = 0 end
+ if line < 0 then line = buffer.line_count - 1 end
+ if line == orig_line then -- prevent infinite loops
+ orig_view:focus()
+ return
+ end
+ if buffer:get_line(line):match('^(.+):(%d+):.+$') then
+ buffer:goto_line(line)
+ goto_file(buffer.current_pos, line)
+ return
+ end
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/core/ext/key_commands.lua b/core/ext/key_commands.lua
index 803fa2cd..4a40ea5a 100644
--- a/core/ext/key_commands.lua
+++ b/core/ext/key_commands.lua
@@ -22,7 +22,7 @@ if not MAC then
--[[
C: B D H I J K L U
A: A B C D E F G H J K L M N P R S T U V W X Y Z
- CS: A B C D F G H I J K L M N O Q T U V X Y Z
+ CS: A B C D G H I J K L M N O Q T U V X Y Z
SA: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
CA: A B C D E F G H J K L M N O Q R S T U V W X Y Z
CSA: A B C D E F G H J K L M N O P Q R S T U V W X Y Z
@@ -96,6 +96,9 @@ if not MAC then
-- Find Next is an when find pane is focused.
-- Find Prev is ap when find pane is focused.
-- Replace is ar when find pane is focused.
+ -- Find in Files is ai when find pane is focused.
+ -- TODO: { t.find.goto_file_in_list, true }
+ -- TODO: { t.find.goto_file_in_list, false }
keys.cg = { m_editing.goto_line }
-- Tools
@@ -202,9 +205,9 @@ else
C: J L U W X Z
A: B D E H I J K L U
CS: C D G H I J K L M O Q S T U V W X Y Z
- SA: A B C D F H I J K L M N O Q R T U V X
- CA: A C E G J K L M N O Q R S T U V W X Y Z
- CSA: A C D E G H J K L M N O P Q R S T U V W X Y Z
+ SA: A B C D H I J K L M N O Q R T U V X
+ CA: A C E J K L M N O Q R S T U V W X Y Z
+ CSA: A C D E H J K L M N O P Q R S T U V W X Y Z
]]--
keys.clear_sequence = 'aesc'
@@ -276,7 +279,15 @@ else
keys.ag = { t.find.call_find_next }
keys.sag = { t.find.call_find_prev }
keys.ar = { t.find.call_replace }
- keys.cg = { m_editing.goto_line }
+ keys.saf = {
+ function()
+ t.find.in_files = true
+ t.find.focus()
+ end
+ }
+ keys.cag = { t.find.goto_file_in_list, true }
+ keys.csag = { t.find.goto_file_in_list, false }
+ keys.cg = { m_editing.goto_line }
-- Tools
keys['f2'] = { t.command_entry.focus }
diff --git a/core/ext/menu.lua b/core/ext/menu.lua
index 27788ec1..eafcefbe 100644
--- a/core/ext/menu.lua
+++ b/core/ext/menu.lua
@@ -74,6 +74,9 @@ local ID = {
FIND_AND_REPLACE = 304,
REPLACE = 305,
REPLACE_ALL = 306,
+ FIND_IN_FILES = 308,
+ GOTO_NEXT_FILE_FOUND = 309,
+ GOTO_PREV_FILE_FOUND = 310,
GOTO_LINE = 307,
-- Tools
FOCUS_COMMAND_ENTRY = 401,
@@ -202,6 +205,10 @@ local menubar = {
{ l.MENU_SEARCH_REPLACE, ID.REPLACE },
{ l.MENU_SEARCH_REPLACE_ALL, ID.REPLACE_ALL },
{ SEPARATOR, ID.SEPARATOR },
+ { l.MENU_SEARCH_FIND_IN_FILES, ID.FIND_IN_FILES },
+ { l.MENU_SEARCH_GOTO_NEXT_FILE_FOUND, ID.GOTO_NEXT_FILE_FOUND },
+ { l.MENU_SEARCH_GOTO_PREV_FILE_FOUND, ID.GOTO_PREV_FILE_FOUND },
+ { SEPARATOR, ID.SEPARATOR },
{ l.MENU_SEARCH_GOTO_LINE, ID.GOTO_LINE },
},
gtkmenu {
@@ -374,6 +381,14 @@ local actions = {
[ID.FIND_AND_REPLACE] = { t.find.focus },
[ID.REPLACE] = { t.find.call_replace },
[ID.REPLACE_ALL] = { t.find.call_replace_all },
+ [ID.FIND_IN_FILES] = {
+ function()
+ t.find.in_files = true
+ t.find.focus()
+ end
+ },
+ [ID.GOTO_NEXT_FILE_FOUND] = { t.find.goto_file_in_list, true },
+ [ID.GOTO_PREV_FILE_FOUND] = { t.find.goto_file_in_list, false },
[ID.GOTO_LINE] = { m_editing.goto_line },
-- Tools
[ID.FOCUS_COMMAND_ENTRY] = { t.command_entry.focus },
diff --git a/core/locale.conf b/core/locale.conf
index a3eacfb2..b7aed789 100644
--- a/core/locale.conf
+++ b/core/locale.conf
@@ -416,6 +416,18 @@ MENU_SEARCH_REPLACE "Replace"
MENU_SEARCH_REPLACE_ALL "Replace _All"
% core/ext/menu.lua
+% "Find in F_iles"
+MENU_SEARCH_FIND_IN_FILES "Find in F_iles"
+
+% core/ext/menu.lua
+% "Goto Next File Found"
+MENU_SEARCH_GOTO_NEXT_FILE_FOUND "Goto Next File Found"
+
+% core/ext/menu.lua
+% "Goto Previous File Found"
+MENU_SEARCH_GOTO_PREV_FILE_FOUND "Goto Previous File Found"
+
+% core/ext/menu.lua
% "gtk-jump-to"
MENU_SEARCH_GOTO_LINE "gtk-jump-to"
@@ -532,8 +544,8 @@ MENU_BUF_TITLE "_Buffers"
MENU_BUF_NEXT "_Next Buffer"
% core/ext/menu.lua
-% "_Prev Buffer"
-MENU_BUF_PREV "_Prev Buffer"
+% "_Previous Buffer"
+MENU_BUF_PREV "_Previous Buffer"
% core/ext/menu.lua
% "Toggle View _EOL"
@@ -584,8 +596,8 @@ MENU_VIEW_TITLE "_Views"
MENU_VIEW_NEXT "_Next View"
% core/ext/menu.lua
-% "_Prev View"
-MENU_VIEW_PREV "_Prev View"
+% "_Previous View"
+MENU_VIEW_PREV "_Previous View"
% core/ext/menu.lua
% "Split _Vertical"