X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=include%2Fviewer.h;h=8850c7f841844db04f71225461d87f84df0dc4c7;hb=c093b8dd5e29a2afb22988023d32261be1d41978;hp=89837ec89b322a074ec4e4b3b6681cb8bdd8e15a;hpb=f4e453fa3619de52dce9d98c5ad1441982c46539;p=smdp.git diff --git a/include/viewer.h b/include/viewer.h index 89837ec..8850c7f 100644 --- a/include/viewer.h +++ b/include/viewer.h @@ -1,24 +1,63 @@ #if !defined( VIEWER_H ) #define VIEWER_H -#define CP_WHITE 1 // 255 -#define CP_BLUE 2 // 123 -#define CP_RED 3 // 213 -#define CP_YELLOW 4 // 208 +/* + * Functions necessary to display a deck of slides in different color modes + * using ncurses. Only white, red, and blue are supported, as they can be + * faded in 256 color mode. + * Copyright (C) 2018 Michael Goehler + * + * This file is part of mdp. + * + * This program 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. + * + * This program 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 this program. If not, see . + * + * + * function: ncurses_display initializes ncurses, defines colors, calculates + * window geometry and handles key strokes + * function: add_line detects inline markdown formatting and prints line char + * by char + * function: fade_in, fade_out implementing color fading in 256 color mode + * function: int_length to calculate decimal length of slide count + * + */ -static short white_ramp[24] = { 16, 232, 233, 234, 235, 236, - 237, 238, 239, 240, 241, 242, - 244, 245, 246, 247, 248, 249, - 250, 251, 252, 253, 254, 255 }; +#define _GNU_SOURCE // enable ncurses wchar support +#define _XOPEN_SOURCE_EXTENDED 1 // enable ncurses wchar support -static short blue_ramp[24] = { 16, 17, 17, 18, 18, 19, - 19, 20, 20, 21, 27, 32, - 33, 38, 39, 44, 45, 45, - 81, 81, 51, 51, 123, 123 }; +#if defined( WIN32 ) +#include +#else +#include +#endif -static short red_ramp[24] = { 16, 52, 52, 53, 53, 89, - 89, 90, 90, 126, 127, 127, - 163, 163, 164, 164, 200, 200, - 201, 201, 207, 207, 213, 213 }; +#include "common.h" +#include "parser.h" +#include "cstack.h" +#include "url.h" + +#define CP_FG 1 +#define CP_HEADER 2 +#define CP_BOLD 3 +#define CP_TITLE 4 +#define CP_CODE 5 + +int ncurses_display(deck_t *deck, int reload, int noreload, int slidenum); +void add_line(WINDOW *window, int y, int x, line_t *line, int max_cols, int colors); +void inline_display(WINDOW *window, const wchar_t *c, const int colors); +int int_length (int val); +int get_slide_number(char init); +void setup_list_strings(void); +bool evaluate_binding(const int bindings[], char c); #endif // !defined( VIEWER_H )