Compare commits
No commits in common. "9c7390bad8025fdfe96295b41ccff61153b3362a" and "69535eda41b90e5aa0b69e47f73c51d08a23a97c" have entirely different histories.
9c7390bad8
...
69535eda41
2 changed files with 8 additions and 51 deletions
|
|
@ -138,7 +138,6 @@ MODE, TOPIC, and INVITE events are shown in the relevant window.
|
|||
| Key | Action |
|
||||
| --- | --- |
|
||||
| `Tab` | complete a `/` command or a nick; press again to cycle matches (recently completed nicks come first) |
|
||||
| `Ctrl+Left` / `Ctrl+Right` | move to the previous / next word in the input line |
|
||||
| `ctrl-n` / `ctrl-p` | next / previous window (tree order, wraps around) |
|
||||
| `PageUp` / `PageDown` | scroll the current window |
|
||||
| `ctrl-l` | clear the screen (history stays scrollable) |
|
||||
|
|
@ -146,7 +145,6 @@ MODE, TOPIC, and INVITE events are shown in the relevant window.
|
|||
| `ctrl-s` | save the current window’s scrollback to a new plain-text file |
|
||||
| Up / Down | command history |
|
||||
| Left / Right, Home / End | edit the input line |
|
||||
| `Del` | delete the character at the cursor |
|
||||
|
||||
At the save prompt, type a path and press Enter, or press Esc or Ctrl-G to
|
||||
cancel. Existing files are protected from overwrites.
|
||||
|
|
|
|||
57
irc9.c
57
irc9.c
|
|
@ -168,8 +168,7 @@ static long accent_color = -1;
|
|||
|
||||
enum {
|
||||
KEY_UP = 256, KEY_DOWN, KEY_LEFT, KEY_RIGHT,
|
||||
KEY_WORD_LEFT, KEY_WORD_RIGHT,
|
||||
KEY_HOME, KEY_END, KEY_PPAGE, KEY_NPAGE, KEY_DELETE
|
||||
KEY_HOME, KEY_END, KEY_PPAGE, KEY_NPAGE
|
||||
};
|
||||
|
||||
#ifdef USE_OPENSSL
|
||||
|
|
@ -2040,8 +2039,6 @@ static void save_scrollback(Window *w, const char *path)
|
|||
else appendf(w, "* saved scrollback to %s", path);
|
||||
}
|
||||
|
||||
static size_t terminal_character(const char *s, size_t available, int *width);
|
||||
|
||||
static void edit_line(int c, char text[MAXINPUT], int *len, int *pos)
|
||||
{
|
||||
if (c == 127 || c == 8) {
|
||||
|
|
@ -2054,32 +2051,8 @@ static void edit_line(int c, char text[MAXINPUT], int *len, int *pos)
|
|||
input_dirty = 1;
|
||||
return;
|
||||
}
|
||||
if (c == KEY_DELETE) {
|
||||
if (*pos < *len) {
|
||||
int width;
|
||||
size_t remaining = (size_t)(*len - *pos);
|
||||
size_t bytes = terminal_character(text + *pos, remaining, &width);
|
||||
if (!bytes) bytes = 1;
|
||||
memmove(text + *pos, text + *pos + bytes, remaining - bytes + 1);
|
||||
*len -= (int)bytes;
|
||||
input_dirty = 1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (c == KEY_LEFT) { if (*pos > 0) (*pos)--; input_dirty = 1; return; }
|
||||
if (c == KEY_RIGHT) { if (*pos < *len) (*pos)++; input_dirty = 1; return; }
|
||||
if (c == KEY_WORD_LEFT) {
|
||||
while (*pos > 0 && isspace((unsigned char)text[*pos - 1])) --*pos;
|
||||
while (*pos > 0 && !isspace((unsigned char)text[*pos - 1])) --*pos;
|
||||
input_dirty = 1;
|
||||
return;
|
||||
}
|
||||
if (c == KEY_WORD_RIGHT) {
|
||||
while (*pos < *len && !isspace((unsigned char)text[*pos])) ++*pos;
|
||||
while (*pos < *len && isspace((unsigned char)text[*pos])) ++*pos;
|
||||
input_dirty = 1;
|
||||
return;
|
||||
}
|
||||
if (c == KEY_HOME) { *pos = 0; input_dirty = 1; return; }
|
||||
if (c == KEY_END) { *pos = *len; input_dirty = 1; return; }
|
||||
if (((c >= 32 && c < 127) || (c >= 0x80 && c < 0x100)) &&
|
||||
|
|
@ -2474,7 +2447,7 @@ static void draw_title(void)
|
|||
fputs("\033[0m", stdout);
|
||||
}
|
||||
|
||||
/* Include the topic divider when calculating the chat pane height. */
|
||||
/* Use the same topic height for drawing and paging the chat pane. */
|
||||
static int layout_topic(int draw)
|
||||
{
|
||||
int width = cols - treew - (copy_view ? 0 : 2);
|
||||
|
|
@ -2488,22 +2461,14 @@ static int layout_topic(int draw)
|
|||
int count = 0;
|
||||
push_wrapped(rows, &count, MAXWRAPROWS, topic, width);
|
||||
|
||||
int divider = mainh >= 3;
|
||||
int limit = mainh > 1 ? mainh - 1 - divider : 1;
|
||||
int left = treew + (copy_view ? 0 : 1);
|
||||
int limit = mainh > 1 ? mainh - 1 : 1;
|
||||
int height = count < limit ? count : limit;
|
||||
for (int row = 0; row < count; row++) {
|
||||
char *text = rows[count - 1 - row];
|
||||
if (draw && row < height) draw_irc_text(row + 1, left, text, width);
|
||||
if (draw && row < height) draw_irc_text(row + 1, treew + (copy_view ? 0 : 1), text, width);
|
||||
free(text);
|
||||
}
|
||||
if (draw && divider) {
|
||||
terminal_move(height + 1, left);
|
||||
terminal_accent();
|
||||
terminal_repeat('-', width);
|
||||
fputs("\033[0m", stdout);
|
||||
}
|
||||
return height + divider;
|
||||
return height;
|
||||
}
|
||||
|
||||
static void draw_main(void)
|
||||
|
|
@ -2659,7 +2624,7 @@ static void terminal_start(void)
|
|||
/* Decode both normal and application cursor keys, including split reads. */
|
||||
static void terminal_read_keys(void)
|
||||
{
|
||||
static int state, number, parameters, modifier;
|
||||
static int state, number, parameters;
|
||||
static struct timespec last_escape;
|
||||
struct timespec now = {0};
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
|
|
@ -2682,19 +2647,15 @@ static void terminal_read_keys(void)
|
|||
if (c == '[' || c == 'O') {
|
||||
state = c;
|
||||
number = parameters = 0;
|
||||
modifier = -1;
|
||||
continue;
|
||||
}
|
||||
state = 0;
|
||||
} else if (state) {
|
||||
if (c >= '0' && c <= '9') {
|
||||
if (!parameters && number < 100) number = number * 10 + c - '0';
|
||||
else if (modifier >= 0 && modifier < 100)
|
||||
modifier = modifier * 10 + c - '0';
|
||||
continue;
|
||||
}
|
||||
if (c >= 0x20 && c <= 0x3f) {
|
||||
modifier = (!parameters && c == ';') ? 0 : -1;
|
||||
parameters = 1;
|
||||
continue;
|
||||
}
|
||||
|
|
@ -2709,18 +2670,16 @@ static void terminal_read_keys(void)
|
|||
continue;
|
||||
}
|
||||
if (sequence == -1) continue;
|
||||
int ctrl_arrow = sequence == '[' && number == 1 && modifier == 5;
|
||||
switch (c) {
|
||||
case 'A': c = KEY_UP; break;
|
||||
case 'B': c = KEY_DOWN; break;
|
||||
case 'C': c = ctrl_arrow ? KEY_WORD_RIGHT : KEY_RIGHT; break;
|
||||
case 'D': c = ctrl_arrow ? KEY_WORD_LEFT : KEY_LEFT; break;
|
||||
case 'C': c = KEY_RIGHT; break;
|
||||
case 'D': c = KEY_LEFT; break;
|
||||
case 'H': c = KEY_HOME; break;
|
||||
case 'F': c = KEY_END; break;
|
||||
case '~':
|
||||
switch (number) {
|
||||
case 1: case 7: c = KEY_HOME; break;
|
||||
case 3: c = KEY_DELETE; break;
|
||||
case 4: case 8: c = KEY_END; break;
|
||||
case 5: c = KEY_PPAGE; break;
|
||||
case 6: c = KEY_NPAGE; break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue