1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00
profanity/profanity.c

81 lines
1.8 KiB
C
Raw Normal View History

2012-02-20 15:07:38 -05:00
/*
* profanity.c
*
* Copyright (C) 2012 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/>.
*
*/
2012-02-09 17:24:03 -05:00
#include <string.h>
#include <stdlib.h>
2012-02-09 17:24:03 -05:00
#include <ncurses.h>
#include "profanity.h"
2012-02-05 10:10:10 -05:00
#include "log.h"
2012-02-05 18:08:15 -05:00
#include "windows.h"
2012-02-09 17:24:03 -05:00
#include "jabber.h"
2012-02-09 18:15:53 -05:00
#include "command.h"
2012-02-26 20:44:09 -05:00
#include "history.h"
2012-02-09 17:24:03 -05:00
static void _profanity_shutdown(void);
2012-02-29 20:44:47 -05:00
void profanity_run(void)
2012-02-09 17:50:19 -05:00
{
2012-02-09 18:15:53 -05:00
int cmd_result = TRUE;
2012-02-09 17:50:19 -05:00
inp_non_block();
2012-02-09 18:15:53 -05:00
while(cmd_result == TRUE) {
2012-02-09 17:50:19 -05:00
int ch = ERR;
2012-04-22 20:14:14 -04:00
char inp[200];
2012-02-09 17:50:19 -05:00
int size = 0;
2012-02-29 20:52:35 -05:00
while(ch != '\n') {
win_handle_special_keys(&ch);
2012-04-22 15:59:36 -04:00
2012-04-17 18:28:21 -04:00
if (ch == KEY_RESIZE) {
gui_resize(ch, inp, size);
}
2012-04-22 15:59:36 -04:00
gui_refresh();
jabber_process_events();
inp_get_char(&ch, inp, &size);
2012-02-29 20:52:35 -05:00
}
2012-02-16 19:42:41 -05:00
2012-02-19 20:42:29 -05:00
inp[size++] = '\0';
cmd_result = process_input(inp);
2012-02-09 17:50:19 -05:00
}
}
2012-03-08 20:06:55 -05:00
void profanity_init(const int disable_tls)
2012-02-26 20:48:51 -05:00
{
2012-02-29 20:44:47 -05:00
log_init();
gui_init();
2012-02-26 20:48:51 -05:00
jabber_init(disable_tls);
history_init();
atexit(_profanity_shutdown);
2012-02-26 20:48:51 -05:00
}
void _profanity_shutdown(void)
2012-02-29 20:44:47 -05:00
{
jabber_disconnect();
gui_close();
log_close();
}