Re: [code] ctrl-c frequently doesn't work on Windows.

From: Danny MacMillan <>
Date: Sun, 22 Oct 2017 14:47:16 -0600

On 2017-10-22 14:24, Danny MacMillan wrote:
> On 2017-10-22 13:28, Robert Gieseke wrote:
>> But, I think you might be able to wrap Textadept's copy function in
>> Lua
>> to check if it has actually been copied.
> This is ham-fisted I know but I put this (and only this) in my
> init.lua:
> = function()
> -- get selection
> local sel = buffer.get_sel_text()
> buffer.copy()
> ui.bufstatusbar_text = ui.clipboard_text
> if sel ~= ui.clipboard_text then
> -- alert for debugging (retry, if not the same ...)
> ui.statusbar_text = "Clipboard problem ..."
> else
> ui.statusbar_text = "Clipboard just fine ..."
> end
> end
> So every time I ctrl-c, the left side of the status bar will show
> either "Clipboard problem ..." or "Clipboard just fine ..." and the
> right side will show the contents of the clipboard after the copy
> operation.
> Unfortunately even in the failure case (when the text I copied can't
> be pasted into other Windows applications), it prints "Clipboard just
> fine ..." on the left, and the text I tried to copy on the right. I
> take this to mean that ui.clipboard_text isn't actually reading the
> clipboard, but some cache. I'm far from a C expert but this chunk of
> code in textadept.c makes me think the cache must be inside GTK. So
> I'm back to square 1.

On the hypothesis that it's a race condition causing this issue, I put
this in init.lua.

-- busy-waiting is terrible but I couldn't find a ready-to-use sleep
-- This implementation is taken from here
function sleep(s)
   local ntime = os.clock() + s
   repeat until os.clock() > ntime
end = function()

With this in my init.lua, I haven't (yet) had a clipboard issue.

Maybe the reason no one else is reporting this is that their computers
are slower? It beggars belief though because even though my computer is
pretty good it's not a speed demon by any stretch.

You are subscribed to
To change subscription settings, send an e-mail to
To unsubscribe, send an e-mail to
Received on Sun 22 Oct 2017 - 16:47:16 EDT

This archive was generated by hypermail 2.2.0 : Mon 23 Oct 2017 - 06:42:22 EDT