From 20c4fb3baaac9d176e029e3680cc0c8e8101e44c Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Fri, 18 Oct 2013 12:05:32 -0400 Subject: The buffer API applies to all buffers now, not just the global one. Created a "dummy" Scintilla view for operating on non-global documents. Removed `buffer:check_global()` and replaced `buffer.dirty` with Scintilla's `buffer.modify`. --- core/ui.lua | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'core/ui.lua') diff --git a/core/ui.lua b/core/ui.lua index 67a8a661..9a1bd5a4 100644 --- a/core/ui.lua +++ b/core/ui.lua @@ -123,7 +123,7 @@ function ui.switch_buffer() local filename = buffer.filename or buffer._type or _L['Untitled'] filename = filename:iconv('UTF-8', _CHARSET) local basename = buffer.filename and filename:match('[^/\\]+$') or filename - items[#items + 1] = (buffer.dirty and '*' or '')..basename + items[#items + 1] = (buffer.modify and '*' or '')..basename items[#items + 1] = filename end local button, i = ui.dialogs.filteredlist{ @@ -261,20 +261,12 @@ local function set_title() filename = filename:iconv('UTF-8', _CHARSET) local basename = buffer.filename and filename:match('[^/\\]+$') or filename ui.title = string.format('%s %s Textadept (%s)', basename, - buffer.dirty and '*' or '-', filename) + buffer.modify and '*' or '-', filename) end --- Changes Textadept title to show the buffer as being "clean". -events_connect(events.SAVE_POINT_REACHED, function() - buffer.dirty = false - set_title() -end) - --- Changes Textadept title to show thee buffer as "dirty". -events_connect(events.SAVE_POINT_LEFT, function() - buffer.dirty = true - set_title() -end) +-- Changes Textadept title to show the buffer as being "clean" or "dirty". +events_connect(events.SAVE_POINT_REACHED, set_title) +events_connect(events.SAVE_POINT_LEFT, set_title) -- Open uri(s). events_connect(events.URI_DROPPED, function(utf8_uris) @@ -355,11 +347,11 @@ events_connect(events.VIEW_AFTER_SWITCH, update_bars) events_connect(events.RESET_AFTER, function() ui.statusbar_text = 'Lua reset' end) --- Prompts for confirmation if any buffers are dirty. +-- Prompts for confirmation if any buffers are modified. events_connect(events.QUIT, function() local list = {} for _, buffer in ipairs(_BUFFERS) do - if buffer.dirty then + if buffer.modify then local filename = buffer.filename or buffer._type or _L['Untitled'] list[#list + 1] = filename:iconv('UTF-8', _CHARSET) end -- cgit v1.2.3