lnav/test/test_ncurses_unicode.cc

41 lines
870 B
C++
Raw Normal View History

#include <stdlib.h>
2022-03-16 22:38:08 +00:00
#include "config.h"
#define _XOPEN_SOURCE_EXTENDED 1
#include <locale.h>
#if defined HAVE_NCURSESW_CURSES_H
2022-03-16 22:38:08 +00:00
# include <ncursesw/curses.h>
#elif defined HAVE_NCURSESW_H
2022-03-16 22:38:08 +00:00
# include <ncursesw.h>
#elif defined HAVE_NCURSES_CURSES_H
2022-03-16 22:38:08 +00:00
# include <ncurses/curses.h>
#elif defined HAVE_NCURSES_H
2022-03-16 22:38:08 +00:00
# include <ncurses.h>
#elif defined HAVE_CURSES_H
2022-03-16 22:38:08 +00:00
# include <curses.h>
#else
2022-03-16 22:38:08 +00:00
# error "SysV or X/Open-compatible Curses header file required"
#endif
2022-03-16 22:38:08 +00:00
int
main(int argc, char* argv[])
{
setenv("LANG", "en_US.utf-8", 1);
setlocale(LC_ALL, "");
2022-03-16 22:38:08 +00:00
WINDOW* stdscr = initscr();
cbreak();
char buf[1024];
2022-03-16 22:38:08 +00:00
FILE* file = fopen(argv[1], "r");
int row = 0;
while (!feof(file)) {
if (fgets(buf, sizeof(buf), file) != nullptr) {
mvwaddstr(stdscr, row++, 0, buf);
}
}
getch();
endwin();
}