2 Commits

Author SHA1 Message Date
p a1c7d2c983 xC/xF: make it possible to insert newlines directly
Alpine 3.24 Success
Arch Linux AUR Success
OpenBSD 7.8 Success
That should do for us to stop claiming that the interface needs polish.
2026-08-10 08:22:33 +02:00
p 63d54df66a xC: add a basic C-t binding 2026-08-10 08:02:29 +02:00
3 changed files with 37 additions and 3 deletions
+1 -3
View File
@@ -11,9 +11,7 @@ They're all lean on dependencies, and offer a maximally permissive licence.
xC
--
The IRC client, and the core of 'xK'. Its interface should feel somewhat
familiar for WeeChat or irssi users. Currently the terminal interface
experience deserves some polishing, because we've just got rid of
Readline/Editline dependencies, which kept breaking in exciting ways.
familiar for WeeChat or irssi users.
image::xC.webp[align="center"]
+31
View File
@@ -815,6 +815,23 @@ INPUT_FN (kill_line)
return true;
}
INPUT_FN (transpose_chars)
// TODO(p): Better Unicode processing.
if (buffer->point < 1 || buffer->len < 2)
return false;
if (buffer->point == (int) buffer->len)
buffer->point--;
uint32_t cp = buffer->line[buffer->point];
int width = buffer->w[buffer->point];
buffer->line[buffer->point] = buffer->line[buffer->point - 1];
buffer->w [buffer->point] = buffer->w [buffer->point - 1];
buffer->line[buffer->point - 1] = cp;
buffer->w [buffer->point - 1] = width;
buffer->point++;
return true;
}
INPUT_FN (upcase_word)
// TODO(p): Better Unicode processing.
int i = buffer->point;
@@ -938,6 +955,9 @@ g_input_actions[] =
{ "kill-line", "Delete everything up to EOL",
input_kill_line,
(const char *[]) { "C-k", NULL } },
{ "transpose-chars", "Transpose characters before and at the cursor",
input_transpose_chars,
(const char *[]) { "C-t", NULL } },
{ "upcase-word", "Convert word to uppercase",
input_upcase_word,
@@ -14422,6 +14442,15 @@ on_insert_attribute (int key, void *user_data)
return true;
}
static bool
on_insert_newline (int key, void *user_data)
{
(void) key;
struct app_context *ctx = user_data;
return input_insert (ctx->input, "\n");
}
#define BRACKETED_PASTE_LIMIT 102400 ///< How much text can be pasted
static bool
@@ -14616,6 +14645,7 @@ app_input_init (struct input *self)
XX ("edit-input", "Edit input", on_edit_input)
XX ("redraw-screen", "Redraw screen", on_redraw_screen)
XX ("insert-attribute", "IRC formatting", on_insert_attribute)
XX ("insert-newline", "Insert newline", on_insert_newline)
XX ("start-paste-mode", "Bracketed paste", on_start_paste_mode)
XX ("accept-line", "Send line", on_input_return)
XX ("complete", "Complete word", on_input_complete)
@@ -14636,6 +14666,7 @@ app_input_init (struct input *self)
input_bind (self, "M-a", "goto-activity");
input_bind (self, "M-A", "goto-backtivity");
input_bind (self, "M-m", "insert-attribute");
input_bind (self, "M-Enter", "insert-newline");
input_bind (self, "M-h", "display-full-log");
input_bind (self, "M-H", "toggle-unimportant");
input_bind (self, "M-e", "edit-input");
+5
View File
@@ -278,6 +278,7 @@ enum action
ACTION_EDIT_INPUT,
ACTION_VIEW_TRANSCRIPT,
ACTION_OPEN,
ACTION_INSERT_NEWLINE,
ACTION_FORMAT,
ACTION_FORMAT_BOLD,
ACTION_FORMAT_ITALIC,
@@ -3980,6 +3981,9 @@ app_process_action (enum action action)
return app_launch_transcript_editor ();
case ACTION_OPEN:
return app_open_last_link ();
case ACTION_INSERT_NEWLINE:
app_editor_insert ('\n');
return true;
case ACTION_FORMAT:
g.inserting_attribute = true;
return true;
@@ -4155,6 +4159,7 @@ g_default_bindings[] =
{ "M-e", ACTION_EDIT_INPUT }, // xC
{ "M-E", ACTION_VIEW_TRANSCRIPT }, // xF
{ "C-o", ACTION_OPEN }, // xF
{ "M-Enter", ACTION_INSERT_NEWLINE },
{ "M-m", ACTION_FORMAT }, // xC
{ "PageUp", ACTION_SCROLL_UP },
{ "PageDown", ACTION_SCROLL_DOWN },