1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Removed inputwin functions from ui.h

This commit is contained in:
James Booth 2014-04-07 21:50:28 +01:00
parent e2443511b6
commit 9aa282f6de
10 changed files with 110 additions and 64 deletions

View File

@ -14,7 +14,7 @@ core_sources = \
src/server_events.c src/server_events.h \
src/ui/ui.h src/ui/window.c src/ui/window.h src/ui/core.c \
src/ui/titlebar.c src/ui/statusbar.c src/ui/inputwin.c \
src/ui/titlebar.h src/ui/statusbar.h \
src/ui/titlebar.h src/ui/statusbar.h src/ui/inputwin.h \
src/ui/console.c src/ui/notifier.c \
src/ui/windows.c src/ui/windows.h \
src/command/command.h src/command/command.c src/command/history.c \
@ -51,8 +51,8 @@ tests_sources = \
src/config/theme.c src/config/theme.h \
src/ui/windows.c src/ui/windows.h \
src/ui/window.c src/ui/window.h \
src/ui/titlebar.c src/ui/statusbar.c \
src/ui/titlebar.h src/ui/statusbar.h \
src/ui/titlebar.c src/ui/statusbar.c src/ui/inputwin.c \
src/ui/titlebar.h src/ui/statusbar.h src/ui/inputwin.h \
src/server_events.c src/server_events.h \
tests/xmpp/mock_xmpp.h tests/xmpp/mock_xmpp.c \
tests/otr/mock_otr.h tests/otr/mock_otr.c \

View File

