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

From: Danny MacMillan <>
Date: Sun, 22 Oct 2017 14:24:01 -0600

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.
> Something like the proposal here
> = function()
> -- get selection
> local sel = buffer.get_sel_text()
> buffer.copy()
> if sel ~= ui.clipboard_text then
> -- alert for debugging (retry, if not the same ...)
> ui.dialogs.msgbox({text="Clipboard problem ...")
> end
> end
> Could be applied to Textadept if that would fix it. Maybe wrapping the
> retries with some timeout and limit ...

Thanks for the idea.

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()
   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 ..."
     ui.statusbar_text = "Clipboard just fine ..."

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.

/** `ui.__index` Lua metamethod. */
static int lui__index(lua_State *L) {
   const char *key = lua_tostring(L, 2);
   if (strcmp(key, "clipboard_text") == 0) {
#if GTK
     char *text = gtk_clipboard_wait_for_text(
     lua_pushstring(L, text ? text : "");
     if (text) free(text);
#elif CURSES

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:24:01 EDT

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