mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-26 22:13:26 +01:00
put back prompt char
This commit is contained in:
parent
e3400e095b
commit
a57f94306a
22
src/prompt.c
22
src/prompt.c
@ -136,16 +136,24 @@ static void prompt_onDraw(ToxWindow *self, Tox *m)
|
||||
getyx(self->window, y, x);
|
||||
getmaxyx(self->window, y2, x2);
|
||||
|
||||
int px2 = ctx->len >= x2 ? x2 : x2 - X_OFST; /* max x to account for prompt char */
|
||||
int p_ofst = px2 != x2 ? 0 : X_OFST; /* line pos offset to account for prompt char */
|
||||
|
||||
wclrtobot(self->window);
|
||||
|
||||
/* Mark point of origin for new line */
|
||||
if (ctx->len == 0) {
|
||||
ctx->orig_y = y;
|
||||
} else {
|
||||
mvwprintw(self->window, ctx->orig_y, 0, wcs_to_char(ctx->line));
|
||||
if (ctx->len > 0) {
|
||||
mvwprintw(self->window, ctx->orig_y, X_OFST, wcs_to_char(ctx->line));
|
||||
|
||||
/* move point of line origin up when input scrolls screen down */
|
||||
if (y == y2-1 && ctx->len % x2 == 0)
|
||||
if (y == y2-1 && (ctx->len + p_ofst) % px2 == 0)
|
||||
--ctx->orig_y;
|
||||
|
||||
} else {
|
||||
ctx->orig_y = y;
|
||||
wattron(self->window, COLOR_PAIR(GREEN));
|
||||
mvwprintw(self->window, y, 0, "# ");
|
||||
wattroff(self->window, COLOR_PAIR(GREEN));
|
||||
}
|
||||
|
||||
StatusBar *statusbar = self->stb;
|
||||
@ -190,8 +198,8 @@ static void prompt_onDraw(ToxWindow *self, Tox *m)
|
||||
wattroff(statusbar->topline, A_BOLD);
|
||||
|
||||
/* put cursor back in correct spot */
|
||||
int y_m = ctx->pos <= 0 ? ctx->orig_y : ctx->orig_y + (ctx->pos / x2);
|
||||
int x_m = ctx->pos > 0 ? ctx->pos % x2 : 0;
|
||||
int y_m = ctx->pos <= 0 ? ctx->orig_y : ctx->orig_y + ((ctx->pos + p_ofst) / px2);
|
||||
int x_m = ctx->pos > 0 ? (ctx->pos + X_OFST) % x2 : X_OFST;
|
||||
wmove(self->window, y_m, x_m);
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
#ifndef PROMPT_H_UZYGWFFL
|
||||
#define PROMPT_H_UZYGWFFL
|
||||
|
||||
#define X_OFST 2 /* offset to account for prompt "# " */
|
||||
|
||||
ToxWindow new_prompt(void);
|
||||
void prompt_init_statusbar(ToxWindow *self, Tox *m);
|
||||
void prompt_update_nick(ToxWindow *prompt, uint8_t *nick, uint16_t len);
|
||||
|
Loading…
Reference in New Issue
Block a user