diff --git a/data/core/config.lua b/data/core/config.lua index 7e1ab277..bfe4fb76 100644 --- a/data/core/config.lua +++ b/data/core/config.lua @@ -19,6 +19,7 @@ config.line_limit = 80 config.max_symbols = 4000 config.max_project_files = 2000 config.transitions = true +config.blink_period = 0.8 -- Disable plugin loading setting to false the config entry -- of the same name. diff --git a/data/core/docview.lua b/data/core/docview.lua index d60f07c1..57383da7 100644 --- a/data/core/docview.lua +++ b/data/core/docview.lua @@ -47,8 +47,6 @@ DocView.translate = { end, } -local blink_period = 0.8 - function DocView:new(doc) DocView.super.new(self) @@ -290,9 +288,9 @@ function DocView:update() -- update blink timer if self == core.active_view and not self.mouse_selecting then - local n = blink_period / 2 + local n = config.blink_period / 2 local prev = self.blink_timer - self.blink_timer = (self.blink_timer + 1 / config.fps) % blink_period + self.blink_timer = (self.blink_timer + 1 / config.fps) % config.blink_period if (self.blink_timer > n) ~= (prev > n) then core.redraw = true end @@ -344,7 +342,7 @@ function DocView:draw_line_body(idx, x, y) -- draw caret if it overlaps this line if line == idx and core.active_view == self - and self.blink_timer < blink_period / 2 + and self.blink_timer < config.blink_period / 2 and system.window_has_focus() then local lh = self:get_line_height() local x1 = x + self:get_col_x_offset(line, col) diff --git a/data/core/init.lua b/data/core/init.lua index da24c930..819f26bd 100644 --- a/data/core/init.lua +++ b/data/core/init.lua @@ -877,7 +877,7 @@ end function core.on_error(err) -- write error to file - local fp = io.open(EXEDIR .. "/error.txt", "wb") + local fp = io.open(USERDIR .. "/error.txt", "wb") fp:write("Error: " .. tostring(err) .. "\n") fp:write(debug.traceback(nil, 4)) fp:close() diff --git a/data/core/statusview.lua b/data/core/statusview.lua index 8d1a3653..58421c31 100644 --- a/data/core/statusview.lua +++ b/data/core/statusview.lua @@ -108,8 +108,8 @@ function StatusView:get_items() local line, col = dv.doc:get_selection() local dirty = dv.doc:is_dirty() local indent = dv.doc.indent_info - local indent_label = indent.type == "hard" and "tabs: " or "spaces: " - local indent_size = tostring(indent.size) .. (indent.confirmed and "" or "*") + local indent_label = (indent and indent.type == "hard") and "tabs: " or "spaces: " + local indent_size = indent and tostring(indent.size) .. (indent.confirmed and "" or "*") or "unknown" return { dirty and style.accent or style.text, style.icon_font, "f", diff --git a/src/main.c b/src/main.c index ed02c11b..95f04840 100644 --- a/src/main.c +++ b/src/main.c @@ -63,11 +63,11 @@ static void init_window_icon(void) { #ifdef _WIN32 #define LITE_OS_HOME "USERPROFILE" #define LITE_PATHSEP_PATTERN "\\\\" -#define LITE_NONPATHSEP_PATTERN "[^\\\\]" +#define LITE_NONPATHSEP_PATTERN "[^\\\\]+" #else #define LITE_OS_HOME "HOME" #define LITE_PATHSEP_PATTERN "/" -#define LITE_NONPATHSEP_PATTERN "[^/]" +#define LITE_NONPATHSEP_PATTERN "[^/]+" #endif int main(int argc, char **argv) { @@ -127,23 +127,28 @@ init_lua: "local core\n" "xpcall(function()\n" " HOME = os.getenv('" LITE_OS_HOME "')\n" - " local exedir = EXEFILE:match(\"^(.+)" LITE_PATHSEP_PATTERN LITE_NONPATHSEP_PATTERN "+$\")\n" - " local prefix = exedir:match(\"^(.+)" LITE_PATHSEP_PATTERN "bin$\")\n" + " local exedir = EXEFILE:match(\"^(.*)" LITE_PATHSEP_PATTERN LITE_NONPATHSEP_PATTERN "$\")\n" + " local prefix = exedir:match(\"^(.*)" LITE_PATHSEP_PATTERN "bin$\")\n" " dofile((prefix and prefix .. '/share/lite-xl' or exedir .. '/data') .. '/core/start.lua')\n" " core = require('core')\n" " core.init()\n" " core.run()\n" "end, function(err)\n" - " system.show_fatal_error('Lite XL start error', '" - "Fatal error: cannot locate the data directory.\\n" - "Please verify that the data folder is available.')\n" - " local fp = io.open((exedir and exedir .. '/' or '') .. 'error.txt', 'wb')\n" - " fp:write('Error: ' .. tostring(err) .. '\\n')\n" - " fp:write(debug.traceback(nil, 2) .. '\\n')\n" - " fp:close()\n" + " local error_dir\n" + " print('ERROR', err)\n" " if core and core.on_error then\n" + " error_dir=USERDIR\n" " pcall(core.on_error, err)\n" + " else\n" + " error_dir=system.absolute_path('.')\n" + " local fp = io.open('error.txt', 'wb')\n" + " fp:write('Error: ' .. tostring(err) .. '\\n')\n" + " fp:write(debug.traceback(nil, 4))\n" + " fp:close()\n" " end\n" + " system.show_fatal_error('Lite XL internal error',\n" + " 'An internal error occurred in a critical part of the application.\\n\\n'..\n" + " 'Please verify the file \\\"error.txt\\\" in the directory '..error_dir)\n" " os.exit(1)\n" "end)\n" "return core and core.restart_request\n";