--------------------------------
* Redefined library to use version-info
+ * Imported a bunch of distribution patches:
+ watch: support unicode
+ watch: add precision wait time option -p
+ watch: interpret ANSI color code sequences
+ watch: add -exec and -beep flags and has better quoting
+ w: use environment to set user and from/host column widths
+ w: use COLUMNS environment if TIOCGWINSZ fails
+ w: bassman emulation with -o option
+ vmstat: do not scale si/so just like bi/bo
+ libprocps-ng: sysinfo.c: truncate the vmstat figure to 32 bits
+ tload: remote unneeded optarg and optind variables
+ sysctl: fix up some option processing
+ skill: kill prints perror
+ skill: do not treat skill null parameter as 0
+ skill: fix too greedy option parser
+ libprocps-ng: readproc.c: some type conversion help
+ ps: rename SZ to SIZE
+ ps: add sorting to %mem for ps
+ pmap: provide information for -x option
+ pgrep: distinguish between invalid commandline parameters and '-?'
+ pgrep: fix compiler warning saved_start_time might be used uninitialized
+ pgrep: add -c option for counting number of matched proceesses
+ pwdx & libprocps-ng: Hurd does not have MAX_PATH defined
+ ps: --sort does not work with time argument
+ skill: add CR to warning line
+ contrib: minimal ps: define mips PAGE_SIZE
+ libproc-ng: prettyfy proc mount messages
+ ps: add build option to disable ps option warning
+ libproc-ng: support building without WCHAR support
+ sysctl: remove index() for buildroot
procps-ng-3.3.0 --> procps-ng-3.3.1
--------------------------------
AC_PROG_INSTALL
AC_PROG_LN_S
+AC_SUBST([WITH_WATCH8BIT])
+AC_ARG_ENABLE([watch8bit],
+ AS_HELP_STRING([--enable-watch8bit], [enable watch to be 8bit clean (requires ncursesw)]),
+ [enable_watch8bit=$enableval],
+ [enable_watch8bit="no"])
+if test "$enable_watch8bit" = "yes"; then
+ AC_DEFINE([WITH_WATCH8BIT], [1], [Enable 8 bit clean watch])
+fi
+
# Checks for header files.
AC_HEADER_MAJOR
AC_CHECK_HEADERS([\
AC_MSG_ERROR([ncurses support missing/incomplete (for partial build use --without-ncurses)])
fi
AM_CONDITIONAL(WITH_NCURSES, true)
+ if test "$enable_watch8bit" = yes; then
+ AC_CHECK_LIB([ncursesw], [addwstr], [WATCH_NCURSES_LIBS=-lncursesw],
+ [AC_MSG_ERROR([Cannot find ncurses wide library ncursesw with --enable-watch8bit])])
+ else
+ WATCH_NCURSES_LIBS="-lncurses"
+ fi
NCURSES_LIBS="-lncurses"
fi
AC_SUBST([NCURSES_LIBS])
+AC_SUBST([WATCH_NCURSES_LIBS])
usrbin_execdir='${exec_prefix}/usr/bin'
AC_SUBST([usrbin_execdir])
* Unicode Support added by Jarrod Lowe <procps@rrod.net> in 2009.
*/
+#include "config.h"
#include <ctype.h>
#include <getopt.h>
#include <signal.h>
-#include <ncurses.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <termios.h>
#include <locale.h>
#include "proc/procps.h"
-#include "config.h"
#include <errno.h>
+#ifdef WITH_WATCH8BIT
+#include <wchar.h>
+#include <ncursesw/ncurses.h>
+#else
+#include <ncurses.h>
+#endif /* WITH_WATCH8BIT */
#ifdef FORCE_8BIT
#undef isprint
return USECS_PER_SEC*now.tv_sec + now.tv_usec;
}
+#ifdef WITH_WATCH8BIT
// read a wide character from a popen'd stream
#define MAX_ENC_BYTES 16
wint_t my_getwc(FILE *s);
}
}
}
+#endif /* WITH_WATCH8BIT */
int
main(int argc, char *argv[])
option_help = 0, option_version = 0;
double interval = 2;
char *command;
- wchar_t *wcommand = NULL;
char **command_argv;
int command_length = 0; /* not including final \0 */
- int wcommand_columns = 0; /* not including final \0 */
- int wcommand_characters = 0; /* not including final \0 */
watch_usec_t next_loop; /* next loop time in us, used for precise time
keeping only */
+#ifdef WITH_WATCH8BIT
+ wchar_t *wcommand = NULL;
+ int wcommand_columns = 0; /* not including final \0 */
+ int wcommand_characters = 0; /* not including final \0 */
+#endif /* WITH_WATCH8BIT */
+
int pipefd[2];
int status;
pid_t child;
command[command_length] = '\0';
}
+#ifdef WITH_WATCH8BIT
// convert to wide for printing purposes
//mbstowcs(NULL, NULL, 0);
wcommand_characters = mbstowcs(NULL, command, 0);
}
mbstowcs(wcommand, command, wcommand_characters+1);
wcommand_columns = wcswidth(wcommand, -1);
-
+#endif /* WITH_WATCH8BIT */
get_terminal_size();
if(width < tsl + hlen + 4) {
mvaddstr(0, width - tsl - 4, "... ");
}else{
+#ifdef WITH_WATCH8BIT
if(width < tsl + hlen + wcommand_columns) {
// print truncated
int avail_columns = width - tsl - hlen;
}else{
mvaddwstr(0, hlen, wcommand);
}
+#else
+ mvaddnstr(0, hlen, command, width - tsl - hlen);
+#endif /* WITH_WATCH8BIT */
}
}
}
for (y = show_title; y < height; y++) {
int eolseen = 0, tabpending = 0;
+#ifdef WITH_WATCH8BIT
wint_t carry = WEOF;
+#endif /* WITH_WATCH8BIT */
for (x = 0; x < width; x++) {
+#ifdef WITH_WATCH8BIT
wint_t c = ' ';
+#else
+ int c = ' ';
+#endif /* WITH_WATCH8BIT */
int attr = 0;
if (!eolseen) {
/* if there is a tab pending, just spit spaces until the
next stop instead of reading characters */
if (!tabpending)
+#ifdef WITH_WATCH8BIT
do {
if(carry == WEOF) {
c = my_getwc(p);
&& c != L'\n'
&& c != L'\t'
&& (c != L'\033' || option_color != 1));
+#else
+ do
+ c = getc(p);
+ while (c != EOF && !isprint(c)
+ && c != '\n'
+ && c != '\t'
+ && (c != L'\033' || option_color != 1));
+#endif /* WITH_WATCH8BIT */
if (c == L'\033' && option_color == 1) {
x--;
process_ansi(p);
eolseen = 1;
else if (c == L'\t')
tabpending = 1;
+#ifdef WITH_WATCH8BIT
if (x==width-1 && wcwidth(c)==2) {
y++;
x = -1; //process this double-width
}
if (c == WEOF || c == L'\n' || c == L'\t')
c = L' ';
+#else
+ if (c == EOF || c == '\n' || c == '\t')
+ c = ' ';
+#endif /* WITH_WATCH8BIT */
if (tabpending && (((x + 1) % 8) == 0))
tabpending = 0;
}
move(y, x);
if (option_differences) {
+#ifdef WITH_WATCH8BIT
cchar_t oldc;
in_wch(&oldc);
attr = !first_screen
||
(option_differences_cumulative
&& (oldc.attr & A_ATTRIBUTES)));
+#else
+ chtype oldch = inch();
+ unsigned char oldc = oldch & A_CHARTEXT;
+ attr = !first_screen
+ && ((unsigned char)c != oldc
+ ||
+ (option_differences_cumulative
+ && (oldch & A_ATTRIBUTES)));
+#endif /* WITH_WATCH8BIT */
}
if (attr)
standout();
+#ifdef WITH_WATCH8BIT
addnwstr((wchar_t*)&c,1);
+#else
+ addch(c);
+#endif /* WITH_WATCH8BIT */
if (attr)
standend();
+#ifdef WITH_WATCH8BIT
if(wcwidth(c) == 0) { x--; }
if(wcwidth(c) == 2) { x++; }
+#endif /* WITH_WATCH8BIT */
}
oldeolseen = eolseen;
}