]> git.ipfire.org Git - thirdparty/newt.git/blobdiff - newt.c
install python modules to purelib and platlib
[thirdparty/newt.git] / newt.c
diff --git a/newt.c b/newt.c
index 605b6facccbddacec0e5c954f2ab8c5aa4ae5677..7b58f1709bf61cf97c6fd710a3b8e0d11792411f 100644 (file)
--- a/newt.c
+++ b/newt.c
@@ -8,6 +8,7 @@
 #include <sys/time.h>
 #include <sys/types.h>
 #include <termios.h>
+#include <time.h>
 #include <unistd.h>
 #include <wchar.h>
 
@@ -38,6 +39,7 @@ static char ** currentHelpline = NULL;
 
 static int cursorRow, cursorCol;
 static int cursorOn = 1;
+static int noFlowCtrl = 0;
 static int trashScreen = 0;
 extern int needResize;
 
@@ -134,11 +136,6 @@ static const struct keymap keymap[] = {
 static void initKeymap();
 static void freeKeymap();
 
-static const char ident[] = // ident friendly
-    "$Version: Newt windowing library v" VERSION " $"
-    "$Copyright: (C) 1996-2003 Red Hat, Inc. Written by Erik Troan $"
-    "$License: Lesser GNU Public License. $";
-
 static newtSuspendCallback suspendCallback = NULL;
 static void * suspendCallbackData = NULL;
 
@@ -237,7 +234,6 @@ static void updateColorset(char *fg, char *bg, char **fg_p, char **bg_p)
 static void parseColors(char *s, struct newtColors *palette)
 {
     char *name, *str, *fg, *bg;
-    int i;
 
     for (str = s; (s = strtok(str, ";:\n\r\t ")); str = NULL) {
        name = s;
@@ -356,7 +352,7 @@ void newtSuspend(void) {
 int newtResume(void) {
     SLsmg_resume_smg ();
     SLsmg_refresh();
-    return SLang_init_tty(0, 0, 0);
+    return SLang_init_tty(0, noFlowCtrl, 0);
 }
 
 void newtCls(void) {
@@ -387,6 +383,7 @@ void newtResizeScreen(int redraw) {
  */
 int newtInit(void) {
     char * MonoValue, * MonoEnv = "NEWT_MONO";
+    char * NoFlowCtrlValue, * NoFlowCtrlEnv = "NEWT_NOFLOWCTRL";
     const char *lang;
     int ret;
 
@@ -399,8 +396,6 @@ int newtInit(void) {
     if (strstr (lang, ".euc") != NULL)
        trashScreen = 1;
 
-    (void) strlen(ident);
-
     SLutf8_enable(-1);
     SLtt_get_terminfo();
     SLtt_get_screen_size();
@@ -409,9 +404,13 @@ int newtInit(void) {
     if ( MonoValue != NULL )
        SLtt_Use_Ansi_Colors = 0;
 
+    NoFlowCtrlValue = getenv(NoFlowCtrlEnv);
+    if ( NoFlowCtrlValue != NULL )
+        noFlowCtrl = 1;
+
     if ((ret = SLsmg_init_smg()) < 0)
        return ret;
-    if ((ret = SLang_init_tty(0, 0, 0)) < 0)
+    if ((ret = SLang_init_tty(0, noFlowCtrl, 0)) < 0)
        return ret;
 
     initColors();
@@ -868,8 +867,6 @@ void newtPopWindowNoRefresh(void) {
     if (currentWindow == NULL)
        return;
 
-    row = col = 0;
-
     row = currentWindow->top - 1;
     col = currentWindow->left - 2;
     if (row < 0)
@@ -1028,7 +1025,9 @@ static void freeKeymap() {
  * @param int - number of usecs to wait for.
  */
 void newtDelay(unsigned int usecs) {
-    usleep(usecs);
+    struct timespec t = { usecs / 1000000, (usecs % 1000000) * 1000 };
+
+    nanosleep(&t, NULL);
 }
 
 struct eventResult newtDefaultEventHandler(newtComponent c,
@@ -1064,6 +1063,7 @@ void newtRedrawHelpLine(void) {
     }
     SLsmg_gotorc(SLtt_Screen_Rows - 1, 0);
     SLsmg_write_string(buf);
+    SLsmg_gotorc(cursorRow, cursorCol);
 }
 
 void newtPushHelpLine(const char * text) {
@@ -1161,3 +1161,12 @@ void newtTrashScreen(void) {
        SLsmg_touch_lines(0, SLtt_Screen_Rows);
 }
      
+void newtComponentGetPosition(newtComponent co, int * left, int * top) {
+    if (left) *left = co->left;
+    if (top) *top = co->top;
+}
+
+void newtComponentGetSize(newtComponent co, int * width, int * height) {
+    if (width) *width = co->width;
+    if (height) *height = co->height;
+}