mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-23 03:13:01 +01:00
cursor done better, fixed for chat windows
This commit is contained in:
parent
2ebd30bdb3
commit
53f7d9af0d
3
chat.c
3
chat.c
@ -106,6 +106,7 @@ static void chat_onKey(ToxWindow* self, int key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void chat_onDraw(ToxWindow* self) {
|
static void chat_onDraw(ToxWindow* self) {
|
||||||
|
curs_set(1);
|
||||||
int x, y;
|
int x, y;
|
||||||
ChatContext* ctx = (ChatContext*) self->x;
|
ChatContext* ctx = (ChatContext*) self->x;
|
||||||
|
|
||||||
@ -117,7 +118,7 @@ static void chat_onDraw(ToxWindow* self) {
|
|||||||
|
|
||||||
wclear(ctx->linewin);
|
wclear(ctx->linewin);
|
||||||
mvwhline(ctx->linewin, 0, 0, '_', COLS);
|
mvwhline(ctx->linewin, 0, 0, '_', COLS);
|
||||||
mvwprintw(ctx->linewin, 1, 0, "%s\n", ctx->line);
|
mvwprintw(self->window, y-1, 0, "%s\n", ctx->line);
|
||||||
|
|
||||||
wrefresh(self->window);
|
wrefresh(self->window);
|
||||||
}
|
}
|
||||||
|
@ -113,6 +113,7 @@ static void friendlist_onKey(ToxWindow* self, int key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void friendlist_onDraw(ToxWindow* self) {
|
static void friendlist_onDraw(ToxWindow* self) {
|
||||||
|
curs_set(0);
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
wclear(self->window);
|
wclear(self->window);
|
||||||
|
23
main.c
23
main.c
@ -280,26 +280,6 @@ void prepare_window(WINDOW* w) {
|
|||||||
wresize(w, LINES-2, COLS);
|
wresize(w, LINES-2, COLS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Draws cursor relative to input on prompt window.
|
|
||||||
* Removes cursor on friends window and chat windows.
|
|
||||||
*
|
|
||||||
* TODO: Make it work for chat windows
|
|
||||||
*/
|
|
||||||
void position_cursor(WINDOW* w, char* title)
|
|
||||||
{
|
|
||||||
curs_set(1);
|
|
||||||
if (strcmp(title, "[prompt]") == 0) { // main/prompt window
|
|
||||||
int x, y;
|
|
||||||
getyx(w, y, x);
|
|
||||||
move(y, x);
|
|
||||||
}
|
|
||||||
else if (strcmp(title, "[friends]") == 0) // friends window
|
|
||||||
curs_set(0);
|
|
||||||
else // any other window (i.e chat)
|
|
||||||
curs_set(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
int ch;
|
int ch;
|
||||||
ToxWindow* a;
|
ToxWindow* a;
|
||||||
@ -317,9 +297,8 @@ int main(int argc, char* argv[]) {
|
|||||||
a = &windows[w_active];
|
a = &windows[w_active];
|
||||||
prepare_window(a->window);
|
prepare_window(a->window);
|
||||||
a->blink = false;
|
a->blink = false;
|
||||||
a->onDraw(a);
|
|
||||||
draw_bar();
|
draw_bar();
|
||||||
position_cursor(a->window, a->title);
|
a->onDraw(a);
|
||||||
|
|
||||||
// Handle input.
|
// Handle input.
|
||||||
ch = getch();
|
ch = getch();
|
||||||
|
Loading…
Reference in New Issue
Block a user