Show source link on exit
Этот коммит содержится в:
родитель
8fdf2c402d
Коммит
6df61b5dda
12
chat.c
12
chat.c
@ -19,6 +19,7 @@
|
|||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
#include <signal.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -27,7 +28,14 @@
|
|||||||
|
|
||||||
#include "chat.h"
|
#include "chat.h"
|
||||||
|
|
||||||
char *prompt(const char *prompt) {
|
static void sigint(int sig) {
|
||||||
|
(void)sig;
|
||||||
|
input(L"/quit");
|
||||||
|
uiHide();
|
||||||
|
exit(EX_OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *prompt(const char *prompt) {
|
||||||
char *line = NULL;
|
char *line = NULL;
|
||||||
size_t cap;
|
size_t cap;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@ -67,6 +75,8 @@ int main(int argc, char *argv[]) {
|
|||||||
if (!chat.nick) chat.nick = prompt("Name: ");
|
if (!chat.nick) chat.nick = prompt("Name: ");
|
||||||
chat.user = strdup(chat.nick);
|
chat.user = strdup(chat.nick);
|
||||||
|
|
||||||
|
signal(SIGINT, sigint);
|
||||||
|
|
||||||
uiInit();
|
uiInit();
|
||||||
uiLog("Traveling...");
|
uiLog("Traveling...");
|
||||||
uiDraw();
|
uiDraw();
|
||||||
|
2
chat.h
2
chat.h
@ -14,6 +14,8 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define SOURCE_URL "https://code.causal.agency/june/chat"
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
4
ui.c
4
ui.c
@ -100,6 +100,10 @@ static void uiResize(void) {
|
|||||||
|
|
||||||
void uiHide(void) {
|
void uiHide(void) {
|
||||||
endwin();
|
endwin();
|
||||||
|
printf(
|
||||||
|
"This program is AGPLv3 free software!\n"
|
||||||
|
"The source is available at <" SOURCE_URL ">\n"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiDraw(void) {
|
void uiDraw(void) {
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user