From 0ba47873ec725db8f4ba83bac2c33664ea8fd8c1 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Wed, 6 Jun 2012 21:15:25 -0400 Subject: `gui.statusbar_text` is write-only again. --- core/gui.lua | 2 +- core/keys.lua | 19 ++++++------------- 2 files changed, 7 insertions(+), 14 deletions(-) (limited to 'core') diff --git a/core/gui.lua b/core/gui.lua index a81877b0..8eaa80ed 100644 --- a/core/gui.lua +++ b/core/gui.lua @@ -10,7 +10,7 @@ local gui = gui -- A GTK menu defining the editor's context menu. -- @field clipboard_text (string, Read-only) -- The text on the clipboard. --- @field statusbar_text (string) +-- @field statusbar_text (string, Write-only) -- The text displayed by the statusbar. -- @field docstatusbar_text (string, Write-only) -- The text displayed by the doc statusbar. diff --git a/core/keys.lua b/core/keys.lua index 08181c49..c8850fbe 100644 --- a/core/keys.lua +++ b/core/keys.lua @@ -158,8 +158,8 @@ local keychain = {} -- Clears the current key sequence. local function clear_key_sequence() - if #keychain > 0 then keychain = {} end - gui.statusbar_text = '' + -- Clearing a table is faster than re-creating one. + if #keychain == 1 then keychain[1] = nil else keychain = {} end end -- Runs a given command. @@ -237,6 +237,7 @@ local function keypress(code, shift, control, alt, meta) (meta and OSX and META or '')..(shift and SHIFT or '')..key --print(key_seq) + gui.statusbar_text = '' if #keychain > 0 and key_seq == M.CLEAR then clear_key_sequence() return true @@ -247,22 +248,14 @@ local function keypress(code, shift, control, alt, meta) for i = 1, 2 do local status = run_key_command(i == 1 and buffer:get_lexer(true)) if status > 0 then -- CHAIN or HALT - if status == HALT then - -- Clear the key sequence, but keep any status messages from the key - -- command itself. - keychain = {} - local text = gui.statusbar_text or '' - if text == _L['Invalid sequence'] or text:find(_L['Keychain:']) then - gui.statusbar_text = '' - end - end + if status == HALT then clear_key_sequence() end return true end success = success or status ~= -1 end - local size = #keychain - 1 + local size = #keychain clear_key_sequence() - if not success and size > 0 then -- INVALID keychain sequence + if not success and size > 1 then -- INVALID keychain sequence gui.statusbar_text = _L['Invalid sequence'] return true end -- cgit v1.2.3