xF: support pasting from clipboard
Bump liberty. Most of the change happens in liberty-xui.
This commit is contained in:
+1
-1
Submodule liberty updated: bb75c8e4fa...285dacb785
@@ -279,6 +279,7 @@ enum action
|
||||
ACTION_VIEW_TRANSCRIPT,
|
||||
ACTION_OPEN,
|
||||
ACTION_INSERT_NEWLINE,
|
||||
ACTION_PASTE,
|
||||
ACTION_FORMAT,
|
||||
ACTION_FORMAT_BOLD,
|
||||
ACTION_FORMAT_ITALIC,
|
||||
@@ -2282,6 +2283,20 @@ app_on_clipboard_copy (const char *text)
|
||||
print_status ("copied to clipboard: %s", text);
|
||||
}
|
||||
|
||||
static void
|
||||
app_on_clipboard_paste (const char *text)
|
||||
{
|
||||
if (!text)
|
||||
return;
|
||||
|
||||
struct utf8_iter iter = utf8_iter_make (text);
|
||||
int32_t codepoint = 0;
|
||||
size_t codepoint_len = 0;
|
||||
while ((codepoint = utf8_iter_next (&iter, &codepoint_len)) >= 0)
|
||||
app_editor_insert (codepoint);
|
||||
xui_invalidate ();
|
||||
}
|
||||
|
||||
static void
|
||||
app_select_backend (void)
|
||||
{
|
||||
@@ -3984,6 +3999,11 @@ app_process_action (enum action action)
|
||||
case ACTION_INSERT_NEWLINE:
|
||||
app_editor_insert ('\n');
|
||||
return true;
|
||||
case ACTION_PASTE:
|
||||
if (!g_xui.ui->request_clipboard)
|
||||
return false;
|
||||
g_xui.ui->request_clipboard ();
|
||||
return true;
|
||||
case ACTION_FORMAT:
|
||||
g.inserting_attribute = true;
|
||||
return true;
|
||||
@@ -4160,6 +4180,8 @@ g_default_bindings[] =
|
||||
{ "M-E", ACTION_VIEW_TRANSCRIPT }, // xF
|
||||
{ "C-o", ACTION_OPEN }, // xF
|
||||
{ "M-Enter", ACTION_INSERT_NEWLINE },
|
||||
{ "C-v", ACTION_PASTE },
|
||||
{ "S-Insert", ACTION_PASTE },
|
||||
{ "M-m", ACTION_FORMAT }, // xC
|
||||
{ "PageUp", ACTION_SCROLL_UP },
|
||||
{ "PageDown", ACTION_SCROLL_DOWN },
|
||||
|
||||
Reference in New Issue
Block a user