From 728cda221560dd70ee7c7bd3d41ff6ba4980955f Mon Sep 17 00:00:00 2001 From: kepler155c Date: Sat, 14 Oct 2017 13:40:16 -0400 Subject: [PATCH] non-global clipboard --- apps/edit.lua | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/apps/edit.lua b/apps/edit.lua index 9cb5b30..e5a4df3 100644 --- a/apps/edit.lua +++ b/apps/edit.lua @@ -314,8 +314,8 @@ local function writeHighlighted(sLine, ny) text = '', } - local function tryWrite(sLine, regex, fgcolor) - local match = sLine:match(regex) + local function tryWrite(line, regex, fgcolor) + local match = line:match(regex) if match then local fg if type(fgcolor) == "string" then @@ -325,7 +325,7 @@ local function writeHighlighted(sLine, ny) end buffer.text = buffer.text .. match buffer.fg = buffer.fg .. string.rep(fg, #match) - return sLine:sub(#match + 1) + return line:sub(#match + 1) end return nil end @@ -452,12 +452,12 @@ local function hacky_read() local _oldSetCursorPos = term.setCursorPos local _oldGetCursorPos = term.getCursorPos - term.setCursorPos = function(x, y) - return _oldSetCursorPos(x, h) + term.setCursorPos = function(cx) + return _oldSetCursorPos(cx, h) end term.getCursorPos = function() - local x, y = _oldGetCursorPos() - return x, 1 + local cx = _oldGetCursorPos() + return cx, 1 end local s, m = pcall(function() return read() end) @@ -986,18 +986,18 @@ local __actions = { local count = 0 local lines = { } - for _ = csy, cey do - local line = tLines[y] + for cy = csy, cey do + local line = tLines[cy] if line then - local x = 1 + local cx = 1 local ex = #line - if y == csy then - x = csx + if cy == csy then + cx = csx end - if y == cey then + if cy == cey then ex = cex - 1 end - local str = line:sub(x, ex) + local str = line:sub(cx, ex) count = count + #str table.insert(lines, str) end @@ -1055,6 +1055,7 @@ local __actions = { setStatus('Using system clipboard') end end + mark.continue = mark.active end, copy_marked = function() @@ -1063,6 +1064,7 @@ local __actions = { clipboard.setData(text) clipboard.useInternal(true) else + debug(text) os.queueEvent('clipboard_copy', text) end setStatus('%d chars copied', size)