]> git.ipfire.org Git - thirdparty/newt.git/blobdiff - newt.h
install python modules to purelib and platlib
[thirdparty/newt.git] / newt.h
diff --git a/newt.h b/newt.h
index 2d4c559deea4637ef8ea9c4f230c1282b4965abb..07becc75bf4bb9d83a26b6e5f526deee06365916 100644 (file)
--- a/newt.h
+++ b/newt.h
@@ -31,6 +31,11 @@ extern "C" {
 #define NEWT_COLORSET_ACTSELLISTBOX    23
 #define NEWT_COLORSET_SELLISTBOX       24
 
+#define NEWT_COLORSET_CUSTOM(x)                (30 + (x))
+
+#define NEWT_ARG_LAST                  -100000
+#define NEWT_ARG_APPEND                        -1
+
 struct newtColors {
     char * rootFg, * rootBg;
     char * borderFg, * borderBg;
@@ -68,9 +73,20 @@ enum newtFlagsSense { NEWT_FLAGS_SET, NEWT_FLAGS_RESET, NEWT_FLAGS_TOGGLE };
 #define NEWT_FLAG_NOF12                (1 << 7)
 #define NEWT_FLAG_MULTIPLE      (1 << 8)
 #define NEWT_FLAG_SELECTED     (1 << 9)
-
+#define NEWT_FLAG_CHECKBOX     (1 << 10)
+#define NEWT_FLAG_PASSWORD      (1 << 11)  /* draw '*'  of chars in entrybox */
+#define NEWT_FLAG_SHOWCURSOR    (1 << 12) /* Only applies to listbox for now */
 #define NEWT_FD_READ           (1 << 0)
 #define NEWT_FD_WRITE          (1 << 1)
+#define NEWT_FD_EXCEPT         (1 << 2)
+
+#define NEWT_CHECKBOXTREE_UNSELECTABLE (1 << 12)
+#define NEWT_CHECKBOXTREE_HIDE_BOX     (1 << 13)
+
+#define NEWT_CHECKBOXTREE_COLLAPSED    '\0'
+#define NEWT_CHECKBOXTREE_EXPANDED     '\1'
+#define NEWT_CHECKBOXTREE_UNSELECTED   ' '
+#define NEWT_CHECKBOXTREE_SELECTED     '*'
 
 /* Backwards compatibility */
 #define NEWT_LISTBOX_RETURNEXIT NEWT_FLAG_RETURNEXIT
@@ -91,7 +107,7 @@ typedef struct newtComponent_struct * newtComponent;
 extern const struct newtColors newtDefaultColorPalette;
 
 typedef void (*newtCallback)(newtComponent, void *);
-typedef void (*newtSuspendCallback)(void);
+typedef void (*newtSuspendCallback)(void * data);
 
 int newtInit(void);
 int newtFinished(void);
@@ -99,22 +115,28 @@ void newtCls(void);
 void newtResizeScreen(int redraw);
 void newtWaitForKey(void);
 void newtClearKeyBuffer(void);
-void newtDelay(int usecs);
+void newtDelay(unsigned int usecs);
 /* top, left are *not* counting the border */
-int newtOpenWindow(int left, int top, int width, int height, 
-                         const char * title);
-int newtCenteredWindow(int width, int height, const char * title);
+int newtOpenWindow(int left,int top, 
+                  unsigned int width,unsigned  int height, 
+                 const char * title);
+int newtCenteredWindow(unsigned int width,unsigned int height, const char * title);
 void newtPopWindow(void);
+void newtPopWindowNoRefresh(void);
 void newtSetColors(struct newtColors colors);
+void newtSetColor(int colorset, char *fg, char *bg);
 void newtRefresh(void);
 void newtSuspend(void);
-void newtSetSuspendCallback(newtSuspendCallback cb);
-void newtResume(void);
+void newtSetSuspendCallback(newtSuspendCallback cb, void * data);
+void newtSetHelpCallback(newtCallback cb);
+int  newtResume(void);
 void newtPushHelpLine(const char * text);
 void newtRedrawHelpLine(void);
 void newtPopHelpLine(void);
 void newtDrawRootText(int col, int row, const char * text);
 void newtBell(void);
+void newtCursorOff(void);
+void newtCursorOn(void);
 
 /* Components */
 
@@ -130,17 +152,16 @@ void newtCheckboxSetFlags(newtComponent co, int flags, enum newtFlagsSense sense
 newtComponent newtRadiobutton(int left, int top, const char * text, int isDefault,
                              newtComponent prevButton);
 newtComponent newtRadioGetCurrent(newtComponent setMember);
-newtComponent newtListitem(int left, int top, const char * text, int isDefault,
-                             newtComponent prevItem, const void * data, int flags);
-void newtListitemSet(newtComponent co, const char * text);
-void * newtListitemGetData(newtComponent co);
+void newtRadioSetCurrent(newtComponent setMember);
 void newtGetScreenSize(int * cols, int * rows);
 
 newtComponent newtLabel(int left, int top, const char * text);
 void newtLabelSetText(newtComponent co, const char * text);
+void newtLabelSetColors(newtComponent co, int colorset);
 newtComponent newtVerticalScrollbar(int left, int top, int height,
                                    int normalColorset, int thumbColorset);
 void newtScrollbarSet(newtComponent co, int where, int total);
+void newtScrollbarSetColors(newtComponent co, int normal, int thumb);
 
 newtComponent newtListbox(int left, int top, int height, int flags);
 void * newtListboxGetCurrent(newtComponent co);
@@ -161,26 +182,52 @@ void **newtListboxGetSelection(newtComponent co, int *numitems);
 void newtListboxClearSelection(newtComponent co);
 void newtListboxSelectItem(newtComponent co, const void * key,
        enum newtFlagsSense sense);
-
-    
+/* Returns number of items currently in listbox. */
+int newtListboxItemCount(newtComponent co);
+
+newtComponent newtCheckboxTree(int left, int top, int height, int flags);
+newtComponent newtCheckboxTreeMulti(int left, int top, int height, char *seq, int flags);
+const void ** newtCheckboxTreeGetSelection(newtComponent co, int *numitems);
+const void * newtCheckboxTreeGetCurrent(newtComponent co);
+void newtCheckboxTreeSetCurrent(newtComponent co, void * item);
+const void ** newtCheckboxTreeGetMultiSelection(newtComponent co, int *numitems, char seqnum);
+/* last item is NEWT_ARG_LAST for all of these */
+int newtCheckboxTreeAddItem(newtComponent co, 
+                           const char * text, const void * data,
+                           int flags, int index, ...);
+int newtCheckboxTreeAddArray(newtComponent co, 
+                            const char * text, const void * data,
+                            int flags, int * indexes);
+int * newtCheckboxTreeFindItem(newtComponent co, void * data);
+void newtCheckboxTreeSetEntry(newtComponent co, const void * data,
+                             const char * text);
+void newtCheckboxTreeSetWidth(newtComponent co, int width);
+char newtCheckboxTreeGetEntryValue(newtComponent co, const void * data);
+void newtCheckboxTreeSetEntryValue(newtComponent co, const void * data,
+                                  char value);
 newtComponent newtTextboxReflowed(int left, int top, char * text, int width,
                                  int flexDown, int flexUp, int flags);
 newtComponent newtTextbox(int left, int top, int width, int height, int flags);
 void newtTextboxSetText(newtComponent co, const char * text);
 void newtTextboxSetHeight(newtComponent co, int height);
 int newtTextboxGetNumLines(newtComponent co);
+void newtTextboxSetColors(newtComponent co, int normal, int active);
 char * newtReflowText(char * text, int width, int flexDown, int flexUp,
                      int * actualWidth, int * actualHeight);
 
 struct newtExitStruct {
-    enum { NEWT_EXIT_HOTKEY, NEWT_EXIT_COMPONENT, NEWT_EXIT_FDREADY } reason;
+    enum { NEWT_EXIT_HOTKEY, NEWT_EXIT_COMPONENT, NEWT_EXIT_FDREADY,
+          NEWT_EXIT_TIMER, NEWT_EXIT_ERROR } reason;
     union {
+       int watch;
        int key;
        newtComponent co;
     } u;
 } ;
 
-newtComponent newtForm(newtComponent vertBar, const char * help, int flags);
+newtComponent newtForm(newtComponent vertBar, void * helpTag, int flags);
+void newtFormSetTimer(newtComponent form, int millisecs);
 void newtFormWatchFd(newtComponent form, int fd, int fdFlags);
 void newtFormSetSize(newtComponent co);
 newtComponent newtFormGetCurrent(newtComponent co);
@@ -194,31 +241,51 @@ newtComponent newtRunForm(newtComponent form);            /* obsolete */
 void newtFormRun(newtComponent co, struct newtExitStruct * es);
 void newtDrawForm(newtComponent form);
 void newtFormAddHotKey(newtComponent co, int key);
+int newtFormGetScrollPosition(newtComponent co);
+void newtFormSetScrollPosition(newtComponent co, int position);
 
 typedef int (*newtEntryFilter)(newtComponent entry, void * data, int ch,
                               int cursor);
 newtComponent newtEntry(int left, int top, const char * initialValue, int width,
-                       char ** resultPtr, int flags);
+                       const char ** resultPtr, int flags);
 void newtEntrySet(newtComponent co, const char * value, int cursorAtEnd);
 void newtEntrySetFilter(newtComponent co, newtEntryFilter filter, void * data);
 char * newtEntryGetValue(newtComponent co);
 void newtEntrySetFlags(newtComponent co, int flags, enum newtFlagsSense sense);
+void newtEntrySetColors(newtComponent co, int normal, int disabled);
+int newtEntryGetCursorPosition(newtComponent co);
+void newtEntrySetCursorPosition(newtComponent co, int position);
 
 newtComponent newtScale(int left, int top, int width, long long fullValue);
 void newtScaleSet(newtComponent co, unsigned long long amount);
+void newtScaleSetColors(newtComponent co, int empty, int full);
 
 void newtComponentAddCallback(newtComponent co, newtCallback f, void * data);
 void newtComponentTakesFocus(newtComponent co, int val);
 
+void newtComponentGetPosition(newtComponent co, int * left, int * top);
+void newtComponentGetSize(newtComponent co, int * width, int * height);
+
+/* This callback is called when a component is destroyed. */
+void newtComponentAddDestroyCallback(newtComponent co,
+                                     newtCallback f, void * data);
+
 /* this also destroys all of the components (including other forms) on the 
    form */
 void newtFormDestroy(newtComponent form);      
 
+/* NB: You SHOULD NOT call this for components which have been added
+ * to a form (ie. almost all components).  They are destroyed along
+ * with the form when you call newtFormDestroy.
+ */
+void newtComponentDestroy(newtComponent co);
+
 /* Key codes */
 
 #define NEWT_KEY_TAB                   '\t'
 #define NEWT_KEY_ENTER                 '\r'
 #define NEWT_KEY_SUSPEND               '\032'                  /* ctrl - z*/
+#define NEWT_KEY_ESCAPE                        '\e'
 #define NEWT_KEY_RETURN                        NEWT_KEY_ENTER
 
 #define NEWT_KEY_EXTRA_BASE            0x8000
@@ -233,6 +300,7 @@ void newtFormDestroy(newtComponent form);
 #define NEWT_KEY_UNTAB                 NEWT_KEY_EXTRA_BASE + 10
 #define NEWT_KEY_PGUP                  NEWT_KEY_EXTRA_BASE + 11
 #define NEWT_KEY_PGDN                  NEWT_KEY_EXTRA_BASE + 12
+#define NEWT_KEY_INSERT                        NEWT_KEY_EXTRA_BASE + 13
 
 #define NEWT_KEY_F1                    NEWT_KEY_EXTRA_BASE + 101
 #define NEWT_KEY_F2                    NEWT_KEY_EXTRA_BASE + 102
@@ -249,6 +317,7 @@ void newtFormDestroy(newtComponent form);
 
 /* not really a key, but newtGetKey returns it */
 #define NEWT_KEY_RESIZE                        NEWT_KEY_EXTRA_BASE + 113
+#define NEWT_KEY_ERROR                 NEWT_KEY_EXTRA_BASE + 114
 
 #define NEWT_ANCHOR_LEFT               (1 << 0)
 #define NEWT_ANCHOR_RIGHT              (1 << 1)