mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-23 02:23:02 +01:00
Keybind defaults moved to settings.c; conf keybinds not reading correctly yet
This commit is contained in:
parent
f630a3e604
commit
9f01a45b1f
@ -368,12 +368,12 @@ static void groupchat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
|
||||
} else {
|
||||
beep();
|
||||
}
|
||||
} else if (key == T_KEY_C_RB) { /* Scroll peerlist up and down one position */
|
||||
} else if (key == user_settings_->key_peer_list_down) { /* Scroll peerlist up and down one position */
|
||||
int L = y2 - CHATBOX_HEIGHT - SDBAR_OFST;
|
||||
|
||||
if (groupchats[self->num].side_pos < groupchats[self->num].num_peers - L)
|
||||
++groupchats[self->num].side_pos;
|
||||
} else if (key == T_KEY_C_LB) {
|
||||
} else if (key == user_settings_->key_peer_list_up) {
|
||||
if (groupchats[self->num].side_pos > 0)
|
||||
--groupchats[self->num].side_pos;
|
||||
} else if (key == '\n') {
|
||||
|
@ -453,36 +453,24 @@ bool line_info_onKey(ToxWindow *self, wint_t key)
|
||||
struct history *hst = self->chatwin->hst;
|
||||
bool match = true;
|
||||
|
||||
switch (key) {
|
||||
/* TODO: Find good key bindings for all this stuff */
|
||||
case T_KEY_C_F:
|
||||
line_info_page_up(self, hst);
|
||||
break;
|
||||
|
||||
case T_KEY_C_V:
|
||||
line_info_page_down(self, hst);
|
||||
break;
|
||||
|
||||
case KEY_PPAGE:
|
||||
line_info_scroll_up(hst);
|
||||
break;
|
||||
|
||||
case KEY_NPAGE:
|
||||
line_info_scroll_down(hst);
|
||||
break;
|
||||
|
||||
/* case ?:
|
||||
line_info_goto_root(hst);
|
||||
break; */
|
||||
|
||||
case T_KEY_C_H:
|
||||
line_info_reset_start(self, hst);
|
||||
break;
|
||||
|
||||
default:
|
||||
match = false;
|
||||
break;
|
||||
}
|
||||
if (key == user_settings_->key_half_page_up) {
|
||||
line_info_page_up(self, hst);
|
||||
}
|
||||
else if(key == user_settings_->key_half_page_down) {
|
||||
line_info_page_down(self, hst);
|
||||
}
|
||||
else if(key == user_settings_->key_scroll_line_up) {
|
||||
line_info_scroll_up(hst);
|
||||
}
|
||||
else if(key == user_settings_->key_scroll_line_down) {
|
||||
line_info_scroll_down(hst);
|
||||
}
|
||||
else if(key == user_settings_->key_page_bottom) {
|
||||
line_info_reset_start(self, hst);
|
||||
}
|
||||
else {
|
||||
match = false;
|
||||
}
|
||||
|
||||
return match;
|
||||
}
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <libconfig.h>
|
||||
|
||||
#include "toxic.h"
|
||||
#include "windows.h"
|
||||
#include "configdir.h"
|
||||
@ -68,7 +67,43 @@ 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* keys;
|
||||
const char* next_tab;
|
||||
const char* prev_tab;
|
||||
const char* scroll_line_up;
|
||||
const char* scroll_line_down;
|
||||
const char* half_page_up;
|
||||
const char* half_page_down;
|
||||
const char* page_bottom;
|
||||
const char* peer_list_up;
|
||||
const char* peer_list_down;
|
||||
} key_strings = {
|
||||
"keys",
|
||||
"next_tab",
|
||||
"prev_tab",
|
||||
"scroll_line_up",
|
||||
"scroll_line_down",
|
||||
"half_page_up",
|
||||
"half_page_down",
|
||||
"page_bottom",
|
||||
"peer_list_up",
|
||||
"peer_list_down"
|
||||
};
|
||||
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;
|
||||
|
||||
}
|
||||
const struct _tox_strings {
|
||||
const char* self;
|
||||
const char* download_path;
|
||||
@ -139,6 +174,7 @@ int settings_load(struct user_settings *s, const char *patharg)
|
||||
/* Load default settings */
|
||||
ui_defaults(s);
|
||||
tox_defaults(s);
|
||||
key_defaults(s);
|
||||
#ifdef _AUDIO
|
||||
audio_defaults(s);
|
||||
#endif
|
||||
@ -155,7 +191,6 @@ int settings_load(struct user_settings *s, const char *patharg)
|
||||
|
||||
/* make sure path exists or is created on first time running */
|
||||
FILE *fp = fopen(path, "r");
|
||||
|
||||
if (fp == NULL) {
|
||||
if ((fp = fopen(path, "w")) == NULL)
|
||||
return -1;
|
||||
@ -167,6 +202,8 @@ int settings_load(struct user_settings *s, const char *patharg)
|
||||
}
|
||||
|
||||
if (!config_read_file(cfg, path)) {
|
||||
char* chk = config_error_text(cfg);
|
||||
int lin = config_error_line(cfg);
|
||||
config_destroy(cfg);
|
||||
return -1;
|
||||
}
|
||||
@ -188,6 +225,18 @@ int settings_load(struct user_settings *s, const char *patharg)
|
||||
strcpy(s->download_path, str);
|
||||
}
|
||||
}
|
||||
/* keys */
|
||||
if((setting = config_lookup(cfg, key_strings.self)) != NULL) {
|
||||
config_setting_lookup_int(setting, key_strings.next_tab, &s->key_next_tab);
|
||||
config_setting_lookup_int(setting, key_strings.prev_tab, &s->key_prev_tab);
|
||||
config_setting_lookup_int(setting, key_strings.scroll_line_up, &s->key_scroll_line_up);
|
||||
config_setting_lookup_int(setting, key_strings.scroll_line_down, &s->key_scroll_line_down);
|
||||
config_setting_lookup_int(setting, key_strings.half_page_up, &s->key_half_page_up);
|
||||
config_setting_lookup_int(setting, key_strings.half_page_down, &s->key_half_page_down);
|
||||
config_setting_lookup_int(setting, key_strings.page_bottom, &s->key_page_bottom);
|
||||
config_setting_lookup_int(setting, key_strings.peer_list_up, &s->key_peer_list_up);
|
||||
//config_setting_lookup_int(setting, key_strings.peer_list_down, &s->key_peer_list_down);
|
||||
}
|
||||
|
||||
#ifdef _AUDIO
|
||||
if ((setting = config_lookup(cfg, audio_strings.self)) != NULL) {
|
||||
|
@ -33,6 +33,15 @@ struct user_settings {
|
||||
int history_size; /* int between MIN_HISTORY and MAX_HISTORY */
|
||||
char download_path[MAX_STR_SIZE];
|
||||
|
||||
int key_next_tab; /* character code */
|
||||
int key_prev_tab; /* character code */
|
||||
int key_scroll_line_up;
|
||||
int key_scroll_line_down;
|
||||
int key_half_page_up;
|
||||
int key_half_page_down;
|
||||
int key_page_bottom;
|
||||
int key_peer_list_up;
|
||||
int key_peer_list_down;
|
||||
#ifdef _AUDIO
|
||||
int audio_in_dev;
|
||||
int audio_out_dev;
|
||||
|
@ -33,15 +33,16 @@
|
||||
#include "chat.h"
|
||||
#include "line_info.h"
|
||||
|
||||
#include "settings.h"
|
||||
extern char *DATA_FILE;
|
||||
extern struct _Winthread Winthread;
|
||||
static ToxWindow windows[MAX_WINDOWS_NUM];
|
||||
static ToxWindow *active_window;
|
||||
|
||||
extern ToxWindow *prompt;
|
||||
extern struct user_settings *user_settings_;
|
||||
|
||||
static int num_active_windows;
|
||||
|
||||
/* CALLBACKS START */
|
||||
void on_request(Tox *m, const uint8_t *public_key, const uint8_t *data, uint16_t length, void *userdata)
|
||||
{
|
||||
@ -267,7 +268,7 @@ void set_next_window(int ch)
|
||||
ToxWindow *inf = active_window;
|
||||
|
||||
while (true) {
|
||||
if (ch == T_KEY_NEXT) {
|
||||
if (ch == user_settings_->key_next_tab) {
|
||||
if (++active_window > end)
|
||||
active_window = windows;
|
||||
} else if (--active_window < windows)
|
||||
@ -452,7 +453,7 @@ void draw_active_window(Tox *m)
|
||||
ltr = isprint(ch);
|
||||
#endif /* HAVE_WIDECHAR */
|
||||
|
||||
if (!ltr && (ch == T_KEY_NEXT || ch == T_KEY_PREV)) {
|
||||
if (!ltr && (ch == user_settings_->key_next_tab || ch == user_settings_->key_prev_tab)) {
|
||||
set_next_window((int) ch);
|
||||
} else {
|
||||
pthread_mutex_lock(&Winthread.lock);
|
||||
|
Loading…
Reference in New Issue
Block a user