Half way there with the help screen

pull/36/head
Robert 2017-04-17 21:40:01 +00:00
rodzic 20ae9016e1
commit 47ec677639
3 zmienionych plików z 101 dodań i 1 usunięć

Wyświetl plik

@ -33,6 +33,7 @@
#include "server.h"
#include "gateway.h"
#include "config.h"
#include "gui.h"
#define VERSION "V1.8.6"
bool run = TRUE;
@ -161,6 +162,9 @@ struct TBandwidth
};
int LEDCounts[2];
int help_win_displayed = 0;
pthread_mutex_t var = PTHREAD_MUTEX_INITIALIZER;
#pragma pack(1)
@ -367,7 +371,10 @@ void ChannelPrintf(int Channel, int row, int column, const char *format, ... )
mvwaddstr( Config.LoRaDevices[Channel].Window, row, column, Buffer );
wrefresh( Config.LoRaDevices[Channel].Window );
if (! help_win_displayed)
{
wrefresh( Config.LoRaDevices[Channel].Window );
}
pthread_mutex_unlock( &var ); // unlock once you are done
@ -1773,6 +1780,10 @@ ProcessKeyPress( int ch )
case 'c':
ReTune( Channel, -0.001 );
break;
case 'h':
help_win_displayed = 1;
gui_show_help();
break;
default:
//LogMessage("KeyPress %d\n", ch);
return;

81
gui.c 100644
Wyświetl plik

@ -0,0 +1,81 @@
#include "gui.h"
extern int help_win_displayed;
WINDOW *create_help_win(int height, int width, int starty, int startx);
void destroy_help_win(WINDOW *local_win);
WINDOW *create_help_win(int height, int width, int starty, int startx)
{ WINDOW *local_win;
local_win = newwin(height, width, starty, startx);
box(local_win, 0 , 0); /* 0, 0 gives default characters
* for the vertical and horizontal
* lines */
wbkgd( local_win, COLOR_PAIR( 2 ) );
wrefresh(local_win); /* Show that box */
return local_win;
}
void destroy_help_win(WINDOW *local_win)
{
/* box(local_win, ' ', ' '); : This won't produce the desired
* result of erasing the window. It will leave it's four corners
* and so an ugly remnant of window.
*/
wborder(local_win, ' ', ' ', ' ',' ',' ',' ',' ',' ');
/* The parameters taken are
* 1. win: the window on which to operate
* 2. ls: character to be used for the left side of the window
* 3. rs: character to be used for the right side of the window
* 4. ts: character to be used for the top side of the window
* 5. bs: character to be used for the bottom side of the window
* 6. tl: character to be used for the top left corner of the window
* 7. tr: character to be used for the top right corner of the window
* 8. bl: character to be used for the bottom left corner of the window
* 9. br: character to be used for the bottom right corner of the window
*/
wrefresh(local_win);
delwin(local_win);
}
void gui_show_help ()
{
WINDOW *help_win;
int startx, starty, width, height;
int ch;
height = 14;
width = 76;
starty = 1; /* Calculating for a center placement */
startx = 2; /* of the window */
help_win = create_help_win(height, width, starty, startx);
while((ch = getch()) != 'c')
{
switch(ch)
{ case KEY_LEFT:
destroy_help_win(help_win);
help_win = create_help_win(height, width, starty,--startx);
break;
case KEY_RIGHT:
destroy_help_win(help_win);
help_win = create_help_win(height, width, starty,++startx);
break;
case KEY_UP:
destroy_help_win(help_win);
help_win = create_help_win(height, width, --starty,startx);
break;
case KEY_DOWN:
destroy_help_win(help_win);
help_win = create_help_win(height, width, ++starty,startx);
break;
}
}
help_win_displayed = 0;
}

8
gui.h 100644
Wyświetl plik

@ -0,0 +1,8 @@
#ifndef _GUI_H
#define _GUI_H
#include <ncurses.h>
void gui_show_help ();
#endif