diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/cpp/init.lua | 3 | ||||
-rw-r--r-- | modules/lua/init.lua | 3 | ||||
-rw-r--r-- | modules/textadept/adeptsense.lua | 4 | ||||
-rw-r--r-- | modules/textadept/find.lua | 23 | ||||
-rw-r--r-- | modules/textadept/run.lua | 4 | ||||
-rw-r--r-- | modules/textadept/session.lua | 20 |
6 files changed, 26 insertions, 31 deletions
diff --git a/modules/cpp/init.lua b/modules/cpp/init.lua index bfd8670c..95a7452c 100644 --- a/modules/cpp/init.lua +++ b/modules/cpp/init.lua @@ -67,8 +67,7 @@ end -- @name _G.keys.cpp keys.cpp = { [keys.LANGUAGE_MODULE_PREFIX] = { - m = {io.open_file, - (_HOME..'/modules/cpp/init.lua'):iconv('UTF-8', _CHARSET)}, + m = {io.open_file, _HOME..'/modules/cpp/init.lua'}, }, ['s\n'] = function() buffer:line_end() diff --git a/modules/lua/init.lua b/modules/lua/init.lua index d970e2c5..286dbdf6 100644 --- a/modules/lua/init.lua +++ b/modules/lua/init.lua @@ -140,8 +140,7 @@ end) -- @name _G.keys.lua keys.lua = { [keys.LANGUAGE_MODULE_PREFIX] = { - m = {io.open_file, - (_HOME..'/modules/lua/init.lua'):iconv('UTF-8', _CHARSET)}, + m = {io.open_file, _HOME..'/modules/lua/init.lua'}, }, ['s\n'] = M.try_to_autocomplete_end, } diff --git a/modules/textadept/adeptsense.lua b/modules/textadept/adeptsense.lua index 84938f24..63ee855b 100644 --- a/modules/textadept/adeptsense.lua +++ b/modules/textadept/adeptsense.lua @@ -812,7 +812,7 @@ function M.goto_ctag(sense, kind, title) if kind == M.FUNCTION or kind == M.FIELD then items[#items + 1] = kind:match('^[^#]+') -- class name end - items[#items + 1] = v[1]..':'..v[2] + items[#items + 1] = v[1]:iconv('UTF-8', _CHARSET)..':'..v[2] end local columns = {'Name', 'Location'} if kind == M.FUNCTION or kind == M.FIELD then @@ -822,7 +822,7 @@ function M.goto_ctag(sense, kind, title) '--output-column', '3') if not location then return end local path, line = location:match('^(%a?:?[^:]+):(.+)$') - io.open_file(path) + io.open_file(path:iconv(_CHARSET, 'UTF-8')) if not tonumber(line) then -- /^ ... $/ buffer.target_start, buffer.target_end = 0, buffer.length diff --git a/modules/textadept/find.lua b/modules/textadept/find.lua index 43a48223..0e912367 100644 --- a/modules/textadept/find.lua +++ b/modules/textadept/find.lua @@ -84,8 +84,7 @@ local preferred_view -- patterns matching folders to exclude listed in a `folders` sub-table. -- Patterns starting with '!' exclude files and folders that do not match the -- pattern that follows. Use a table of raw file extensions assigned to an --- `extensions` key for fast filtering by extension. All strings must be encoded --- in `_G._CHARSET`, not UTF-8. +-- `extensions` key for fast filtering by extension. -- The default value is `lfs.FILTER`, a filter for common binary file extensions -- and version control folders. -- @see find_in_files @@ -208,32 +207,30 @@ function M.find_incremental(text, next, anchor) end --- --- Searches directory *utf8_dir* or user-specified directory for files that --- match search text and options and prints the results to a files found buffer. +-- Searches directory *dir* or user-specified directory for files that match +-- search text and options and prints the results to a files found buffer. -- Use the `find_text`, `match_case`, `whole_word`, and `lua` fields to set the -- search text and option flags, respectively. Use `FILTER` to set the search -- filter. --- @param utf8_dir Optional UTF-8-encoded directory path to search. If `nil`, --- the user is prompted for one. +-- @param dir Optional directory path to search. If `nil`, the user is prompted +-- for one. -- @see FILTER -- @name find_in_files -function M.find_in_files(utf8_dir) - if not utf8_dir then - utf8_dir = ui.dialog('fileselect', +function M.find_in_files(dir) + dir = dir or ui.dialog('fileselect', '--title', _L['Find in Files'], '--select-only-directories', '--with-directory', (buffer.filename or ''):match('^.+[/\\]') or '', '--no-newline') - end - if utf8_dir == '' then return end + if dir == '' then return end local text = M.find_entry_text if not M.lua then text = text:gsub('([().*+?^$%%[%]-])', '%%%1') end if not M.match_case then text = text:lower() end if M.whole_word then text = '%f[%w_]'..text..'%f[^%w_]' end local matches = {_L['Find:']..' '..text} - lfs.dir_foreach(utf8_dir, function(file) + lfs.dir_foreach(dir, function(file) local match_case = M.match_case local line_num = 1 for line in io.lines(file) do @@ -374,7 +371,7 @@ function M.goto_file_found(line, next) local file, line_num = buffer:get_cur_line():match('^(.+):(%d+):.+$') if not file then if CURSES then view:goto_buffer(cur_buf) end return end textadept.editing.select_line() - ui.goto_file(file, true, preferred_view) + ui.goto_file(file:iconv(_CHARSET, 'UTF-8'), true, preferred_view) textadept.editing.goto_line(line_num) end events.connect(events.DOUBLE_CLICK, function(pos, line) diff --git a/modules/textadept/run.lua b/modules/textadept/run.lua index 67850924..87e292c4 100644 --- a/modules/textadept/run.lua +++ b/modules/textadept/run.lua @@ -56,8 +56,7 @@ local function command(cmd_table, compiling) if type(command) == 'function' then command = command() end preferred_view = view - local filepath = buffer.filename:iconv(_CHARSET, 'UTF-8') - local filedir, filename = '', filepath + local filepath, filedir, filename = buffer.filename, '', buffer.filename if filepath:find('[/\\]') then filedir, filename = filepath:match('^(.+[/\\])([^/\\]+)$') end @@ -92,6 +91,7 @@ local function get_error_details(message) if #captures > 0 then local details = {} for detail, i in pairs(error_detail) do details[detail] = captures[i] end + details.filename = details.filename:iconv(_CHARSET, 'UTF-8') return details end end diff --git a/modules/textadept/session.lua b/modules/textadept/session.lua index 81023328..7d10ab46 100644 --- a/modules/textadept/session.lua +++ b/modules/textadept/session.lua @@ -40,13 +40,13 @@ M.MAX_RECENT_FILES = 10 -- @see DEFAULT_SESSION -- @name load function M.load(filename) + local dir = M.DEFAULT_SESSION:match('^.+[/\\]') or '' + local name = M.DEFAULT_SESSION:match('[^/\\]+$') or '' filename = filename or ui.dialog('fileselect', '--title', _L['Load Session'], - '--with-directory', - M.DEFAULT_SESSION:match('.+[/\\]') or '', - '--with-file', - M.DEFAULT_SESSION:match('[^/\\]+$') or '', - '--no-newline'):iconv(_CHARSET, 'UTF-8') + '--with-directory', dir, + '--with-file', name, + '--no-newline') if filename == '' then return end local not_found = {} local f = io.open(filename, 'rb') @@ -127,13 +127,13 @@ end) -- @see DEFAULT_SESSION -- @name save function M.save(filename) + local dir = M.DEFAULT_SESSION:match('^.+[/\\]') or '' + local name = M.DEFAULT_SESSION:match('[^/\\]+$') or '' filename = filename or ui.dialog('filesave', '--title', _L['Save Session'], - '--with-directory', - M.DEFAULT_SESSION:match('.+[/\\]') or '', - '--with-file', - M.DEFAULT_SESSION:match('[^/\\]+$') or '', - '--no-newline'):iconv(_CHARSET, 'UTF-8') + '--with-directory', dir, + '--with-file', name:iconv('UTF-8', _CHARSET), + '--no-newline') if filename == '' then return end local session = {} local buffer_line = "buffer: %d %d %d %s" -- anchor, cursor, line, filename |