@ -1178,7 +1178,7 @@ cmd_autocomplete(char *input, int *size)
found = autocomplete_complete(commands_ac, inp_cpy);
if (found != NULL) {
char *auto_msg = strdup(found);
inp_replace_input(input, auto_msg, size);
ui_replace_input(input, auto_msg, size);
free(auto_msg);
free(found);
}
@ -1411,7 +1411,7 @@ _cmd_complete_parameters(char *input, int *size)
result = autocomplete_param_with_func(input, size, boolean_choices[i],
prefs_autocomplete_boolean_choice);
if (result != NULL) {
inp_replace_input(input, result, size);
ui_replace_input(input, result, size);
g_free(result);
return;
}
@ -1428,7 +1428,7 @@ _cmd_complete_parameters(char *input, int *size)
result = autocomplete_param_with_ac(input, size, nick_choices[i],
nick_ac);
if (result != NULL) {
inp_replace_input(input, result, size);
ui_replace_input(input, result, size);
g_free(result);
return;
}
@ -1442,7 +1442,7 @@ _cmd_complete_parameters(char *input, int *size)
result = autocomplete_param_with_func(input, size, contact_choices[i],
roster_find_contact);
if (result != NULL) {
inp_replace_input(input, result, size);
ui_replace_input(input, result, size);
g_free(result);
return;
}
@ -1453,7 +1453,7 @@ _cmd_complete_parameters(char *input, int *size)
result = autocomplete_param_with_func(input, size, resource_choices[i],
roster_find_resource);
if (result != NULL) {
inp_replace_input(input, result, size);
ui_replace_input(input, result, size);
g_free(result);
return;
}
@ -1462,7 +1462,7 @@ _cmd_complete_parameters(char *input, int *size)
result = autocomplete_param_with_func(input, size, "/invite", roster_find_contact);
if (result != NULL) {
inp_replace_input(input, result, size);
ui_replace_input(input, result, size);
g_free(result);
return;
}
@ -1472,7 +1472,7 @@ _cmd_complete_parameters(char *input, int *size)
result = autocomplete_param_with_func(input, size, invite_choices[i],
muc_find_invite);
if (result != NULL) {
inp_replace_input(input, result, size);
ui_replace_input(input, result, size);
g_free(result);
return;
}
@ -1484,7 +1484,7 @@ _cmd_complete_parameters(char *input, int *size)
for (i = 0; i < ARRAY_SIZE(cmds); i++) {
result = autocomplete_param_with_ac(input, size, cmds[i], completers[i]);
if (result != NULL) {
inp_replace_input(input, result, size);
ui_replace_input(input, result, size);
g_free(result);
return;
}
@ -1500,7 +1500,7 @@ _cmd_complete_parameters(char *input, int *size)
for (i = 0; i < ARRAY_SIZE(acs); i++) {
result = acs[i](input, size);
if (result != NULL) {
inp_replace_input(input, result, size);
ui_replace_input(input, result, size);
g_free(result);
return;
}

View File

@ -54,7 +54,6 @@ _init_modules(void)
ui_init_module();
console_init_module();
inputwin_init_module();
notifier_init_module();
accounts_init_module();

View File

@ -62,7 +62,7 @@ prof_run(const int disable_tls, char *log_level, char *account_name)
{
_init(disable_tls, log_level);
log_info("Starting main event loop");
inp_non_block();
ui_input_nonblocking();
GTimer *timer = g_timer_new();
gboolean cmd_result = TRUE;
jabber_conn_status_t conn_status = jabber_get_connection_status();
@ -104,10 +104,7 @@ prof_run(const int disable_tls, char *log_level, char *account_name)
ui_update_screen();
jabber_process_events();
ch = inp_get_char(inp, &size);
if (ch != ERR) {
ui_reset_idle_time();
}
ch = ui_get_char(inp, &size);
}
inp[size++] = '\0';
@ -202,7 +199,7 @@ process_input(char *inp)
result = cmd_execute_default(inp);
}
inp_win_reset();
ui_input_clear();
roster_reset_search_attempts();
ui_current_page_off();

View File

@ -52,6 +52,7 @@
#include "ui/ui.h"
#include "ui/titlebar.h"
#include "ui/statusbar.h"
#include "ui/inputwin.h"
#include "ui/window.h"
#include "ui/windows.h"
#include "xmpp/xmpp.h"
@ -155,6 +156,34 @@ _ui_close(void)
endwin();
}
static wint_t
_ui_get_char(char *input, int *size)
{
wint_t ch = inp_get_char(input, size);
if (ch != ERR) {
ui_reset_idle_time();
}
return ch;
}
static void
_ui_input_clear(void)
{
inp_win_reset();
}
static void
_ui_replace_input(char *input, const char * const new_input, int *size)
{
inp_replace_input(input, new_input, size);
}
static void
_ui_input_nonblocking(void)
{
inp_non_block();
}
static void
_ui_resize(const int ch, const char * const input, const int size)
{
@ -1863,4 +1892,8 @@ ui_init_module(void)
ui_update_presence =_ui_update_presence;
ui_about = _ui_about;
ui_statusbar_new = _ui_statusbar_new;
ui_get_char = _ui_get_char;
ui_input_clear = _ui_input_clear;
ui_input_nonblocking = _ui_input_nonblocking;
ui_replace_input = _ui_replace_input;
}

View File

