mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Renamed input_bar -> status_bar
This commit is contained in:
parent
af46792871
commit
9e63c4a0f6
4
Makefile
4
Makefile
@ -2,7 +2,7 @@ CC = gcc
|
||||
WARNS = -Werror -Wall -Wextra -Wno-unused-parameter -Wno-unused-but-set-variable
|
||||
LIBS = -lxml2 -lssl -lresolv -lncurses -lstrophe
|
||||
CFLAGS = -O3 $(WARNS) $(LIBS)
|
||||
OBJS = log.o windows.o title_bar.o input_bar.o input_win.o jabber.o \
|
||||
OBJS = log.o windows.o title_bar.o status_bar.o input_win.o jabber.o \
|
||||
profanity.o util.o command.o main.o
|
||||
|
||||
profanity: $(OBJS)
|
||||
@ -11,7 +11,7 @@ profanity: $(OBJS)
|
||||
log.o: log.h
|
||||
windows.o: windows.h util.h
|
||||
title_bar.o: windows.h
|
||||
input_bar.o: windows.h util.h
|
||||
status_bar.o: windows.h util.h
|
||||
input_win.o: windows.h
|
||||
jabber.o: jabber.h log.h windows.h
|
||||
profanity.o: log.h windows.h jabber.h command.h
|
||||
|
@ -24,11 +24,11 @@ int handle_start_command(char *cmd)
|
||||
char *user;
|
||||
user = strndup(cmd+9, strlen(cmd)-9);
|
||||
|
||||
inp_bar_get_password();
|
||||
status_bar_get_password();
|
||||
char passwd[20];
|
||||
inp_get_password(passwd);
|
||||
|
||||
inp_bar_print_message(user);
|
||||
status_bar_print_message(user);
|
||||
jabber_connect(user, passwd);
|
||||
result = START_MAIN;
|
||||
} else {
|
||||
|
60
input_bar.c
60
input_bar.c
@ -1,60 +0,0 @@
|
||||
#include <ncurses.h>
|
||||
#include "windows.h"
|
||||
#include "util.h"
|
||||
|
||||
static WINDOW *inp_bar;
|
||||
|
||||
void create_input_bar(void)
|
||||
{
|
||||
int rows, cols;
|
||||
getmaxyx(stdscr, rows, cols);
|
||||
|
||||
inp_bar = newwin(1, cols, rows-2, 0);
|
||||
wbkgd(inp_bar, COLOR_PAIR(3));
|
||||
wrefresh(inp_bar);
|
||||
}
|
||||
|
||||
void inp_bar_inactive(int win)
|
||||
{
|
||||
mvwaddch(inp_bar, 0, 30 + win, ' ');
|
||||
if (win == 9)
|
||||
mvwaddch(inp_bar, 0, 30 + win + 1, ' ');
|
||||
wrefresh(inp_bar);
|
||||
}
|
||||
|
||||
void inp_bar_active(int win)
|
||||
{
|
||||
mvwprintw(inp_bar, 0, 30 + win, "%d", win+1);
|
||||
touchwin(inp_bar);
|
||||
wrefresh(inp_bar);
|
||||
}
|
||||
|
||||
void inp_bar_get_password(void)
|
||||
{
|
||||
mvwprintw(inp_bar, 0, 1, "Enter password:");
|
||||
wrefresh(inp_bar);
|
||||
}
|
||||
|
||||
void inp_bar_print_message(char *msg)
|
||||
{
|
||||
mvwprintw(inp_bar, 0, 9, msg);
|
||||
wrefresh(inp_bar);
|
||||
}
|
||||
|
||||
void inp_bar_update_time(void)
|
||||
{
|
||||
char bar_time[8];
|
||||
char tstmp[80];
|
||||
get_time(tstmp);
|
||||
sprintf(bar_time, "[%s]", tstmp);
|
||||
|
||||
mvwprintw(inp_bar, 0, 1, bar_time);
|
||||
wrefresh(inp_bar);
|
||||
inp_put_back();
|
||||
}
|
||||
|
||||
void inp_bar_clear(void)
|
||||
{
|
||||
wclear(inp_bar);
|
||||
wrefresh(inp_bar);
|
||||
}
|
@ -82,7 +82,7 @@ void inp_get_password(char *passwd)
|
||||
mvwgetstr(inp_win, 0, 1, passwd);
|
||||
wmove(inp_win, 0, 1);
|
||||
echo();
|
||||
inp_bar_clear();
|
||||
status_bar_clear();
|
||||
}
|
||||
|
||||
void inp_put_back(void)
|
||||
|
@ -51,7 +51,7 @@ static void _profanity_event_loop(int *ch, char *cmd, int *size)
|
||||
{
|
||||
usleep(1);
|
||||
|
||||
inp_bar_update_time();
|
||||
status_bar_update_time();
|
||||
|
||||
// handle incoming messages
|
||||
jabber_process_events();
|
||||
|
60
status_bar.c
Normal file
60
status_bar.c
Normal file
@ -0,0 +1,60 @@
|
||||
#include <ncurses.h>
|
||||
#include "windows.h"
|
||||
#include "util.h"
|
||||
|
||||
static WINDOW *status_bar;
|
||||
|
||||
void create_status_bar(void)
|
||||
{
|
||||
int rows, cols;
|
||||
getmaxyx(stdscr, rows, cols);
|
||||
|
||||
status_bar = newwin(1, cols, rows-2, 0);
|
||||
wbkgd(status_bar, COLOR_PAIR(3));
|
||||
wrefresh(status_bar);
|
||||
}
|
||||
|
||||
void status_bar_inactive(int win)
|
||||
{
|
||||
mvwaddch(status_bar, 0, 30 + win, ' ');
|
||||
if (win == 9)
|
||||
mvwaddch(status_bar, 0, 30 + win + 1, ' ');
|
||||
wrefresh(status_bar);
|
||||
}
|
||||
|
||||
void status_bar_active(int win)
|
||||
{
|
||||
mvwprintw(status_bar, 0, 30 + win, "%d", win+1);
|
||||
touchwin(status_bar);
|
||||
wrefresh(status_bar);
|
||||
}
|
||||
|
||||
void status_bar_get_password(void)
|
||||
{
|
||||
mvwprintw(status_bar, 0, 1, "Enter password:");
|
||||
wrefresh(status_bar);
|
||||
}
|
||||
|
||||
void status_bar_print_message(char *msg)
|
||||
{
|
||||
mvwprintw(status_bar, 0, 9, msg);
|
||||
wrefresh(status_bar);
|
||||
}
|
||||
|
||||
void status_bar_update_time(void)
|
||||
{
|
||||
char bar_time[8];
|
||||
char tstmp[80];
|
||||
get_time(tstmp);
|
||||
sprintf(bar_time, "[%s]", tstmp);
|
||||
|
||||
mvwprintw(status_bar, 0, 1, bar_time);
|
||||
wrefresh(status_bar);
|
||||
inp_put_back();
|
||||
}
|
||||
|
||||
void status_bar_clear(void)
|
||||
{
|
||||
wclear(status_bar);
|
||||
wrefresh(status_bar);
|
||||
}
|
12
windows.c
12
windows.c
@ -28,7 +28,7 @@ void gui_init(void)
|
||||
refresh();
|
||||
|
||||
create_title_bar();
|
||||
create_input_bar();
|
||||
create_status_bar();
|
||||
create_input_window();
|
||||
|
||||
_create_windows();
|
||||
@ -67,7 +67,7 @@ void win_close_win(void)
|
||||
wclear(_wins[_curr_win].win);
|
||||
|
||||
// set it as inactive in the status bar
|
||||
inp_bar_inactive(_curr_win);
|
||||
status_bar_inactive(_curr_win);
|
||||
|
||||
// go back to console window
|
||||
touchwin(_wins[0].win);
|
||||
@ -117,7 +117,7 @@ void win_show_incomming_msg(char *from, char *message)
|
||||
wprintw(_wins[i].win, line);
|
||||
|
||||
// signify active window in status bar
|
||||
inp_bar_active(i);
|
||||
status_bar_active(i);
|
||||
|
||||
// if its the current window, draw it
|
||||
if (_curr_win == i) {
|
||||
@ -131,7 +131,7 @@ void win_show_incomming_msg(char *from, char *message)
|
||||
wprintw(_wins[i].win, line);
|
||||
|
||||
// signify active window in status bar
|
||||
inp_bar_active(i);
|
||||
status_bar_active(i);
|
||||
|
||||
// if its the current window, draw it
|
||||
if (_curr_win == i) {
|
||||
@ -167,7 +167,7 @@ void win_show_outgoing_msg(char *from, char *to, char *message)
|
||||
wprintw(_wins[i].win, line);
|
||||
|
||||
// signify active window in status bar
|
||||
inp_bar_active(i);
|
||||
status_bar_active(i);
|
||||
|
||||
// if its the current window, draw it
|
||||
if (_curr_win == i) {
|
||||
@ -181,7 +181,7 @@ void win_show_outgoing_msg(char *from, char *to, char *message)
|
||||
wprintw(_wins[i].win, line);
|
||||
|
||||
// signify active window in status bar
|
||||
inp_bar_active(i);
|
||||
status_bar_active(i);
|
||||
|
||||
// if its the current window, draw it
|
||||
if (_curr_win == i) {
|
||||
|
16
windows.h
16
windows.h
@ -14,16 +14,16 @@ void gui_close(void);
|
||||
|
||||
// create windows
|
||||
void create_title_bar(void);
|
||||
void create_input_bar(void);
|
||||
void create_status_bar(void);
|
||||
void create_input_window(void);
|
||||
|
||||
// input bar actions
|
||||
void inp_bar_clear(void);
|
||||
void inp_bar_get_password(void);
|
||||
void inp_bar_print_message(char *msg);
|
||||
void inp_bar_inactive(int win);
|
||||
void inp_bar_active(int win);
|
||||
void inp_bar_update_time(void);
|
||||
// status bar actions
|
||||
void status_bar_clear(void);
|
||||
void status_bar_get_password(void);
|
||||
void status_bar_print_message(char *msg);
|
||||
void status_bar_inactive(int win);
|
||||
void status_bar_active(int win);
|
||||
void status_bar_update_time(void);
|
||||
|
||||
// input window actions
|
||||
void inp_get_command_str(char *cmd);
|
||||
|
Loading…
Reference in New Issue
Block a user