aboutsummaryrefslogtreecommitdiff
path: root/src/messenger_cli.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/messenger_cli.c')
-rw-r--r--src/messenger_cli.c60
1 files changed, 56 insertions, 4 deletions
diff --git a/src/messenger_cli.c b/src/messenger_cli.c
index 253a1ae..97ab83d 100644
--- a/src/messenger_cli.c
+++ b/src/messenger_cli.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2021 GNUnet e.V. 3 Copyright (C) 2021--2022 GNUnet e.V.
4 4
5 GNUnet is free software: you can redistribute it and/or modify it 5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published 6 under the terms of the GNU Affero General Public License as published
@@ -22,10 +22,14 @@
22 * @file messenger_cli.c 22 * @file messenger_cli.c
23 */ 23 */
24 24
25#include <stdlib.h>
26#include <curses.h>
27
25#include <gnunet/platform.h> 28#include <gnunet/platform.h>
26#include <gnunet/gnunet_chat_lib.h> 29#include <gnunet/gnunet_chat_lib.h>
27#include <gnunet/gnunet_util_lib.h> 30#include <gnunet/gnunet_util_lib.h>
28 31
32
29static void 33static void
30run (void *cls, char* const* args, 34run (void *cls, char* const* args,
31 const char *cfgfile, 35 const char *cfgfile,
@@ -34,12 +38,60 @@ run (void *cls, char* const* args,
34 struct GNUNET_CHAT_Handle *handle = GNUNET_CHAT_start( 38 struct GNUNET_CHAT_Handle *handle = GNUNET_CHAT_start(
35 cfg, 39 cfg,
36 "appdir", 40 "appdir",
37 "username",
38 NULL, NULL,
39 NULL, NULL 41 NULL, NULL
40 ); 42 );
41 43
42 // 44 initscr();
45 noecho();
46
47 int bx, by, mx, my;
48 getbegyx(stdscr, by, bx);
49 getmaxyx(stdscr, my, mx);
50
51 WINDOW *win = newwin(15, 30, by + (my - by - 15) / 2, bx + (mx - bx - 30) / 2);
52
53 char c;
54 do {
55 getbegyx(stdscr, by, bx);
56 getmaxyx(stdscr, my, mx);
57
58 int x = bx + (mx - bx - 30) / 2;
59 int y = by + (my - by - 15) / 2;
60
61 int w = 30;
62 int h = 15;
63
64 if (mx - x < w)
65 w = (mx - x > 0? mx - x : 0);
66
67 if (my - y < h)
68 h = (my - y > 0? my - y : 0);
69
70 if (w * h > 0)
71 {
72 mvwin(win, y, x);
73 wresize(win, h, w);
74
75 werase(win);
76 box(win, 0, 0);
77
78 wmove(win, 1, 1);
79 wprintw(win, "%d %d, %d %d", bx, by, mx, my);
80
81 c = wgetch(win);
82 }
83 else
84 {
85 c = getch();
86 }
87
88 clear();
89 refresh();
90 } while (c != 'q');
91
92 delwin(win);
93
94 endwin();
43 95
44 GNUNET_CHAT_stop(handle); 96 GNUNET_CHAT_stop(handle);
45} 97}