mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-17 13:33:03 +01:00
formatting, use case-insensitive string compare, use defines for keycodes
This commit is contained in:
parent
f4fb6ea4fc
commit
15e91cfa99
@ -22,7 +22,6 @@ LIBS = libtoxcore ncursesw libconfig
|
||||
CFLAGS = -std=gnu99 -pthread -Wall -g
|
||||
CFLAGS += -DTOXICVER="\"$(VERSION)\"" -DHAVE_WIDECHAR -D_XOPEN_SOURCE_EXTENDED
|
||||
CFLAGS += -DPACKAGE_DATADIR="\"$(abspath $(DATADIR))\""
|
||||
CFLAGS += -fdiagnostics-color
|
||||
CFLAGS += $(USER_CFLAGS)
|
||||
LDFLAGS = $(USER_LDFLAGS)
|
||||
|
||||
|
@ -51,11 +51,10 @@ sounds = {
|
||||
transfer_completed="__DATADIR__/sounds/TransferComplete.wav";
|
||||
};
|
||||
|
||||
//Only Ctrl modified keys and Tab supported right now
|
||||
//All printable keys register as input anyway
|
||||
// Currently supported: Ctrl modified keys, Tab, PAGEUP and PAGEDOWN (case insensitive)
|
||||
// Note: All printable keys register as input
|
||||
keys = {
|
||||
next_tab="Ctrl+P";
|
||||
//next_tab="Tab";
|
||||
prev_tab="Ctrl+O";
|
||||
scroll_line_up="PAGEUP";
|
||||
scroll_line_down="PAGEDOWN";
|
||||
|
@ -463,16 +463,16 @@ bool line_info_onKey(ToxWindow *self, wint_t key)
|
||||
if (key == user_settings_->key_half_page_up) {
|
||||
line_info_page_up(self, hst);
|
||||
}
|
||||
else if(key == user_settings_->key_half_page_down) {
|
||||
else if (key == user_settings_->key_half_page_down) {
|
||||
line_info_page_down(self, hst);
|
||||
}
|
||||
else if(key == user_settings_->key_scroll_line_up) {
|
||||
else if (key == user_settings_->key_scroll_line_up) {
|
||||
line_info_scroll_up(hst);
|
||||
}
|
||||
else if(key == user_settings_->key_scroll_line_down) {
|
||||
else if (key == user_settings_->key_scroll_line_down) {
|
||||
line_info_scroll_down(hst);
|
||||
}
|
||||
else if(key == user_settings_->key_page_bottom) {
|
||||
else if (key == user_settings_->key_page_bottom) {
|
||||
line_info_reset_start(self, hst);
|
||||
}
|
||||
else {
|
||||
|
@ -58,6 +58,7 @@ const struct _ui_strings {
|
||||
"time_format",
|
||||
"history_size"
|
||||
};
|
||||
|
||||
static void ui_defaults(struct user_settings* settings)
|
||||
{
|
||||
settings->timestamps = TIMESTAMPS_ON;
|
||||
@ -67,6 +68,7 @@ static void ui_defaults(struct user_settings* settings)
|
||||
settings->colour_theme = DFLT_COLS;
|
||||
settings->history_size = 700;
|
||||
}
|
||||
|
||||
const struct _keys_strings {
|
||||
const char* self;
|
||||
const char* next_tab;
|
||||
@ -90,19 +92,21 @@ const struct _keys_strings {
|
||||
"peer_list_up",
|
||||
"peer_list_down"
|
||||
};
|
||||
|
||||
/* defines from toxic.h */
|
||||
static void key_defaults(struct user_settings* settings)
|
||||
{
|
||||
settings->key_next_tab = 0x10;
|
||||
settings->key_prev_tab = 0x0F;
|
||||
settings->key_scroll_line_up = 0523; /* value from libncurses:curses.h */
|
||||
settings->key_scroll_line_down = 0522;
|
||||
settings->key_half_page_up = 0x06;
|
||||
settings->key_half_page_down = 0x16;
|
||||
settings->key_page_bottom = 0x08;
|
||||
settings->key_peer_list_up = 0x1B;
|
||||
settings->key_peer_list_down = 0x1D;
|
||||
|
||||
settings->key_next_tab = T_KEY_NEXT;
|
||||
settings->key_prev_tab = T_KEY_PREV;
|
||||
settings->key_scroll_line_up = KEY_PPAGE;
|
||||
settings->key_scroll_line_down = KEY_NPAGE;
|
||||
settings->key_half_page_up = T_KEY_C_F;
|
||||
settings->key_half_page_down = T_KEY_C_V;
|
||||
settings->key_page_bottom = T_KEY_C_H;
|
||||
settings->key_peer_list_up = T_KEY_C_LB;
|
||||
settings->key_peer_list_down = T_KEY_C_RB;
|
||||
}
|
||||
|
||||
const struct _tox_strings {
|
||||
const char* self;
|
||||
const char* download_path;
|
||||
@ -128,6 +132,7 @@ const struct _audio_strings {
|
||||
"output_device",
|
||||
"VAD_treshold",
|
||||
};
|
||||
|
||||
static void audio_defaults(struct user_settings* settings)
|
||||
{
|
||||
settings->audio_in_dev = 0;
|
||||
@ -164,6 +169,23 @@ const struct _sound_strings {
|
||||
};
|
||||
#endif
|
||||
|
||||
static int key_parse(const char** bind){
|
||||
int len = strlen(*bind);
|
||||
|
||||
if (len > 5) {
|
||||
if(strncasecmp(*bind, "ctrl+", 5) == 0)
|
||||
return bind[0][5] - 'A' + 1;
|
||||
}
|
||||
|
||||
if (strncasecmp(*bind, "tab", 3) == 0)
|
||||
return T_KEY_TAB;
|
||||
|
||||
if (strncasecmp(*bind, "page", 4) == 0)
|
||||
return len == 6 ? KEY_PPAGE : KEY_NPAGE;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int settings_load(struct user_settings *s, const char *patharg)
|
||||
{
|
||||
config_t cfg[1];
|
||||
@ -173,7 +195,7 @@ int settings_load(struct user_settings *s, const char *patharg)
|
||||
/* Load default settings */
|
||||
ui_defaults(s);
|
||||
tox_defaults(s);
|
||||
key_defaults(s);
|
||||
key_defaults(s);
|
||||
#ifdef _AUDIO
|
||||
audio_defaults(s);
|
||||
#endif
|
||||
@ -327,14 +349,3 @@ int settings_load(struct user_settings *s, const char *patharg)
|
||||
config_destroy(cfg);
|
||||
return 0;
|
||||
}
|
||||
int key_parse(const char** bind){
|
||||
if(strlen(*bind) > 5){
|
||||
if(strncmp(*bind,"Ctrl+", 5)==0) return bind[0][5]-'A'+1;
|
||||
}
|
||||
if(strncmp(*bind,"Tab",3)==0) return 9;
|
||||
if(strncmp(*bind,"PAGE",4)==0) {
|
||||
if(strlen(*bind) == 6) return 0523;
|
||||
return 0522;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
@ -69,5 +69,4 @@ enum {
|
||||
} settings_values;
|
||||
|
||||
int settings_load(struct user_settings *s, const char *patharg);
|
||||
int key_parse(const char** bind);
|
||||
#endif /* #define _settings_h */
|
||||
|
@ -50,7 +50,7 @@
|
||||
#define TIME_STR_SIZE 16
|
||||
|
||||
/* ASCII key codes */
|
||||
#define T_KEY_ESC 0X1B /* esc key */
|
||||
#define T_KEY_ESC 0x1B /* ESC key */
|
||||
#define T_KEY_KILL 0x0B /* ctrl-k */
|
||||
#define T_KEY_DISCARD 0x15 /* ctrl-u */
|
||||
#define T_KEY_NEXT 0x10 /* ctrl-p */
|
||||
@ -63,6 +63,7 @@
|
||||
#define T_KEY_C_F 0x06 /* ctrl-f */
|
||||
#define T_KEY_C_H 0x08 /* ctrl-h */
|
||||
#define T_KEY_C_Y 0x19 /* ctrl-y */
|
||||
#define T_KEY_TAB 0x09 /* TAB key */
|
||||
|
||||
#define ONLINE_CHAR "*"
|
||||
#define OFFLINE_CHAR "o"
|
||||
|
Loading…
Reference in New Issue
Block a user