@ -43,6 +43,7 @@
#include "roster_list.h"
#include "ui/ui.h"
#include "ui/statusbar.h"
#include "ui/inputwin.h"
#include "ui/windows.h"
#include "xmpp/xmpp.h"
@ -59,8 +60,8 @@ static int _printable(const wint_t ch);
static void _clear_input(void);
static void _go_to_end(int display_size);
static void
_create_input_window(void)
void
create_input_window(void)
{
#ifdef NCURSES_REENTRANT
set_escdelay(25);
@ -75,8 +76,8 @@ _create_input_window(void)
_inp_win_update_virtual();
}
static void
_inp_win_resize(const char * const input, const int size)
void
inp_win_resize(const char * const input, const int size)
{
int inp_x;
getmaxyx(stdscr, rows, cols);
@ -93,20 +94,20 @@ _inp_win_resize(const char * const input, const int size)
_inp_win_update_virtual();
}
static void
_inp_non_block(void)
void
inp_non_block(void)
{
wtimeout(inp_win, 20);
}
static void
_inp_block(void)
void
inp_block(void)
{
wtimeout(inp_win, -1);
}
static wint_t
_inp_get_char(char *input, int *size)
wint_t
inp_get_char(char *input, int *size)
{
int inp_x = 0;
int i;
@ -208,8 +209,8 @@ _inp_get_char(char *input, int *size)
return ch;
}
static void
_inp_get_password(char *passwd)
void
inp_get_password(char *passwd)
{
_clear_input();
_inp_win_update_virtual();
@ -221,14 +222,14 @@ _inp_get_password(char *passwd)
status_bar_clear();
}
static void
_inp_put_back(void)
void
inp_put_back(void)
{
_inp_win_update_virtual();
}
static void
_inp_replace_input(char *input, const char * const new_input, int *size)
void
inp_replace_input(char *input, const char * const new_input, int *size)
{
int display_size;
strncpy(input, new_input, INP_WIN_MAX);
@ -240,8 +241,8 @@ _inp_replace_input(char *input, const char * const new_input, int *size)
_go_to_end(display_size);
}
static void
_inp_win_reset(void)
void
inp_win_reset(void)
{
_clear_input();
pad_start = 0;
@ -708,18 +709,4 @@ _printable(const wint_t ch)
bytes[utf_len] = '\0';
gunichar unichar = g_utf8_get_char(bytes);
return g_unichar_isprint(unichar) && (ch != KEY_MOUSE);
}
void
inputwin_init_module(void)
{
create_input_window = _create_input_window;
inp_win_resize = _inp_win_resize;
inp_non_block = _inp_non_block;
inp_block = _inp_block;
inp_get_char = _inp_get_char;
inp_get_password = _inp_get_password;
inp_put_back = _inp_put_back;
inp_replace_input = _inp_replace_input;
inp_win_reset = _inp_win_reset;
}
}

36
src/ui/inputwin.h Normal file
View File

@ -0,0 +1,36 @@
/*
* inputwin.c
*
* Copyright (C) 2012 - 2014 James Booth <boothj5@gmail.com>
*
* This file is part of Profanity.
*
* Profanity is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Profanity is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Profanity. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef UI_INPUTWIN_H
#define UI_INPUTWIN_H
void create_input_window(void);
wint_t inp_get_char(char *input, int *size);
void inp_win_reset(void);
void inp_win_resize(const char * input, const int size);
void inp_put_back(void);
void inp_non_block(void);
void inp_block(void);
void inp_get_password(char *passwd);
void inp_replace_input(char *input, const char * const new_input, int *size);
#endif

View File

@ -35,6 +35,7 @@
#include "config/theme.h"
#include "ui/ui.h"
#include "ui/statusbar.h"
#include "ui/inputwin.h"
#define TIME_CHECK 60000000

View File

@ -28,6 +28,7 @@
#include "config/preferences.h"
#include "ui/ui.h"
#include "ui/titlebar.h"
#include "ui/inputwin.h"
#include "ui/windows.h"
#include "ui/window.h"
#include "roster_list.h"

View File

@ -155,8 +155,10 @@ void (*ui_update_presence)(const resource_presence_t resource_presence,
void (*ui_about)(void);
void (*ui_statusbar_new)(const int win);
// create windows
void (*create_input_window)(void);
wint_t (*ui_get_char)(char *input, int *size);
void (*ui_input_clear)(void);
void (*ui_input_nonblocking)(void);
void (*ui_replace_input)(char *input, const char * const new_input, int *size);
// console window actions
void (*cons_show)(const char * const msg, ...);
@ -230,16 +232,6 @@ void (*cons_autoconnect_setting)(void);
void (*cons_show_contact_online)(PContact contact, Resource *resource, GDateTime *last_activity);
void (*cons_show_contact_offline)(PContact contact, char *resource, char *status);
// input window actions
wint_t (*inp_get_char)(char *input, int *size);
void (*inp_win_reset)(void);
void (*inp_win_resize)(const char * input, const int size);
void (*inp_put_back)(void);
void (*inp_non_block)(void);
void (*inp_block)(void);
void (*inp_get_password)(char *passwd);
void (*inp_replace_input)(char *input, const char * const new_input, int *size);
// desktop notifier actions
void (*notifier_init)(void);
void (*notifier_uninit)(void);