Initial NCURSES Support

Initial NCURSES Support

Its in there, and can be called with -N, but it doesn't display much yet aside from program name, mbelib, and time.
Just want to upload it so I can test it vs autobuild with cmake requiring ncurses libraries again
This commit is contained in:
lwvmobile
2022-02-11 19:25:05 -05:00
committed by GitHub
parent 142fb0c60e
commit 9092259ce1
6 changed files with 215 additions and 35 deletions

102
src/dsd_ncurses.c Normal file
View File

@@ -0,0 +1,102 @@
/*-------------------------------------------------------------------------------
* dsd_ncurses.c
* A dsd ncurses terminal printer
*
* ASCII art generated by:
* https://fsymbols.com/generators/carty/
*
* LWVMOBILE
* 2022-02 DSD-FME Florida Man Edition
*-----------------------------------------------------------------------------*/
/*
* Copyright (C) 2010 DSD Author
* GPG Key ID: 0x3F1D7FD0 (74EF 430D F7F2 0A48 FCE6 F630 FAA2 635D 3F1D 7FD0)
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include "dsd.h"
#include "git_ver.h"
char versionstr[25];
char * FM_bannerN[9] = {
" CTRL + C twice to exit",
" ██████╗ ██████╗██████╗    ███████╗███╗ ███╗███████╗",
" ██╔══██╗██╔════╝██╔══██╗   ██╔════╝████╗ ████║██╔════╝",
" ██║ ██║╚█████╗ ██║ ██║   █████╗ ██╔████╔██║█████╗ ",
" ██║ ██║ ╚═══██╗██║ ██║   ██╔══╝ ██║╚██╔╝██║██╔══╝ ",
" ██████╔╝██████╔╝██████╔╝   ██║ ██║ ╚═╝ ██║███████╗",
" ╚═════╝ ╚═════╝ ╚═════╝    ╚═╝ ╚═╝ ╚═╝╚══════╝",
};
time_t nowN;
char * getTimeN(void) //get pretty hh:mm:ss timestamp
{
time_t t = time(NULL);
char * curr;
char * stamp = asctime(localtime( & t));
curr = strtok(stamp, " ");
curr = strtok(NULL, " ");
curr = strtok(NULL, " ");
curr = strtok(NULL, " ");
return curr;
}
void ncursesOpen ()
{
mbe_printVersion (versionstr);
//setlocale(LC_ALL, "");
initscr(); //Initialize NCURSES screen window
start_color();
init_pair(1, COLOR_YELLOW, COLOR_BLACK); //Yellow/Amber for frame sync/control channel, NV style
init_pair(2, COLOR_RED, COLOR_BLACK); //Red for Terminated Calls
init_pair(3, COLOR_GREEN, COLOR_BLACK); //Green for Active Calls
init_pair(4, COLOR_CYAN, COLOR_BLACK); //Cyan for Site Extra and Patches
init_pair(5, COLOR_MAGENTA, COLOR_BLACK); //Magenta for no frame sync/signal
noecho();
cbreak();
}
void
ncursesPrinter (dsd_opts * opts, dsd_state * state)
{
erase();
//disabling until wide support can be built for LM, etc. $(ncursesw5-config --cflags --libs)
//printw("%s \n", FM_bannerN[0]); //top line in white
//attron(COLOR_PAIR(4));
//for (short int i = 1; i < 7; i++) { //following lines in cyan
//printw("%s \n", FM_bannerN[i]); }
//attroff(COLOR_PAIR(4));
printw("Digital Speech Decoder: Florida Man Edition\n");
printw("mbelib version %s\n", versionstr);
printw("Time: ");
printw("%s ", getTimeN());
if (state->lastsynctype == 8 ||state->lastsynctype == 9 ||state->lastsynctype == 16 ||state->lastsynctype == 17)
{
printw("NXDN");
}
printw("\n"); //line return
//add other interesting info to put here
refresh();
}
void ncursesClose ()
{
erase();
refresh();
endwin();
}