Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Some UI improvements #141

Merged
merged 1 commit into from
Nov 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/friendlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -1378,6 +1378,6 @@ ToxWindow *new_friendlist(void)
}

ret->help = help;
strcpy(ret->name, "contacts");
strcpy(ret->name, "Contacts");
return ret;
}
6 changes: 1 addition & 5 deletions src/misc_tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,11 +584,7 @@ void set_window_title(ToxWindow *self, const char *title, int len)

char cpy[TOXIC_MAX_NAME_LENGTH + 1];

if (self->type == WINDOW_TYPE_CONFERENCE) { /* keep conferencenumber in title */
snprintf(cpy, sizeof(cpy), "%u %s", self->num, title);
} else {
snprintf(cpy, sizeof(cpy), "%s", title);
}
snprintf(cpy, sizeof(cpy), "%s", title);

if (len > MAX_WINDOW_NAME_LENGTH) {
strcpy(&cpy[MAX_WINDOW_NAME_LENGTH - 3], "...");
Expand Down
2 changes: 1 addition & 1 deletion src/prompt.c
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ ToxWindow *new_prompt(void)
ret->onConnectionChange = &prompt_onConnectionChange;
ret->onFriendRequest = &prompt_onFriendRequest;

strcpy(ret->name, "home");
strcpy(ret->name, "Home");

ChatContext *chatwin = calloc(1, sizeof(ChatContext));
StatusBar *stb = calloc(1, sizeof(StatusBar));
Expand Down
1 change: 1 addition & 0 deletions src/toxic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1501,6 +1501,7 @@ int main(int argc, char **argv)

pthread_mutex_lock(&Winthread.lock);
print_init_messages(prompt);
set_active_window_index(0);
pthread_mutex_unlock(&Winthread.lock);

cleanup_init_messages();
Expand Down
17 changes: 12 additions & 5 deletions src/windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ void on_window_resize(void)
}
}

static void draw_window_tab(ToxWindow *toxwin)
static void draw_window_tab(ToxWindow *toxwin, bool active_window)
{
pthread_mutex_lock(&Winthread.lock);

Expand All @@ -505,7 +505,12 @@ static void draw_window_tab(ToxWindow *toxwin)
pthread_mutex_unlock(&Winthread.lock);

clrtoeol();
printw(" [%s]", toxwin->name);

if (active_window || toxwin->index <= 1) {
printw(" [%s]", toxwin->name);
} else {
printw(" [%u]", toxwin->index - 1);
}

pthread_mutex_lock(&Winthread.lock);

Expand Down Expand Up @@ -540,7 +545,9 @@ static void draw_bar(void)
continue;
}

if (i == active_window_index) {
bool active_window = i == active_window_index;

if (active_window) {

#ifdef URXVT_FIX
attron(A_BOLD | COLOR_PAIR(GREEN));
Expand All @@ -550,9 +557,9 @@ static void draw_bar(void)
attron(A_BOLD);
}

draw_window_tab(windows[i]);
draw_window_tab(windows[i], active_window);

if (i == active_window_index) {
if (active_window) {

#ifdef URXVT_FIX
attroff(A_BOLD | COLOR_PAIR(GREEN));
Expand Down
2 changes: 1 addition & 1 deletion src/windows.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

#include "toxic.h"

#define MAX_WINDOWS_NUM 16
#define MAX_WINDOWS_NUM 20
#define MAX_WINDOW_NAME_LENGTH 22
#define CURS_Y_OFFSET 1 /* y-axis cursor offset for chat contexts */
#define CHATBOX_HEIGHT 2
Expand Down