sdgtk -> sdgui, improve build, mention in README
It's finally not horrible.
This commit is contained in:
29
src/sdtui.c
29
src/sdtui.c
@@ -36,8 +36,12 @@
|
||||
#include <signal.h>
|
||||
#include <pwd.h>
|
||||
|
||||
#include <termo.h> // input
|
||||
#include <ncurses.h> // output
|
||||
#include <termo.h> // input
|
||||
#include <ncurses.h> // output
|
||||
#include <termios.h>
|
||||
#ifndef TIOCGWINSZ
|
||||
#include <sys/ioctl.h>
|
||||
#endif // ! TIOCGWINSZ
|
||||
|
||||
#include "config.h"
|
||||
#include "stardict.h"
|
||||
@@ -62,6 +66,27 @@ unichar_width (gunichar ch)
|
||||
return 1 + g_unichar_iswide (ch);
|
||||
}
|
||||
|
||||
void
|
||||
update_curses_terminal_size (void)
|
||||
{
|
||||
#if defined (HAVE_RESIZETERM) && defined (TIOCGWINSZ)
|
||||
struct winsize size;
|
||||
if (!ioctl (STDOUT_FILENO, TIOCGWINSZ, (char *) &size))
|
||||
{
|
||||
char *row = getenv ("LINES");
|
||||
char *col = getenv ("COLUMNS");
|
||||
unsigned long tmp;
|
||||
resizeterm (
|
||||
(row && xstrtoul (&tmp, row, 10)) ? tmp : size.ws_row,
|
||||
(col && xstrtoul (&tmp, col, 10)) ? tmp : size.ws_col);
|
||||
}
|
||||
#else // HAVE_RESIZETERM && TIOCGWINSZ
|
||||
// The standard endwin/refresh sequence makes the terminal flicker.
|
||||
endwin ();
|
||||
refresh ();
|
||||
#endif // HAVE_RESIZETERM && TIOCGWINSZ
|
||||
}
|
||||
|
||||
static guint
|
||||
add_read_watch (int fd, GIOFunc func, gpointer user_data)
|
||||
{
|
||||
|
||||
28
src/utils.c
28
src/utils.c
@@ -23,12 +23,6 @@
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <curses.h>
|
||||
#include <termios.h>
|
||||
#ifndef TIOCGWINSZ
|
||||
#include <sys/ioctl.h>
|
||||
#endif // ! TIOCGWINSZ
|
||||
|
||||
#include "config.h"
|
||||
#include "utils.h"
|
||||
|
||||
@@ -101,28 +95,6 @@ xstrtoul (unsigned long *out, const char *s, int base)
|
||||
return errno == 0 && !*end && end != s;
|
||||
}
|
||||
|
||||
// Didn't want to have this ugly piece of code in the main source file;
|
||||
// the standard endwin/refresh sequence makes the terminal flicker.
|
||||
void
|
||||
update_curses_terminal_size (void)
|
||||
{
|
||||
#if defined (HAVE_RESIZETERM) && defined (TIOCGWINSZ)
|
||||
struct winsize size;
|
||||
if (!ioctl (STDOUT_FILENO, TIOCGWINSZ, (char *) &size))
|
||||
{
|
||||
char *row = getenv ("LINES");
|
||||
char *col = getenv ("COLUMNS");
|
||||
unsigned long tmp;
|
||||
resizeterm (
|
||||
(row && xstrtoul (&tmp, row, 10)) ? tmp : size.ws_row,
|
||||
(col && xstrtoul (&tmp, col, 10)) ? tmp : size.ws_col);
|
||||
}
|
||||
#else // HAVE_RESIZETERM && TIOCGWINSZ
|
||||
endwin ();
|
||||
refresh ();
|
||||
#endif // HAVE_RESIZETERM && TIOCGWINSZ
|
||||
}
|
||||
|
||||
/// Print a fatal error message and terminate the process immediately.
|
||||
void
|
||||
fatal (const gchar *format, ...)
|
||||
|
||||
@@ -41,7 +41,6 @@ gchar *xdxf_to_pango_markup_with_reduced_effort (const gchar *xml);
|
||||
gboolean stream_read_all (GByteArray *ba, GInputStream *is, GError **error);
|
||||
gchar *stream_read_string (GDataInputStream *dis, GError **error);
|
||||
gboolean xstrtoul (unsigned long *out, const char *s, int base);
|
||||
void update_curses_terminal_size (void);
|
||||
void fatal (const gchar *format, ...) G_GNUC_PRINTF (1, 2) G_GNUC_NORETURN;
|
||||
|
||||
#endif // ! UTILS_H
|
||||
|
||||
Reference in New Issue
Block a user