Skip to content

Commit

Permalink
Implement "sticky" private chat mode
Browse files Browse the repository at this point in the history
Now, after sending /m, next line keeps this prompt.
This not only avoids many "oops, meant to be private" cases, but also
allows easy pasting of multi-line data.
  • Loading branch information
grayed committed Jan 11, 2020
1 parent 0a52369 commit b873b7c
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions oicb.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,16 +229,27 @@ prepare_stdout(void) {

void
restore_rl(void) {
size_t len;
size_t len;

if (repeat_priv_nick) {
rl_clear_message();
rl_point = 0;
rl_insert_text("/m ");
rl_insert_text(priv_chats_nicks[0]);
rl_insert_text(" ");
kill(getpid(), SIGWINCH);
repeat_priv_nick = 0;
} else {
len = strlen(o_rl_buf);
rl_extend_line_buffer(len+2);
(void) strlcpy(rl_line_buffer, o_rl_buf, len+1);
rl_point = o_rl_point;
rl_mark = o_rl_mark;
rl_redisplay();
}

len = strlen(o_rl_buf);
rl_extend_line_buffer(len+1);
(void) strlcpy(rl_line_buffer, o_rl_buf, len+1);
free(o_rl_buf);
o_rl_buf = NULL;
rl_point = o_rl_point;
rl_mark = o_rl_mark;
rl_redisplay();
}

/*
Expand Down

0 comments on commit b873b7c

Please sign in to comment.