Add a top divider to the chat pane
This commit is contained in:
parent
38df64d3b2
commit
5d311bbef4
2 changed files with 13 additions and 11 deletions
|
|
@ -110,8 +110,9 @@ Build yours by copying `irc9rc-example` to `irc9rc` next to the binary (or to
|
||||||
|
|
||||||
```
|
```
|
||||||
[irc9] irc.example / #general
|
[irc9] irc.example / #general
|
||||||
/----------------------\ Topic: General discussion
|
/----------------------\----------------------------------------
|
||||||
|* irc.example |
|
|* irc.example | Topic: General discussion
|
||||||
|
| | ---------------------------------------
|
||||||
| |-#general |
|
| |-#general |
|
||||||
| |-#help(3) |
|
| |-#help(3) |
|
||||||
| \-alice | [10:21] <alice> hello there
|
| \-alice | [10:21] <alice> hello there
|
||||||
|
|
|
||||||
19
irc9.c
19
irc9.c
|
|
@ -160,7 +160,7 @@ static int dirty = 1;
|
||||||
static int input_dirty;
|
static int input_dirty;
|
||||||
static time_t status_minute;
|
static time_t status_minute;
|
||||||
static int cols = 80, lines = 24;
|
static int cols = 80, lines = 24;
|
||||||
static int treew = TREEW, mainh = 1;
|
static int treew = TREEW, mainh = 1, chat_top = 1;
|
||||||
static struct termios saved_terminal;
|
static struct termios saved_terminal;
|
||||||
static int terminal_active;
|
static int terminal_active;
|
||||||
static int terminal_color;
|
static int terminal_color;
|
||||||
|
|
@ -2245,7 +2245,8 @@ static void layout(void)
|
||||||
treew = cols >= 60 ? TREEW : (cols >= 30 ? 16 : 8);
|
treew = cols >= 60 ? TREEW : (cols >= 30 ? 16 : 8);
|
||||||
if (copy_view) treew = 0;
|
if (copy_view) treew = 0;
|
||||||
else if (treew > cols / 2) treew = cols / 2;
|
else if (treew > cols / 2) treew = cols / 2;
|
||||||
mainh = lines > 5 ? lines - 5 : lines == 5;
|
chat_top = lines >= 8 ? 2 : 1;
|
||||||
|
mainh = lines > 5 ? lines - 4 - chat_top : lines == 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void terminal_move(int row, int col)
|
static void terminal_move(int row, int col)
|
||||||
|
|
@ -2572,11 +2573,11 @@ static int layout_topic(int draw)
|
||||||
int height = count < limit ? count : limit;
|
int height = count < limit ? count : limit;
|
||||||
for (int row = 0; row < count; row++) {
|
for (int row = 0; row < count; row++) {
|
||||||
char *text = rows[count - 1 - 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(chat_top + row, left, text, width);
|
||||||
free(text);
|
free(text);
|
||||||
}
|
}
|
||||||
if (draw && divider) {
|
if (draw && divider) {
|
||||||
terminal_move(height + 1, left);
|
terminal_move(chat_top + height, left);
|
||||||
terminal_accent();
|
terminal_accent();
|
||||||
terminal_repeat('-', width);
|
terminal_repeat('-', width);
|
||||||
fputs("\033[0m", stdout);
|
fputs("\033[0m", stdout);
|
||||||
|
|
@ -2614,18 +2615,17 @@ static void draw_main(void)
|
||||||
for (int r = 0; r < h; r++) {
|
for (int r = 0; r < h; r++) {
|
||||||
int idx = curwin->scroll + (h - 1 - r);
|
int idx = curwin->scroll + (h - 1 - r);
|
||||||
if (idx >= 0 && idx < nr && rows[idx])
|
if (idx >= 0 && idx < nr && rows[idx])
|
||||||
draw_irc_text(r + 1 + header, left, rows[idx], ww);
|
draw_irc_text(chat_top + header + r, left, rows[idx], ww);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < nr; i++) free(rows[i]);
|
for (int i = 0; i < nr; i++) free(rows[i]);
|
||||||
free(rows);
|
free(rows);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void draw_bottom_divider(void)
|
static void draw_pane_divider(int row)
|
||||||
{
|
{
|
||||||
if (lines < 4) return;
|
|
||||||
int left = lines > 5 && treew >= 2 ? treew : 0;
|
int left = lines > 5 && treew >= 2 ? treew : 0;
|
||||||
terminal_move(lines - (lines > 5 ? 4 : 3), left);
|
terminal_move(row, left);
|
||||||
terminal_accent();
|
terminal_accent();
|
||||||
terminal_repeat('-', cols - left);
|
terminal_repeat('-', cols - left);
|
||||||
fputs("\033[0m", stdout);
|
fputs("\033[0m", stdout);
|
||||||
|
|
@ -2698,8 +2698,9 @@ static void redraw(void)
|
||||||
fputs("\033[?25l\033[0m\033[2J", stdout);
|
fputs("\033[?25l\033[0m\033[2J", stdout);
|
||||||
draw_title();
|
draw_title();
|
||||||
draw_tree();
|
draw_tree();
|
||||||
|
if (chat_top > 1) draw_pane_divider(1);
|
||||||
draw_main();
|
draw_main();
|
||||||
draw_bottom_divider();
|
if (lines >= 4) draw_pane_divider(lines - (lines > 5 ? 4 : 3));
|
||||||
draw_status();
|
draw_status();
|
||||||
draw_input();
|
draw_input();
|
||||||
fputs("\033[?25h", stdout);
|
fputs("\033[?25h", stdout);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue