cleanup: convert tab to spaces and trim tail spaces

This commit is contained in:
Vincent Wei
2020-02-02 10:53:31 +08:00
parent 8dbe2c63f1
commit 14d020cccf
831 changed files with 468564 additions and 468554 deletions

View File

@@ -83,7 +83,7 @@ const se_font_description se_font_desc = {
/* The following is the scripteasy mem pool definition */ /* The following is the scripteasy mem pool definition */
#define SE_MEM_POOL_SIZE (64 * 1024) #define SE_MEM_POOL_SIZE (64 * 1024)
#define SE_CACHE_MEM_POOL_SIZE (256 * 1024) #define SE_CACHE_MEM_POOL_SIZE (256 * 1024)
int se_minigui_mem_pool[SE_MEM_POOL_SIZE]; int se_minigui_mem_pool[SE_MEM_POOL_SIZE];

View File

@@ -130,9 +130,9 @@
/* If using the C implementation of alloca, define if you know the /* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be direction of stack growth for your system; otherwise it will be
automatically deduced at run-time. automatically deduced at run-time.
STACK_DIRECTION > 0 => grows toward higher addresses STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown */ STACK_DIRECTION = 0 => direction of growth unknown */
/* #undef STACK_DIRECTION */ /* #undef STACK_DIRECTION */
/* Define to 1 if you have the ANSI C header files. */ /* Define to 1 if you have the ANSI C header files. */

View File

@@ -130,9 +130,9 @@
/* If using the C implementation of alloca, define if you know the /* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be direction of stack growth for your system; otherwise it will be
automatically deduced at run-time. automatically deduced at run-time.
STACK_DIRECTION > 0 => grows toward higher addresses STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown */ STACK_DIRECTION = 0 => direction of growth unknown */
/* #undef STACK_DIRECTION */ /* #undef STACK_DIRECTION */
/* Define to 1 if you have the ANSI C header files. */ /* Define to 1 if you have the ANSI C header files. */

View File

@@ -130,9 +130,9 @@
/* If using the C implementation of alloca, define if you know the /* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be direction of stack growth for your system; otherwise it will be
automatically deduced at run-time. automatically deduced at run-time.
STACK_DIRECTION > 0 => grows toward higher addresses STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown */ STACK_DIRECTION = 0 => direction of growth unknown */
/* #undef STACK_DIRECTION */ /* #undef STACK_DIRECTION */
/* Define to 1 if you have the ANSI C header files. */ /* Define to 1 if you have the ANSI C header files. */

View File

@@ -366,7 +366,7 @@
/* #undef _MGINCOREFONT_VGAS */ /* #undef _MGINCOREFONT_VGAS */
/* Define if include in-core font: 12x12 RBF for GB2312 */ /* Define if include in-core font: 12x12 RBF for GB2312 */
#define _MGINCORERBF_GB12 1 #define _MGINCORERBF_GB12 1
/* Define if include in-core font: 16x16 RBF for GB2312 */ /* Define if include in-core font: 16x16 RBF for GB2312 */
/* #undef _MGINCORERBF_GB16 */ /* #undef _MGINCORERBF_GB16 */

View File

@@ -377,7 +377,7 @@
/* #undef _MGINCOREFONT_VGAS */ /* #undef _MGINCOREFONT_VGAS */
/* Define if include in-core font: 12x12 RBF for GB2312 */ /* Define if include in-core font: 12x12 RBF for GB2312 */
#define _MGINCORERBF_GB12 1 #define _MGINCORERBF_GB12 1
/* Define if include in-core font: 16x16 RBF for GB2312 */ /* Define if include in-core font: 16x16 RBF for GB2312 */
#define _MGINCORERBF_GB16 1 #define _MGINCORERBF_GB16 1

View File

@@ -377,7 +377,7 @@
/* #undef _MGINCOREFONT_VGAS */ /* #undef _MGINCOREFONT_VGAS */
/* Define if include in-core font: 12x12 RBF for GB2312 */ /* Define if include in-core font: 12x12 RBF for GB2312 */
#define _MGINCORERBF_GB12 1 #define _MGINCORERBF_GB12 1
/* Define if include in-core font: 16x16 RBF for GB2312 */ /* Define if include in-core font: 16x16 RBF for GB2312 */
#define _MGINCORERBF_GB16 1 #define _MGINCORERBF_GB16 1

View File

@@ -91,12 +91,12 @@
/* Define to 1 if you have the `tmpfile' function. */ /* Define to 1 if you have the `tmpfile' function. */
#define HAVE_TMPFILE 1 #define HAVE_TMPFILE 1
/*#define HAVE_MODE_T 1*/ /*#define HAVE_MODE_T 1*/
/* Define to 1 if you have the `mktime' function. */ /* Define to 1 if you have the `mktime' function. */
#define HAVE_MKTIME 1 #define HAVE_MKTIME 1
/* Define to 1 if you have the `time' function. */ /* Define to 1 if you have the `time' function. */
#define HAVE_TIME 1 #define HAVE_TIME 1
/* Define to 1 if you have the `localtime' function. */ /* Define to 1 if you have the `localtime' function. */
#define HAVE_LOCALTIME 1 #define HAVE_LOCALTIME 1
@@ -140,9 +140,9 @@
/* If using the C implementation of alloca, define if you know the /* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be direction of stack growth for your system; otherwise it will be
automatically deduced at run-time. automatically deduced at run-time.
STACK_DIRECTION > 0 => grows toward higher addresses STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown */ STACK_DIRECTION = 0 => direction of growth unknown */
/* #undef STACK_DIRECTION */ /* #undef STACK_DIRECTION */
/* Define to 1 if you have the ANSI C header files. */ /* Define to 1 if you have the ANSI C header files. */

View File

@@ -24,5 +24,5 @@
#pragma warning(disable:4101) /* unreferenced local variable */ #pragma warning(disable:4101) /* unreferenced local variable */
#pragma warning(error:4150) #pragma warning(error:4150)
#pragma warning(disable:4244) /* No possible loss of data warnings */ #pragma warning(disable:4244) /* No possible loss of data warnings */
#pragma warning(disable:4305) /* No truncation from int to char warnings */ #pragma warning(disable:4305) /* No truncation from int to char warnings */

View File

@@ -1,5 +1,13 @@
#!/bin/bash #!/bin/bash
tab2space() {
sed -i 's/\t/ /g' `find . -name '*.c'`
sed -i 's/\t/ /g' `find . -name '*.h'`
sed -i 's/\s\+$//g' `find . -name '*.c'`
sed -i 's/\s\+$//g' `find . -name '*.h'`
}
# templates # templates
# sed -i 's/\<AAA\>/__AAA/g' `grep AAA -rl include/ src/` # sed -i 's/\<AAA\>/__AAA/g' `grep AAA -rl include/ src/`
# sed -i 's/\<AAA\>/__mgAAA/g' `grep AAA -rl include/ src/` # sed -i 's/\<AAA\>/__mgAAA/g' `grep AAA -rl include/ src/`
@@ -41,4 +49,6 @@
# sed -i 's/\<sysres_init_inner_resource\>/__sysres_init_inner_resource/g' `grep sysres_init_inner_resource -rl include/ src/` # sed -i 's/\<sysres_init_inner_resource\>/__sysres_init_inner_resource/g' `grep sysres_init_inner_resource -rl include/ src/`
# sed -i 's/\<sysres_get_system_res_path\>/__sysres_get_system_res_path/g' `grep sysres_get_system_res_path -rl include/ src/` # sed -i 's/\<sysres_get_system_res_path\>/__sysres_get_system_res_path/g' `grep sysres_get_system_res_path -rl include/ src/`
tab2space
exit 0 exit 0

View File

@@ -2,19 +2,19 @@
* The following code destroies all resource used by the main window * The following code destroies all resource used by the main window
* and then destroies the main window itself. * and then destroies the main window itself.
*/ */
case MSG_CLOSE: case MSG_CLOSE:
/* Destroy the resource used by the main window. */ /* Destroy the resource used by the main window. */
DestroyLogFont (logfont1); DestroyLogFont (logfont1);
DestroyLogFont (logfont2); DestroyLogFont (logfont2);
DestroyLogFont (logfont3); DestroyLogFont (logfont3);
/* Destroy the child windows. */ /* Destroy the child windows. */
DestroyWindow(hWndButton); DestroyWindow(hWndButton);
DestroyWindow(hWndEdit); DestroyWindow(hWndEdit);
/* Destroy the main window. */ /* Destroy the main window. */
DestroyMainWindow (hWnd); DestroyMainWindow (hWnd);
/* Send a MSG_QUIT message to quit the message loop. */ /* Send a MSG_QUIT message to quit the message loop. */
PostQuitMessage(hWnd); PostQuitMessage(hWnd);
return 0; return 0;

View File

@@ -2,10 +2,10 @@
* The handler makes sure that the client area always * The handler makes sure that the client area always
* is _WIDTH wide and _HEIGHT high. * is _WIDTH wide and _HEIGHT high.
*/ */
case MSG_SIZECHANGED: case MSG_SIZECHANGED:
{ {
RECT* rcClient = (RECT*)lParam; RECT* rcClient = (RECT*)lParam;
rcClient->right = rcClient->left + _WIDTH; rcClient->right = rcClient->left + _WIDTH;
rcClient->bottom = rcClient->top + _HEIGHT; rcClient->bottom = rcClient->top + _HEIGHT;
return 1; return 1;
} }

View File

@@ -2,14 +2,14 @@
* The handler set the actual size of the window always * The handler set the actual size of the window always
* to be _WIDTH wide and _HEIGHT high. * to be _WIDTH wide and _HEIGHT high.
*/ */
case MSG_SIZECHANGING: case MSG_SIZECHANGING:
{ {
const RECT* rcExpect = (const RECT*)wParam; const RECT* rcExpect = (const RECT*)wParam;
RECT* rcResult = (RECT*)lParam; RECT* rcResult = (RECT*)lParam;
rcResult->left = rcExpect->left; rcResult->left = rcExpect->left;
rcResult->top = rcExpect->top; rcResult->top = rcExpect->top;
rcResult->right = rcExpect->left + _WIDTH; rcResult->right = rcExpect->left + _WIDTH;
rcResult->bottom = rcExpect->top + _HEIGHT; rcResult->bottom = rcExpect->top + _HEIGHT;
return 0; return 0;
} }

View File

@@ -3,14 +3,14 @@
*/ */
case MSG_PAINT: case MSG_PAINT:
{ {
HDC hdc = BeginPaint (hWnd); HDC hdc = BeginPaint (hWnd);
for (j = 0; j < 10; j ++) { for (j = 0; j < 10; j ++) {
if (RectVisible (hdc, rcs + j)) { if (RectVisible (hdc, rcs + j)) {
FillBox (hdc, rcs[j].left, rcs[j].top, rcs [j].right, rcs [j].bottom); FillBox (hdc, rcs[j].left, rcs[j].top, rcs [j].right, rcs [j].bottom);
} }
} }
EndPaint (hWnd, hdc); EndPaint (hWnd, hdc);
return 0; return 0;
} }

View File

@@ -128,9 +128,9 @@ typedef struct _IVITEMINFO
typedef IVITEMINFO* PIVITEMINFO; typedef IVITEMINFO* PIVITEMINFO;
/** Iconview bitmap flags, reserved */ /** Iconview bitmap flags, reserved */
#define IVFLAG_BITMAP 0x0001 #define IVFLAG_BITMAP 0x0001
/** Iconview icon flags, reserved */ /** Iconview icon flags, reserved */
#define IVFLAG_ICON 0x0002 #define IVFLAG_ICON 0x0002
/** /**

View File

@@ -134,9 +134,9 @@ typedef struct _LVITEM
typedef LVITEM *PLVITEM; typedef LVITEM *PLVITEM;
/** Listview bitmap flags */ /** Listview bitmap flags */
#define LVFLAG_BITMAP 0x0001 #define LVFLAG_BITMAP 0x0001
/** Listview icon flags */ /** Listview icon flags */
#define LVFLAG_ICON 0x0002 #define LVFLAG_ICON 0x0002
/** /**
* Struct of the listview subitem info, contains information about a subitem. * Struct of the listview subitem info, contains information about a subitem.
@@ -206,9 +206,9 @@ typedef struct _LVCUSTOMDRAWFUNCS
/** Column flags */ /** Column flags */
/** Column text left align, default */ /** Column text left align, default */
#define LVCF_LEFTALIGN 0x0000 #define LVCF_LEFTALIGN 0x0000
/** Column text right align */ /** Column text right align */
#define LVCF_RIGHTALIGN 0x0001 #define LVCF_RIGHTALIGN 0x0001
/** Column text center align */ /** Column text center align */
#define LVCF_CENTERALIGN 0x0002 #define LVCF_CENTERALIGN 0x0002
/** Column treeview style */ /** Column treeview style */
@@ -216,11 +216,11 @@ typedef struct _LVCUSTOMDRAWFUNCS
/** Header flags */ /** Header flags */
/** Header text left align, default */ /** Header text left align, default */
#define LVHF_LEFTALIGN 0x0000 #define LVHF_LEFTALIGN 0x0000
/** Header text right align */ /** Header text right align */
#define LVHF_RIGHTALIGN 0x0004 #define LVHF_RIGHTALIGN 0x0004
/** Header text center align */ /** Header text center align */
#define LVHF_CENTERALIGN 0x0008 #define LVHF_CENTERALIGN 0x0008
/** /**
* Struct of the listview column info, contains information about a column. * Struct of the listview column info, contains information about a column.
@@ -688,7 +688,7 @@ typedef LVNM_ITEMRUP *PLVNM_ITEMRUP;
* *
* \return Always returns 0. * \return Always returns 0.
*/ */
#define LVM_SELECTITEM 0xF11F #define LVM_SELECTITEM 0xF11F
/** /**
@@ -709,7 +709,7 @@ typedef LVNM_ITEMRUP *PLVNM_ITEMRUP;
* *
* \return Always returns 0. * \return Always returns 0.
*/ */
#define LVM_SHOWITEM 0xF120 #define LVM_SHOWITEM 0xF120
/** /**
* \def LVM_GETSUBITEMLEN * \def LVM_GETSUBITEMLEN
@@ -733,7 +733,7 @@ typedef LVNM_ITEMRUP *PLVNM_ITEMRUP;
* *
* \return Returns the text length if successful, or LV_ERR otherwise. * \return Returns the text length if successful, or LV_ERR otherwise.
*/ */
#define LVM_GETSUBITEMLEN 0xF121 #define LVM_GETSUBITEMLEN 0xF121
/** /**
* \def LVM_SETCOLUMN * \def LVM_SETCOLUMN
@@ -751,7 +751,7 @@ typedef LVNM_ITEMRUP *PLVNM_ITEMRUP;
* *
* \return Returns LV_OKAY if successful, or LV_ERR otherwise. * \return Returns LV_OKAY if successful, or LV_ERR otherwise.
*/ */
#define LVM_SETCOLUMN 0xF122 #define LVM_SETCOLUMN 0xF122
/** /**
* \def LVM_SETSUBITEMTEXT * \def LVM_SETSUBITEMTEXT
@@ -775,7 +775,7 @@ typedef LVNM_ITEMRUP *PLVNM_ITEMRUP;
* *
* \return Returns LV_OKAY if successful, or LV_ERR otherwise. * \return Returns LV_OKAY if successful, or LV_ERR otherwise.
*/ */
#define LVM_SETSUBITEMTEXT 0xF123 #define LVM_SETSUBITEMTEXT 0xF123
/** /**
* \def LVM_SETSUBITEM * \def LVM_SETSUBITEM
@@ -799,7 +799,7 @@ typedef LVNM_ITEMRUP *PLVNM_ITEMRUP;
* *
* \return Returns LV_OKAY if successful, or LV_ERR otherwise. * \return Returns LV_OKAY if successful, or LV_ERR otherwise.
*/ */
#define LVM_SETSUBITEM 0xF124 #define LVM_SETSUBITEM 0xF124
/** /**
* \def LVM_GETCOLUMN * \def LVM_GETCOLUMN
@@ -820,7 +820,7 @@ typedef LVNM_ITEMRUP *PLVNM_ITEMRUP;
* *
* \return Returns TRUE if successful, or FALSE otherwise. * \return Returns TRUE if successful, or FALSE otherwise.
*/ */
#define LVM_GETCOLUMN 0xF125 #define LVM_GETCOLUMN 0xF125
/** /**
* \def LVM_GETCOLUMNWIDTH * \def LVM_GETCOLUMNWIDTH
@@ -838,7 +838,7 @@ typedef LVNM_ITEMRUP *PLVNM_ITEMRUP;
* *
* \return Returns the column width if successful, or -1 otherwise. * \return Returns the column width if successful, or -1 otherwise.
*/ */
#define LVM_GETCOLUMNWIDTH 0xF126 #define LVM_GETCOLUMNWIDTH 0xF126
/** /**
* \def LVM_GETITEM * \def LVM_GETITEM
@@ -860,7 +860,7 @@ typedef LVNM_ITEMRUP *PLVNM_ITEMRUP;
* *
* \return Returns LV_OKAY if successful, or LV_ERR otherwise. * \return Returns LV_OKAY if successful, or LV_ERR otherwise.
*/ */
#define LVM_GETITEM 0xF127 #define LVM_GETITEM 0xF127
/** /**
* \def LVM_GETITEMSTATE * \def LVM_GETITEMSTATE
@@ -881,7 +881,7 @@ typedef LVNM_ITEMRUP *PLVNM_ITEMRUP;
* *
* \return Returns the current state of the specified item. * \return Returns the current state of the specified item.
*/ */
#define LVM_GETITEMSTATE 0xF128 #define LVM_GETITEMSTATE 0xF128
/** /**
* \def LVM_GETSELECTEDCOLUMN * \def LVM_GETSELECTEDCOLUMN
@@ -896,7 +896,7 @@ typedef LVNM_ITEMRUP *PLVNM_ITEMRUP;
* *
* \return Returns the index of the selected column. * \return Returns the index of the selected column.
*/ */
#define LVM_GETSELECTEDCOLUMN 0xF129 #define LVM_GETSELECTEDCOLUMN 0xF129
/** /**
* \def LVM_GETSELECTEDCOUNT * \def LVM_GETSELECTEDCOUNT
@@ -911,7 +911,7 @@ typedef LVNM_ITEMRUP *PLVNM_ITEMRUP;
* *
* \return Returns the number of the selected items. * \return Returns the number of the selected items.
*/ */
#define LVM_GETSELECTEDCOUNT 0xF130 #define LVM_GETSELECTEDCOUNT 0xF130
/** /**
* \def LVM_GETTOPVISIBLE * \def LVM_GETTOPVISIBLE
@@ -926,19 +926,19 @@ typedef LVNM_ITEMRUP *PLVNM_ITEMRUP;
* *
* \return Returns the index of the topmost visible item if successful, or zero. * \return Returns the index of the topmost visible item if successful, or zero.
*/ */
#define LVM_GETTOPVISIBLE 0xF131 #define LVM_GETTOPVISIBLE 0xF131
/** /**
* \def LVM_NULL * \def LVM_NULL
* \brief reserved. * \brief reserved.
*/ */
#define LVM_NULL 0xF132 #define LVM_NULL 0xF132
/** /**
* \def LVM_SETITEMSTATE * \def LVM_SETITEMSTATE
* \brief reserved. * \brief reserved.
*/ */
#define LVM_SETITEMSTATE 0xF133 #define LVM_SETITEMSTATE 0xF133
/** /**
* \def LVM_SORTITEMS * \def LVM_SORTITEMS
@@ -974,7 +974,7 @@ typedef LVNM_ITEMRUP *PLVNM_ITEMRUP;
* *
* \return Returns TRUE if successful, or FALSE otherwise. * \return Returns TRUE if successful, or FALSE otherwise.
*/ */
#define LVM_SORTITEMS 0xF134 #define LVM_SORTITEMS 0xF134
/** /**
* \def LVM_SETITEMHEIGHT * \def LVM_SETITEMHEIGHT
@@ -994,7 +994,7 @@ typedef LVNM_ITEMRUP *PLVNM_ITEMRUP;
* *
* \return Returns TRUE if successful, or FALSE otherwise. * \return Returns TRUE if successful, or FALSE otherwise.
*/ */
#define LVM_SETITEMHEIGHT 0xF135 #define LVM_SETITEMHEIGHT 0xF135
/** /**
* \def LVM_SETHEADHEIGHT * \def LVM_SETHEADHEIGHT
@@ -1011,7 +1011,7 @@ typedef LVNM_ITEMRUP *PLVNM_ITEMRUP;
* \param height The new height of the header. * \param height The new height of the header.
* \return Returns TRUE if successful, or FALSE otherwise. * \return Returns TRUE if successful, or FALSE otherwise.
*/ */
#define LVM_SETHEADHEIGHT 0xF136 #define LVM_SETHEADHEIGHT 0xF136
/** /**
* \def LVM_GETITEMADDDATA * \def LVM_GETITEMADDDATA
@@ -1084,7 +1084,7 @@ typedef LVNM_ITEMRUP *PLVNM_ITEMRUP;
* *
* \return Always returns 0. * \return Always returns 0.
*/ */
#define LVM_CHOOSEITEM 0xF139 #define LVM_CHOOSEITEM 0xF139
/** /**
* \def LVM_SETSTRCMPFUNC * \def LVM_SETSTRCMPFUNC

View File

@@ -1114,7 +1114,7 @@ typedef SVITEMINFO* PSVITEMINFO;
#define SVN_SELCHANGED 2 #define SVN_SELCHANGED 2
/** Indicates the hilighted item changing */ /** Indicates the hilighted item changing */
#define SVN_SELCHANGING 4 #define SVN_SELCHANGING 4
/** @} end of ctrl_scrollview_ncs */ /** @} end of ctrl_scrollview_ncs */

View File

@@ -123,8 +123,8 @@ typedef struct pthread_attr_t
} pthread_attr_t; } pthread_attr_t;
/* Values for detachstate */ /* Values for detachstate */
#define PTHREAD_CREATE_JOINABLE 1 #define PTHREAD_CREATE_JOINABLE 1
#define PTHREAD_CREATE_DETACHED 2 #define PTHREAD_CREATE_DETACHED 2
/* Values for scope */ /* Values for scope */
#define PTHREAD_SCOPE_SYSTEM 1 #define PTHREAD_SCOPE_SYSTEM 1
@@ -234,7 +234,7 @@ int pthread_attr_getschedpolicy (const pthread_attr_t *attr,
/* Set scheduling parameters */ /* Set scheduling parameters */
int pthread_attr_setschedparam (pthread_attr_t *attr, int pthread_attr_setschedparam (pthread_attr_t *attr,
const struct sched_param *param); const struct sched_param *param);
/* Get scheduling parameters */ /* Get scheduling parameters */
int pthread_attr_getschedparam (const pthread_attr_t *attr, int pthread_attr_getschedparam (const pthread_attr_t *attr,
@@ -319,8 +319,8 @@ void *pthread_getspecific (pthread_key_t key);
struct pthread_cleanup_buffer struct pthread_cleanup_buffer
{ {
struct pthread_cleanup_buffer *prev; /* Chain cleanup buffers */ struct pthread_cleanup_buffer *prev; /* Chain cleanup buffers */
void (*routine) (void *); /* Function to call */ void (*routine) (void *); /* Function to call */
void *arg; /* Arg to pass */ void *arg; /* Arg to pass */
}; };
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
@@ -398,14 +398,14 @@ void pthread_cleanup_pop_inner (struct pthread_cleanup_buffer *buffer,
typedef struct _pthread_mutex_t typedef struct _pthread_mutex_t
{ {
NU_SEMAPHORE nu_mutex; NU_SEMAPHORE nu_mutex;
char name [NUPTH_LEN_NAME]; char name [NUPTH_LEN_NAME];
} pthread_mutex_t; } pthread_mutex_t;
/*define pthread_mutexattr_t */ /*define pthread_mutexattr_t */
typedef struct _pthread_mutexattr_t typedef struct _pthread_mutexattr_t
{ {
unsigned int protocol; unsigned int protocol;
} pthread_mutexattr_t; } pthread_mutexattr_t;
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------

View File

@@ -87,11 +87,11 @@ extern "C" {
typedef struct _sem_t typedef struct _sem_t
{ {
NU_SEMAPHORE nu_sem; NU_SEMAPHORE nu_sem;
char name [NUPTH_LEN_NAME]; char name [NUPTH_LEN_NAME];
} sem_t; } sem_t;
#define SEM_VALUE_MAX UINT_MAX #define SEM_VALUE_MAX UINT_MAX
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
** Semaphore functions ** Semaphore functions

View File

@@ -78,7 +78,7 @@
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
#define OSEPTH_LEN_NAME 256 #define OSEPTH_LEN_NAME 256
/** /**
* @\type SEMAPHORE * @\type SEMAPHORE
@@ -94,7 +94,7 @@ typedef struct _sem_t
char name [OSEPTH_LEN_NAME]; char name [OSEPTH_LEN_NAME];
} sem_t; } sem_t;
#define SEM_VALUE_MAX UINT_MAX #define SEM_VALUE_MAX UINT_MAX
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
** Semaphore functions ** Semaphore functions

File diff suppressed because it is too large Load Diff

View File

@@ -134,8 +134,8 @@ typedef struct pthread_attr_t
} pthread_attr_t; } pthread_attr_t;
/* Values for detachstate */ /* Values for detachstate */
#define PTHREAD_CREATE_JOINABLE 1 #define PTHREAD_CREATE_JOINABLE 1
#define PTHREAD_CREATE_DETACHED 2 #define PTHREAD_CREATE_DETACHED 2
#if 0 #if 0
/* Values for scope */ /* Values for scope */
@@ -257,7 +257,7 @@ int pthread_attr_getschedpolicy (const pthread_attr_t *attr,
/* Set scheduling parameters */ /* Set scheduling parameters */
int pthread_attr_setschedparam (pthread_attr_t *attr, int pthread_attr_setschedparam (pthread_attr_t *attr,
const struct sched_param *param); const struct sched_param *param);
/* Get scheduling parameters */ /* Get scheduling parameters */
int pthread_attr_getschedparam (const pthread_attr_t *attr, int pthread_attr_getschedparam (const pthread_attr_t *attr,
@@ -344,8 +344,8 @@ void *pthread_getspecific (pthread_key_t key);
struct pthread_cleanup_buffer struct pthread_cleanup_buffer
{ {
struct pthread_cleanup_buffer *prev; /* Chain cleanup buffers */ struct pthread_cleanup_buffer *prev; /* Chain cleanup buffers */
void (*routine) (void *); /* Function to call */ void (*routine) (void *); /* Function to call */
void *arg; /* Arg to pass */ void *arg; /* Arg to pass */
}; };
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
@@ -436,7 +436,7 @@ typedef unsigned long pthread_mutex_t;
/*define pthread_mutexattr_t */ /*define pthread_mutexattr_t */
typedef struct _pthread_mutexattr_t typedef struct _pthread_mutexattr_t
{ {
int type; int type;
int protocol; int protocol;
unsigned long prio_ceiling; unsigned long prio_ceiling;
} pthread_mutexattr_t; } pthread_mutexattr_t;

View File

@@ -80,7 +80,7 @@ extern "C" {
typedef unsigned long sem_t; typedef unsigned long sem_t;
#define SEM_VALUE_MAX UINT_MAX #define SEM_VALUE_MAX UINT_MAX
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
** Semaphore functions ** Semaphore functions

View File

@@ -127,8 +127,8 @@ typedef struct pthread_attr_t
} pthread_attr_t; } pthread_attr_t;
/* Values for detachstate */ /* Values for detachstate */
#define PTHREAD_CREATE_JOINABLE 1 #define PTHREAD_CREATE_JOINABLE 1
#define PTHREAD_CREATE_DETACHED 2 #define PTHREAD_CREATE_DETACHED 2
/* Values for scope */ /* Values for scope */
#define PTHREAD_SCOPE_SYSTEM 1 #define PTHREAD_SCOPE_SYSTEM 1
@@ -241,7 +241,7 @@ int pthread_attr_getschedpolicy (const pthread_attr_t *attr,
/* Set scheduling parameters */ /* Set scheduling parameters */
int pthread_attr_setschedparam (pthread_attr_t *attr, int pthread_attr_setschedparam (pthread_attr_t *attr,
const struct sched_param *param); const struct sched_param *param);
/* Get scheduling parameters */ /* Get scheduling parameters */
int pthread_attr_getschedparam (const pthread_attr_t *attr, int pthread_attr_getschedparam (const pthread_attr_t *attr,
@@ -328,8 +328,8 @@ void *pthread_getspecific (pthread_key_t key);
struct pthread_cleanup_buffer struct pthread_cleanup_buffer
{ {
struct pthread_cleanup_buffer *prev; /* Chain cleanup buffers */ struct pthread_cleanup_buffer *prev; /* Chain cleanup buffers */
void (*routine) (void *); /* Function to call */ void (*routine) (void *); /* Function to call */
void *arg; /* Arg to pass */ void *arg; /* Arg to pass */
}; };
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
@@ -422,14 +422,14 @@ typedef struct TXPTH_MUTEX_STRUCT
typedef struct _pthread_mutex_t typedef struct _pthread_mutex_t
{ {
TXPTH_MUTEX tx_mutex; TXPTH_MUTEX tx_mutex;
char name [TXPTH_LEN_NAME]; char name [TXPTH_LEN_NAME];
} pthread_mutex_t; } pthread_mutex_t;
/*define pthread_mutexattr_t */ /*define pthread_mutexattr_t */
typedef struct _pthread_mutexattr_t typedef struct _pthread_mutexattr_t
{ {
unsigned int protocol; unsigned int protocol;
} pthread_mutexattr_t; } pthread_mutexattr_t;
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------

View File

@@ -90,11 +90,11 @@ typedef struct TXPTH_SEMAPHORE_STRUCT
typedef struct _sem_t typedef struct _sem_t
{ {
TXPTH_SEMAPHORE tx_sem; TXPTH_SEMAPHORE tx_sem;
char name [TXPTH_LEN_NAME]; char name [TXPTH_LEN_NAME];
} sem_t; } sem_t;
#define SEM_VALUE_MAX UINT_MAX #define SEM_VALUE_MAX UINT_MAX
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
** Semaphore functions ** Semaphore functions

View File

@@ -137,8 +137,8 @@ typedef struct pthread_attr_t
} pthread_attr_t; } pthread_attr_t;
/* Values for detachstate */ /* Values for detachstate */
#define PTHREAD_CREATE_JOINABLE 1 #define PTHREAD_CREATE_JOINABLE 1
#define PTHREAD_CREATE_DETACHED 2 #define PTHREAD_CREATE_DETACHED 2
#if 0 #if 0
/* not support in uC/OS-II */ /* not support in uC/OS-II */
@@ -257,7 +257,7 @@ int pthread_attr_getschedpolicy (const pthread_attr_t *attr,
/* Set scheduling parameters */ /* Set scheduling parameters */
int pthread_attr_setschedparam (pthread_attr_t *attr, int pthread_attr_setschedparam (pthread_attr_t *attr,
const struct sched_param *param); const struct sched_param *param);
/* Get scheduling parameters */ /* Get scheduling parameters */
int pthread_attr_getschedparam (const pthread_attr_t *attr, int pthread_attr_getschedparam (const pthread_attr_t *attr,
@@ -329,8 +329,8 @@ void *pthread_getspecific (pthread_key_t key);
struct pthread_cleanup_buffer struct pthread_cleanup_buffer
{ {
struct pthread_cleanup_buffer *prev; /* Chain cleanup buffers */ struct pthread_cleanup_buffer *prev; /* Chain cleanup buffers */
void (*routine) (void *); /* Function to call */ void (*routine) (void *); /* Function to call */
void *arg; /* Arg to pass */ void *arg; /* Arg to pass */
}; };
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------

View File

@@ -69,7 +69,7 @@
#define sem_t ucos2_sem_t #define sem_t ucos2_sem_t
#define SEM_VALUE_MAX USHRT_MAX #define SEM_VALUE_MAX USHRT_MAX
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
** Semaphore object definition ** Semaphore object definition

View File

@@ -126,8 +126,8 @@ typedef struct pthread_attr_t
} pthread_attr_t; } pthread_attr_t;
/* Values for detachstate */ /* Values for detachstate */
#define PTHREAD_CREATE_JOINABLE 1 #define PTHREAD_CREATE_JOINABLE 1
#define PTHREAD_CREATE_DETACHED 2 #define PTHREAD_CREATE_DETACHED 2
/* Values for scope */ /* Values for scope */
#define PTHREAD_SCOPE_SYSTEM 1 #define PTHREAD_SCOPE_SYSTEM 1
@@ -237,7 +237,7 @@ int pthread_attr_getschedpolicy (const pthread_attr_t *attr,
/* Set scheduling parameters */ /* Set scheduling parameters */
int pthread_attr_setschedparam (pthread_attr_t *attr, int pthread_attr_setschedparam (pthread_attr_t *attr,
const struct sched_param *param); const struct sched_param *param);
/* Get scheduling parameters */ /* Get scheduling parameters */
int pthread_attr_getschedparam (const pthread_attr_t *attr, int pthread_attr_getschedparam (const pthread_attr_t *attr,
@@ -322,8 +322,8 @@ void *pthread_getspecific (pthread_key_t key);
struct pthread_cleanup_buffer struct pthread_cleanup_buffer
{ {
struct pthread_cleanup_buffer *prev; /* Chain cleanup buffers */ struct pthread_cleanup_buffer *prev; /* Chain cleanup buffers */
void (*routine) (void *); /* Function to call */ void (*routine) (void *); /* Function to call */
void *arg; /* Arg to pass */ void *arg; /* Arg to pass */
}; };
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
@@ -402,13 +402,13 @@ void pthread_cleanup_pop_inner (struct pthread_cleanup_buffer *buffer,
typedef struct _pthread_mutex_t typedef struct _pthread_mutex_t
{ {
SEM_ID vx_mutex; SEM_ID vx_mutex;
char name [VXPTH_LEN_NAME]; char name [VXPTH_LEN_NAME];
} pthread_mutex_t; } pthread_mutex_t;
/*define pthread_mutexattr_t */ /*define pthread_mutexattr_t */
typedef struct _pthread_mutexattr_t typedef struct _pthread_mutexattr_t
{ {
unsigned int protocol; unsigned int protocol;
} pthread_mutexattr_t; } pthread_mutexattr_t;
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------

View File

@@ -89,7 +89,7 @@ typedef struct _sem_t
unsigned int value; unsigned int value;
} sem_t; } sem_t;
#define SEM_VALUE_MAX UINT_MAX #define SEM_VALUE_MAX UINT_MAX
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
** Semaphore functions ** Semaphore functions

View File

@@ -14,10 +14,10 @@
* Module: semaphore.h * Module: semaphore.h
* *
* Purpose: * Purpose:
* Semaphores aren't actually part of the PThreads standard. * Semaphores aren't actually part of the PThreads standard.
* They are defined by the POSIX Standard: * They are defined by the POSIX Standard:
* *
* POSIX 1003.1b-1993 (POSIX.1b) * POSIX 1003.1b-1993 (POSIX.1b)
* *
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
* *
@@ -126,7 +126,7 @@
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#endif /* __cplusplus */ #endif /* __cplusplus */
#ifndef HAVE_MODE_T #ifndef HAVE_MODE_T
typedef unsigned int mode_t; typedef unsigned int mode_t;
@@ -136,8 +136,8 @@ typedef unsigned int mode_t;
typedef struct sem_t_ * sem_t; typedef struct sem_t_ * sem_t;
PTW32_DLLPORT int __cdecl sem_init (sem_t * sem, PTW32_DLLPORT int __cdecl sem_init (sem_t * sem,
int pshared, int pshared,
unsigned int value); unsigned int value);
PTW32_DLLPORT int __cdecl sem_destroy (sem_t * sem); PTW32_DLLPORT int __cdecl sem_destroy (sem_t * sem);
@@ -146,30 +146,30 @@ PTW32_DLLPORT int __cdecl sem_trywait (sem_t * sem);
PTW32_DLLPORT int __cdecl sem_wait (sem_t * sem); PTW32_DLLPORT int __cdecl sem_wait (sem_t * sem);
PTW32_DLLPORT int __cdecl sem_timedwait (sem_t * sem, PTW32_DLLPORT int __cdecl sem_timedwait (sem_t * sem,
const struct timespec * abstime); const struct timespec * abstime);
PTW32_DLLPORT int __cdecl sem_post (sem_t * sem); PTW32_DLLPORT int __cdecl sem_post (sem_t * sem);
PTW32_DLLPORT int __cdecl sem_post_multiple (sem_t * sem, PTW32_DLLPORT int __cdecl sem_post_multiple (sem_t * sem,
int count); int count);
PTW32_DLLPORT int __cdecl sem_open (const char * name, PTW32_DLLPORT int __cdecl sem_open (const char * name,
int oflag, int oflag,
mode_t mode, mode_t mode,
unsigned int value); unsigned int value);
PTW32_DLLPORT int __cdecl sem_close (sem_t * sem); PTW32_DLLPORT int __cdecl sem_close (sem_t * sem);
PTW32_DLLPORT int __cdecl sem_unlink (const char * name); PTW32_DLLPORT int __cdecl sem_unlink (const char * name);
PTW32_DLLPORT int __cdecl sem_getvalue (sem_t * sem, PTW32_DLLPORT int __cdecl sem_getvalue (sem_t * sem,
int * sval); int * sval);
#ifdef __cplusplus #ifdef __cplusplus
} /* End of extern "C" */ } /* End of extern "C" */
#endif /* __cplusplus */ #endif /* __cplusplus */
#undef PTW32_LEVEL #undef PTW32_LEVEL
#undef PTW32_LEVEL_MAX #undef PTW32_LEVEL_MAX
#endif /* !SEMAPHORE_H */ #endif /* !SEMAPHORE_H */

View File

@@ -74,12 +74,12 @@ extern "C" {
#define MAX_PHRASE_LENGTH 20 #define MAX_PHRASE_LENGTH 20
#define SELECT_KEY_LENGTH 16 #define SELECT_KEY_LENGTH 16
#define END_KEY_LENGTH 16 #define END_KEY_LENGTH 16
#define MAX_SEL_LENGTH 58 #define MAX_SEL_LENGTH 58
#define InputAreaX 16 #define InputAreaX 16
/* key of toggle input method */ /* key of toggle input method */
#define NR_INPUTMETHOD 10 #define NR_INPUTMETHOD 10
typedef struct { typedef struct {
unsigned long key1; /* sizeof(ITEM=12) */ unsigned long key1; /* sizeof(ITEM=12) */

View File

@@ -165,8 +165,8 @@ static void get_user_phrase_file (const char* tabpath, char* file_name)
strcat (file_name, "usrphrase.tab"); strcat (file_name, "usrphrase.tab");
} }
#elif defined(WIN32) #elif defined(WIN32)
strcpy (file_name, tabpath); strcpy (file_name, tabpath);
strcat (file_name, "usrphrase.tab"); strcat (file_name, "usrphrase.tab");
#endif #endif
} }

View File

@@ -43,8 +43,8 @@
* For more information about the commercial license, please refer to * For more information about the commercial license, please refer to
* <http://www.minigui.com/blog/minigui-licensing-policy/>. * <http://www.minigui.com/blog/minigui-licensing-policy/>.
*/ */
#ifndef _INPUT_MODULE_H_ #ifndef _INPUT_MODULE_H_
#define _INPUT_MODULE_H_ #define _INPUT_MODULE_H_
#define MAX_PY_NUM 410 #define MAX_PY_NUM 410
/* 1-405 */ /* 1-405 */
@@ -93,15 +93,15 @@ typedef struct _UsrPhrase
typedef struct _Phrase typedef struct _Phrase
{ {
u_char len; // phrase len u_char len; // phrase len
u_char count; // phrase number u_char count; // phrase number
u_char key[1]; // pinyin key [len+1] u_char key[1]; // pinyin key [len+1]
} __attribute__((packed)) Phrase; } __attribute__((packed)) Phrase;
typedef struct _SysPhrase typedef struct _SysPhrase
{ {
u_short count; u_short count;
Phrase phrase[1]; Phrase phrase[1];
} __attribute__((packed)) SysPhrase; } __attribute__((packed)) SysPhrase;
@@ -124,7 +124,7 @@ typedef struct _InputModule
int FuzzyPinyin; // zh-ch-sh z-c-s int FuzzyPinyin; // zh-ch-sh z-c-s
UsrPhrase *usrph[MAX_PY_NUM]; //user defined phrase UsrPhrase *usrph[MAX_PY_NUM]; //user defined phrase
char inbuf[MAX_INPUT_BUF]; /* input buffer for keystrokes */ char inbuf[MAX_INPUT_BUF]; /* input buffer for keystrokes */
// whole inputed pinyin string // whole inputed pinyin string
char inbuftmp[MAX_INPUT_BUF]; char inbuftmp[MAX_INPUT_BUF];
// un-selected pinyin string // un-selected pinyin string

View File

@@ -66,7 +66,7 @@ extern "C" {
#include "../gal/ep7211_internal.h" #include "../gal/ep7211_internal.h"
#endif #endif
#ifdef _ADS_GAL #ifdef _ADS_GAL
#include "../gal/ads_internal.h" #include "../gal/ads_internal.h"
#endif #endif
#ifdef _VGA16_GAL #ifdef _VGA16_GAL
typedef struct tagGC_VGA16* PGC_VGA16; typedef struct tagGC_VGA16* PGC_VGA16;
@@ -83,11 +83,11 @@ extern sigset_t __mg_savedset;
typedef struct tagGALClipInfo typedef struct tagGALClipInfo
{ {
int doclip; int doclip;
int clipminx; int clipminx;
int clipminy; int clipminy;
int clipmaxx; int clipmaxx;
int clipmaxy; int clipmaxy;
} GALCLIPINFO; } GALCLIPINFO;
#endif #endif
@@ -100,16 +100,16 @@ typedef union tagGAL_GC
ggi_visual_t visual; ggi_visual_t visual;
#endif #endif
#ifdef _EP7211_GAL #ifdef _EP7211_GAL
VIS_EP7211* vis_ep7211; VIS_EP7211* vis_ep7211;
#endif #endif
#ifdef _ADS_GAL #ifdef _ADS_GAL
ADS* ads; ADS* ads;
#endif #endif
#ifdef _NATIVE_GAL_ENGINE #ifdef _NATIVE_GAL_ENGINE
PSD psd; PSD psd;
#endif #endif
#ifdef _VGA16_GAL #ifdef _VGA16_GAL
PGC_VGA16 gc_vga16; PGC_VGA16 gc_vga16;
#endif #endif
#ifdef _LITE_VERSION #ifdef _LITE_VERSION
GALCLIPINFO* clip_info; // aliase to clipping info in PSD and GC_VGA16 GALCLIPINFO* clip_info; // aliase to clipping info in PSD and GC_VGA16

View File

@@ -98,8 +98,8 @@
* *
*/ */
#ifndef _MGUI_VCONGUI_H #ifndef _MGUI_VCONGUI_H
#define _MGUI_VCONGUI_H #define _MGUI_VCONGUI_H
#ifdef __cplusplus #ifdef __cplusplus
@@ -116,7 +116,7 @@ extern "C" {
#ifndef __cplusplus #ifndef __cplusplus
#ifndef __ECOS__ #ifndef __ECOS__
typedef enum {false, true} bool; typedef enum {false, true} bool;
#endif #endif
#endif #endif

View File

@@ -74,87 +74,87 @@ int __comminput_init (void)
static short keycode_convert_scancode (UINT8 keycode) static short keycode_convert_scancode (UINT8 keycode)
{ {
short scancode = 0; short scancode = 0;
switch (keycode) { switch (keycode) {
case KBD_KEY_SEND: case KBD_KEY_SEND:
scancode = SCANCODE_F2; scancode = SCANCODE_F2;
break; break;
case KBD_KEY_END: case KBD_KEY_END:
scancode = SCANCODE_F1; scancode = SCANCODE_F1;
break; break;
case KBD_KEY_REG: case KBD_KEY_REG:
scancode = SCANCODE_CURSORBLOCKUP; scancode = SCANCODE_CURSORBLOCKUP;
break; break;
case KBD_KEY_INFO_MODE: case KBD_KEY_INFO_MODE:
scancode = SCANCODE_CURSORBLOCKDOWN; scancode = SCANCODE_CURSORBLOCKDOWN;
break; break;
case KBD_KEY_CLEAR: case KBD_KEY_CLEAR:
scancode = SCANCODE_F3; scancode = SCANCODE_F3;
break; break;
case KBD_KEY_CAMP: case KBD_KEY_CAMP:
scancode = SCANCODE_ESCAPE; scancode = SCANCODE_ESCAPE;
break; break;
case KBD_KEY_BLANK1: case KBD_KEY_BLANK1:
scancode = SCANCODE_CURSORBLOCKLEFT; scancode = SCANCODE_CURSORBLOCKLEFT;
break; break;
case KBD_KEY_INFO_SELECT: case KBD_KEY_INFO_SELECT:
scancode = SCANCODE_CURSORBLOCKRIGHT; scancode = SCANCODE_CURSORBLOCKRIGHT;
break; break;
/* case KBD_KEY_POWER: /* case KBD_KEY_POWER:
scancode = SCANCODE_POWER; scancode = SCANCODE_POWER;
break; break;
*/ case KBD_KEY_BLANK2: */ case KBD_KEY_BLANK2:
scancode = SCANCODE_F6; scancode = SCANCODE_F6;
break; break;
case KBD_KEY_1: case KBD_KEY_1:
scancode = SCANCODE_1; scancode = SCANCODE_1;
break; break;
case KBD_KEY_2: case KBD_KEY_2:
scancode = SCANCODE_2; scancode = SCANCODE_2;
break; break;
case KBD_KEY_3: case KBD_KEY_3:
scancode = SCANCODE_3; scancode = SCANCODE_3;
break; break;
/* case KBD_KEY_STAR: /* case KBD_KEY_STAR:
scancode = SCANCODE_F7; scancode = SCANCODE_F7;
break; break;
*/case KBD_KEY_UP: */case KBD_KEY_UP:
scancode = SCANCODE_0; scancode = SCANCODE_0;
break; break;
case KBD_KEY_4: case KBD_KEY_4:
scancode = SCANCODE_4; scancode = SCANCODE_4;
break; break;
case KBD_KEY_5: case KBD_KEY_5:
scancode = SCANCODE_5; scancode = SCANCODE_5;
break; break;
case KBD_KEY_6: case KBD_KEY_6:
scancode = SCANCODE_6; scancode = SCANCODE_6;
break; break;
/* case KBD_KEY_0: /* case KBD_KEY_0:
scancode = SCANCODE_0; scancode = SCANCODE_0;
break; break;
*/ case KBD_KEY_DOWN: */ case KBD_KEY_DOWN:
scancode = SCANCODE_F7; scancode = SCANCODE_F7;
break; break;
case KBD_KEY_7: case KBD_KEY_7:
scancode = SCANCODE_7; scancode = SCANCODE_7;
break; break;
case KBD_KEY_8: case KBD_KEY_8:
scancode = SCANCODE_8; scancode = SCANCODE_8;
break; break;
case KBD_KEY_9: case KBD_KEY_9:
scancode = SCANCODE_9; scancode = SCANCODE_9;
break; break;
/* case KBD_KEY_HASH: /* case KBD_KEY_HASH:
scancode = SCANCODE_CURSORBLOCKRIGHT; scancode = SCANCODE_CURSORBLOCKRIGHT;
break; break;
*/ case KBD_NO_KEY: //no key press ,timeout */ case KBD_NO_KEY: //no key press ,timeout
scancode = 0; scancode = 0;
break; break;
} }
return scancode; return scancode;
} }
/* /*
@@ -164,17 +164,17 @@ static short keycode_convert_scancode (UINT8 keycode)
*/ */
int __comminput_kb_getdata (short *key, short *status) int __comminput_kb_getdata (short *key, short *status)
{ {
MAN_KP_INFO kbdinfo; MAN_KP_INFO kbdinfo;
if (tp_man_kp_get_data (&kbdinfo) == 0) if (tp_man_kp_get_data (&kbdinfo) == 0)
{ {
*key = keycode_convert_scancode (kbdinfo.scancode); *key = keycode_convert_scancode (kbdinfo.scancode);
*status = kbdinfo.status; *status = kbdinfo.status;
} }
if (*key != 0) if (*key != 0)
return 0; return 0;
return -1; return -1;
} }
/* /*
@@ -189,12 +189,12 @@ int __comminput_kb_getdata (short *key, short *status)
*/ */
int __comminput_wait_for_input (void) int __comminput_wait_for_input (void)
{ {
MAN_KP_INFO kbdinfo; MAN_KP_INFO kbdinfo;
if (tp_man_wait_input (30) == MAN_KPINPUT) if (tp_man_wait_input (30) == MAN_KPINPUT)
return COMM_KBINPUT; return COMM_KBINPUT;
return 0; return 0;
} }
/* /*
@@ -204,7 +204,7 @@ int __comminput_wait_for_input (void)
*/ */
int __comminput_ts_getdata (short *x, short *y, short *button) int __comminput_ts_getdata (short *x, short *y, short *button)
{ {
return 0; return 0;
} }
/* /*
@@ -324,12 +324,12 @@ int __commlcd_drv_getinfo (struct commlcd_info *li)
* Set LCD information in a commlcd_info structure pointed by li * Set LCD information in a commlcd_info structure pointed by li
* according to properties of your LCD. * according to properties of your LCD.
*/ */
li->width = 320; li->width = 320;
li->height = 240; li->height = 240;
li->bpp = 16; li->bpp = 16;
li->type = 0; li->type = 0;
li->rlen = 320*2; li->rlen = 320*2;
li->fb = a_fb; li->fb = a_fb;
return 0; return 0;
} }

View File

@@ -151,12 +151,12 @@ int __commlcd_drv_getinfo (struct commlcd_info *li)
* Set LCD information in a commlcd_info structure pointed by li * Set LCD information in a commlcd_info structure pointed by li
* according to properties of your LCD. * according to properties of your LCD.
*/ */
li->width = 320; li->width = 320;
li->height = 240; li->height = 240;
li->bpp = 16; li->bpp = 16;
li->type = 0; li->type = 0;
li->rlen = 320*2; li->rlen = 320*2;
li->fb = a_fb; li->fb = a_fb;
return 0; return 0;
} }

View File

@@ -69,87 +69,87 @@ int __comminput_init (void)
static short keycode_convert_scancode (UINT8 keycode) static short keycode_convert_scancode (UINT8 keycode)
{ {
short scancode = 0; short scancode = 0;
switch (keycode) { switch (keycode) {
case KBD_KEY_SEND: case KBD_KEY_SEND:
scancode = SCANCODE_F2; scancode = SCANCODE_F2;
break; break;
case KBD_KEY_END: case KBD_KEY_END:
scancode = SCANCODE_F1; scancode = SCANCODE_F1;
break; break;
case KBD_KEY_REG: case KBD_KEY_REG:
scancode = SCANCODE_CURSORBLOCKUP; scancode = SCANCODE_CURSORBLOCKUP;
break; break;
case KBD_KEY_INFO_MODE: case KBD_KEY_INFO_MODE:
scancode = SCANCODE_CURSORBLOCKDOWN; scancode = SCANCODE_CURSORBLOCKDOWN;
break; break;
case KBD_KEY_CLEAR: case KBD_KEY_CLEAR:
scancode = SCANCODE_F3; scancode = SCANCODE_F3;
break; break;
case KBD_KEY_CAMP: case KBD_KEY_CAMP:
scancode = SCANCODE_ESCAPE; scancode = SCANCODE_ESCAPE;
break; break;
case KBD_KEY_BLANK1: case KBD_KEY_BLANK1:
scancode = SCANCODE_CURSORBLOCKLEFT; scancode = SCANCODE_CURSORBLOCKLEFT;
break; break;
case KBD_KEY_INFO_SELECT: case KBD_KEY_INFO_SELECT:
scancode = SCANCODE_CURSORBLOCKRIGHT; scancode = SCANCODE_CURSORBLOCKRIGHT;
break; break;
/* case KBD_KEY_POWER: /* case KBD_KEY_POWER:
scancode = SCANCODE_POWER; scancode = SCANCODE_POWER;
break; break;
*/ case KBD_KEY_BLANK2: */ case KBD_KEY_BLANK2:
scancode = SCANCODE_F6; scancode = SCANCODE_F6;
break; break;
case KBD_KEY_1: case KBD_KEY_1:
scancode = SCANCODE_1; scancode = SCANCODE_1;
break; break;
case KBD_KEY_2: case KBD_KEY_2:
scancode = SCANCODE_2; scancode = SCANCODE_2;
break; break;
case KBD_KEY_3: case KBD_KEY_3:
scancode = SCANCODE_3; scancode = SCANCODE_3;
break; break;
/* case KBD_KEY_STAR: /* case KBD_KEY_STAR:
scancode = SCANCODE_F7; scancode = SCANCODE_F7;
break; break;
*/case KBD_KEY_UP: */case KBD_KEY_UP:
scancode = SCANCODE_0; scancode = SCANCODE_0;
break; break;
case KBD_KEY_4: case KBD_KEY_4:
scancode = SCANCODE_4; scancode = SCANCODE_4;
break; break;
case KBD_KEY_5: case KBD_KEY_5:
scancode = SCANCODE_5; scancode = SCANCODE_5;
break; break;
case KBD_KEY_6: case KBD_KEY_6:
scancode = SCANCODE_6; scancode = SCANCODE_6;
break; break;
/* case KBD_KEY_0: /* case KBD_KEY_0:
scancode = SCANCODE_0; scancode = SCANCODE_0;
break; break;
*/ case KBD_KEY_DOWN: */ case KBD_KEY_DOWN:
scancode = SCANCODE_F7; scancode = SCANCODE_F7;
break; break;
case KBD_KEY_7: case KBD_KEY_7:
scancode = SCANCODE_7; scancode = SCANCODE_7;
break; break;
case KBD_KEY_8: case KBD_KEY_8:
scancode = SCANCODE_8; scancode = SCANCODE_8;
break; break;
case KBD_KEY_9: case KBD_KEY_9:
scancode = SCANCODE_9; scancode = SCANCODE_9;
break; break;
/* case KBD_KEY_HASH: /* case KBD_KEY_HASH:
scancode = SCANCODE_CURSORBLOCKRIGHT; scancode = SCANCODE_CURSORBLOCKRIGHT;
break; break;
*/ case KBD_NO_KEY: //no key press ,timeout */ case KBD_NO_KEY: //no key press ,timeout
scancode = 0; scancode = 0;
break; break;
} }
return scancode; return scancode;
} }
/* /*
@@ -159,17 +159,17 @@ static short keycode_convert_scancode (UINT8 keycode)
*/ */
int __comminput_kb_getdata (short *key, short *status) int __comminput_kb_getdata (short *key, short *status)
{ {
MAN_KP_INFO kbdinfo; MAN_KP_INFO kbdinfo;
if (tp_man_kp_get_data (&kbdinfo) == 0) if (tp_man_kp_get_data (&kbdinfo) == 0)
{ {
*key = keycode_convert_scancode (kbdinfo.scancode); *key = keycode_convert_scancode (kbdinfo.scancode);
*status = kbdinfo.status; *status = kbdinfo.status;
} }
if (*key != 0) if (*key != 0)
return 0; return 0;
return -1; return -1;
} }
/* /*
@@ -184,12 +184,12 @@ int __comminput_kb_getdata (short *key, short *status)
*/ */
int __comminput_wait_for_input (void) int __comminput_wait_for_input (void)
{ {
MAN_KP_INFO kbdinfo; MAN_KP_INFO kbdinfo;
if (tp_man_wait_input (30) == MAN_KPINPUT) if (tp_man_wait_input (30) == MAN_KPINPUT)
return COMM_KBINPUT; return COMM_KBINPUT;
return 0; return 0;
} }
/* /*
@@ -199,7 +199,7 @@ int __comminput_wait_for_input (void)
*/ */
int __comminput_ts_getdata (short *x, short *y, short *button) int __comminput_ts_getdata (short *x, short *y, short *button)
{ {
return 0; return 0;
} }
/* /*
@@ -319,12 +319,12 @@ int __commlcd_drv_getinfo (struct commlcd_info *li)
* Set LCD information in a commlcd_info structure pointed by li * Set LCD information in a commlcd_info structure pointed by li
* according to properties of your LCD. * according to properties of your LCD.
*/ */
li->width = 320; li->width = 320;
li->height = 240; li->height = 240;
li->bpp = 16; li->bpp = 16;
li->type = 0; li->type = 0;
li->rlen = 320*2; li->rlen = 320*2;
li->fb = a_fb; li->fb = a_fb;
return 0; return 0;
} }

View File

@@ -148,12 +148,12 @@ int __commlcd_drv_getinfo (struct commlcd_info *li)
* Set LCD information in a commlcd_info structure pointed by li * Set LCD information in a commlcd_info structure pointed by li
* according to properties of your LCD. * according to properties of your LCD.
*/ */
li->width = 320; li->width = 320;
li->height = 240; li->height = 240;
li->bpp = 16; li->bpp = 16;
li->type = 0; li->type = 0;
li->rlen = 320*2; li->rlen = 320*2;
li->fb = a_fb; li->fb = a_fb;
return 0; return 0;
} }

View File

@@ -50,7 +50,7 @@ static int ascii_to_scancode(int asc2);
static short scancode_table[SCANCODE_USER]= static short scancode_table[SCANCODE_USER]=
{ {
0, //0 0, //0
0, 0,
0, 0,
0, 0,
@@ -58,12 +58,12 @@ static short scancode_table[SCANCODE_USER]=
0, 0,
0, 0,
0, 0,
SCANCODE_BACKSPACE, //8 SCANCODE_BACKSPACE, //8
SCANCODE_TAB, SCANCODE_TAB,
0, 0,
0, 0,
0, 0,
SCANCODE_ENTER, //13 SCANCODE_ENTER, //13
0, 0,
0, 0,
0, 0,
@@ -77,7 +77,7 @@ static short scancode_table[SCANCODE_USER]=
0, 0,
0, 0,
0, 0,
SCANCODE_ESCAPE, //27 SCANCODE_ESCAPE, //27
0, 0,
0, 0,
0, 0,
@@ -94,28 +94,28 @@ static short scancode_table[SCANCODE_USER]=
SCANCODE_0, /*sign ())*/ SCANCODE_0, /*sign ())*/
SCANCODE_8, /* sign(*) */ SCANCODE_8, /* sign(*) */
SCANCODE_EQUAL, /*sign (+)*/ SCANCODE_EQUAL, /*sign (+)*/
SCANCODE_COMMA, //44, SCANCODE_COMMA, //44,
SCANCODE_MINUS, //45 SCANCODE_MINUS, //45
SCANCODE_PERIOD, SCANCODE_PERIOD,
SCANCODE_SLASH, // / SCANCODE_SLASH, // /
SCANCODE_0, //48 SCANCODE_0, //48
SCANCODE_1, //49 SCANCODE_1, //49
SCANCODE_2, //50 SCANCODE_2, //50
SCANCODE_3, //51 SCANCODE_3, //51
SCANCODE_4, //52 SCANCODE_4, //52
SCANCODE_5, //53 SCANCODE_5, //53
SCANCODE_6, //54 SCANCODE_6, //54
SCANCODE_7, //55 SCANCODE_7, //55
SCANCODE_8, //56 SCANCODE_8, //56
SCANCODE_9, //57 SCANCODE_9, //57
SCANCODE_SEMICOLON, //58: SCANCODE_SEMICOLON, //58:
SCANCODE_SEMICOLON, //59; SCANCODE_SEMICOLON, //59;
0, 0,
SCANCODE_EQUAL, //61 SCANCODE_EQUAL, //61
0, 0,
0, 0,
SCANCODE_2, /* @ */ SCANCODE_2, /* @ */
SCANCODE_A, //65 SCANCODE_A, //65
SCANCODE_B, SCANCODE_B,
SCANCODE_C, SCANCODE_C,
SCANCODE_D, SCANCODE_D,
@@ -140,14 +140,14 @@ static short scancode_table[SCANCODE_USER]=
SCANCODE_W, SCANCODE_W,
SCANCODE_X, SCANCODE_X,
SCANCODE_Y, SCANCODE_Y,
SCANCODE_Z, //90 SCANCODE_Z, //90
SCANCODE_BRACKET_LEFT, /* [ */ SCANCODE_BRACKET_LEFT, /* [ */
SCANCODE_BACKSLASH, /* \ */ SCANCODE_BACKSLASH, /* \ */
SCANCODE_BRACKET_RIGHT, /* ] */ SCANCODE_BRACKET_RIGHT, /* ] */
SCANCODE_6, SCANCODE_6,
SCANCODE_MINUS, /* _ (95)*/ SCANCODE_MINUS, /* _ (95)*/
0, 0,
SCANCODE_A, //97 SCANCODE_A, //97
SCANCODE_B, SCANCODE_B,
SCANCODE_C, SCANCODE_C,
SCANCODE_D, SCANCODE_D,
@@ -172,7 +172,7 @@ static short scancode_table[SCANCODE_USER]=
SCANCODE_W, SCANCODE_W,
SCANCODE_X, SCANCODE_X,
SCANCODE_Y, SCANCODE_Y,
SCANCODE_Z , //122 SCANCODE_Z , //122
}; };
//0xE000 //0xE000
@@ -269,13 +269,13 @@ int __comminput_init (void)
int __comminput_ts_getdata (short *x, short *y, short *button) int __comminput_ts_getdata (short *x, short *y, short *button)
{ {
*x = msg.data.pointer.position.x; *x = msg.data.pointer.position.x;
*y = msg.data.pointer.position.y; *y = msg.data.pointer.position.y;
*x = *x<1024 ? *x : 1024; *x = *x<1024 ? *x : 1024;
*y = *y<768 ? *y : 768; *y = *y<768 ? *y : 768;
*button = (msg.data.pointer.buttonState) ; *button = (msg.data.pointer.buttonState) ;
return 0; return 0;
} }
@@ -283,9 +283,9 @@ int __comminput_kb_getdata (short *key, short *status)
{ {
*key = ascii_to_scancode (msg.data.keyboard.key); *key = ascii_to_scancode (msg.data.keyboard.key);
if (msg.data.keyboard.modifiers & UGL_KBD_KEYDOWN) if (msg.data.keyboard.modifiers & UGL_KBD_KEYDOWN)
*status = 1; *status = 1;
else else
*status = 0; *status = 0;
return 0; return 0;
} }
@@ -303,7 +303,7 @@ int __comminput_wait_for_input (void)
msg.type = 0; msg.type = 0;
return VX_KBINPUT; return VX_KBINPUT;
}else if (msg.type == MSG_POINTER) { }else if (msg.type == MSG_POINTER) {
msg.type = 0; msg.type = 0;
return VX_MOUSEINPUT; return VX_MOUSEINPUT;
} }
} }
@@ -312,7 +312,7 @@ int __comminput_wait_for_input (void)
void __comminput_deinit (void) void __comminput_deinit (void)
{ {
uglGcDestroy (gc); uglGcDestroy (gc);
uglDeinitialize(); uglDeinitialize();
} }
@@ -345,13 +345,13 @@ int __comminput_ts_getdata (short *x, short *y, short *button)
{ {
int tmp; int tmp;
*x = pInputEvent->x; *x = pInputEvent->x;
*y = pInputEvent->y; *y = pInputEvent->y;
*x<1024 ? *x : 1024 ; *x<1024 ? *x : 1024 ;
*y<768 ? *y : 768 ; *y<768 ? *y : 768 ;
*button = (pInputEvent->type.pointer.buttonState) ; *button = (pInputEvent->type.pointer.buttonState) ;
return 0; return 0;
} }
@@ -360,9 +360,9 @@ int __comminput_kb_getdata (short *key, short *status)
{ {
*key = ascii_to_scancode (pInputEvent->type.keyboard.key); *key = ascii_to_scancode (pInputEvent->type.keyboard.key);
if (pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN) if (pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN)
*status = 1; *status = 1;
else else
*status = 0; *status = 0;
return 0; return 0;
} }
@@ -631,12 +631,12 @@ int __commlcd_drv_getinfo (struct commlcd_info *li)
* Set LCD information in a commlcd_info structure pointed by li * Set LCD information in a commlcd_info structure pointed by li
* according to properties of your LCD. * according to properties of your LCD.
*/ */
li->width = 320; li->width = 320;
li->height = 240; li->height = 240;
li->bpp = 16; li->bpp = 16;
li->type = 0; li->type = 0;
li->rlen = 320*2; li->rlen = 320*2;
li->fb = a_fb; li->fb = a_fb;
return 0; return 0;
} }

View File

@@ -6,99 +6,99 @@
#include <sys/wait.h> #include <sys/wait.h>
/* /*
* A simple filter for the templates * A simple filter for the templates
*/ */
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
char buf[1024]; char buf[1024];
char *vec[8192]; char *vec[8192];
char *fvec[200]; char *fvec[200];
char **svec; char **svec;
char type[64]; char type[64];
int i; int i;
int vp=2; int vp=2;
int ret=0; int ret=0;
pid_t pid; pid_t pid;
if(chdir(getenv("TOPDIR"))) if(chdir(getenv("TOPDIR")))
{ {
perror("chdir"); perror("chdir");
exit(1); exit(1);
} }
/* /*
* Build the exec array ahead of time. * Build the exec array ahead of time.
*/ */
vec[0]="kernel-doc"; vec[0]="kernel-doc";
vec[1]="-docbook"; vec[1]="-docbook";
for(i=1;vp<8189;i++) for(i=1;vp<8189;i++)
{ {
if(argv[i]==NULL) if(argv[i]==NULL)
break; break;
vec[vp++]=type; vec[vp++]=type;
vec[vp++]=argv[i]; vec[vp++]=argv[i];
} }
vec[vp++]=buf+2; vec[vp++]=buf+2;
vec[vp++]=NULL; vec[vp++]=NULL;
/* /*
* Now process the template * Now process the template
*/ */
while(fgets(buf, 1024, stdin)) while(fgets(buf, 1024, stdin))
{ {
if(*buf!='!') { if(*buf!='!') {
printf("%s", buf); printf("%s", buf);
continue; continue;
} }
fflush(stdout); fflush(stdout);
svec = vec; svec = vec;
if(buf[1]=='E') if(buf[1]=='E')
strcpy(type, "-function"); strcpy(type, "-function");
else if(buf[1]=='I') else if(buf[1]=='I')
strcpy(type, "-nofunction"); strcpy(type, "-nofunction");
else if(buf[1]=='F') { else if(buf[1]=='F') {
int snarf = 0; int snarf = 0;
fvec[0] = "kernel-doc"; fvec[0] = "kernel-doc";
fvec[1] = "-docbook"; fvec[1] = "-docbook";
strcpy (type, "-function"); strcpy (type, "-function");
vp = 2; vp = 2;
for (i = 2; buf[i]; i++) { for (i = 2; buf[i]; i++) {
if (buf[i] == ' ' || buf[i] == '\n') { if (buf[i] == ' ' || buf[i] == '\n') {
buf[i] = '\0'; buf[i] = '\0';
snarf = 1; snarf = 1;
continue; continue;
} }
if (snarf) { if (snarf) {
snarf = 0; snarf = 0;
fvec[vp++] = type; fvec[vp++] = type;
fvec[vp++] = &buf[i]; fvec[vp++] = &buf[i];
} }
} }
fvec[vp++] = &buf[2]; fvec[vp++] = &buf[2];
fvec[vp] = NULL; fvec[vp] = NULL;
svec = fvec; svec = fvec;
} else } else
{ {
fprintf(stderr, "Unknown ! escape.\n"); fprintf(stderr, "Unknown ! escape.\n");
exit(1); exit(1);
} }
switch(pid=fork()) switch(pid=fork())
{ {
case -1: case -1:
perror("fork"); perror("fork");
exit(1); exit(1);
case 0: case 0:
execvp("scripts/kernel-doc", svec); execvp("scripts/kernel-doc", svec);
perror("exec scripts/kernel-doc"); perror("exec scripts/kernel-doc");
exit(1); exit(1);
default: default:
waitpid(pid, &ret ,0); waitpid(pid, &ret ,0);
} }
} }
exit(ret); exit(ret);
} }

View File

@@ -30,7 +30,7 @@ static int list_width, check_x, item_x, checkflag;
*/ */
static void static void
print_item (WINDOW * win, const char *item, int status, print_item (WINDOW * win, const char *item, int status,
int choice, int selected) int choice, int selected)
{ {
int i; int i;
@@ -38,22 +38,22 @@ print_item (WINDOW * win, const char *item, int status,
wattrset (win, menubox_attr); wattrset (win, menubox_attr);
wmove (win, choice, 0); wmove (win, choice, 0);
for (i = 0; i < list_width; i++) for (i = 0; i < list_width; i++)
waddch (win, ' '); waddch (win, ' ');
wmove (win, choice, check_x); wmove (win, choice, check_x);
wattrset (win, selected ? check_selected_attr : check_attr); wattrset (win, selected ? check_selected_attr : check_attr);
if (checkflag == FLAG_CHECK) if (checkflag == FLAG_CHECK)
wprintw (win, "[%c]", status ? 'X' : ' '); wprintw (win, "[%c]", status ? 'X' : ' ');
else else
wprintw (win, "(%c)", status ? 'X' : ' '); wprintw (win, "(%c)", status ? 'X' : ' ');
wattrset (win, selected ? tag_selected_attr : tag_attr); wattrset (win, selected ? tag_selected_attr : tag_attr);
mvwaddch(win, choice, item_x, item[0]); mvwaddch(win, choice, item_x, item[0]);
wattrset (win, selected ? item_selected_attr : item_attr); wattrset (win, selected ? item_selected_attr : item_attr);
waddstr (win, (char *)item+1); waddstr (win, (char *)item+1);
if (selected) { if (selected) {
wmove (win, choice, check_x+1); wmove (win, choice, check_x+1);
wrefresh (win); wrefresh (win);
} }
} }
@@ -62,37 +62,37 @@ print_item (WINDOW * win, const char *item, int status,
*/ */
static void static void
print_arrows (WINDOW * win, int choice, int item_no, int scroll, print_arrows (WINDOW * win, int choice, int item_no, int scroll,
int y, int x, int height) int y, int x, int height)
{ {
wmove(win, y, x); wmove(win, y, x);
if (scroll > 0) { if (scroll > 0) {
wattrset (win, uarrow_attr); wattrset (win, uarrow_attr);
waddch (win, ACS_UARROW); waddch (win, ACS_UARROW);
waddstr (win, "(-)"); waddstr (win, "(-)");
} }
else { else {
wattrset (win, menubox_attr); wattrset (win, menubox_attr);
waddch (win, ACS_HLINE); waddch (win, ACS_HLINE);
waddch (win, ACS_HLINE); waddch (win, ACS_HLINE);
waddch (win, ACS_HLINE); waddch (win, ACS_HLINE);
waddch (win, ACS_HLINE); waddch (win, ACS_HLINE);
} }
y = y + height + 1; y = y + height + 1;
wmove(win, y, x); wmove(win, y, x);
if ((height < item_no) && (scroll + choice < item_no - 1)) { if ((height < item_no) && (scroll + choice < item_no - 1)) {
wattrset (win, darrow_attr); wattrset (win, darrow_attr);
waddch (win, ACS_DARROW); waddch (win, ACS_DARROW);
waddstr (win, "(+)"); waddstr (win, "(+)");
} }
else { else {
wattrset (win, menubox_border_attr); wattrset (win, menubox_border_attr);
waddch (win, ACS_HLINE); waddch (win, ACS_HLINE);
waddch (win, ACS_HLINE); waddch (win, ACS_HLINE);
waddch (win, ACS_HLINE); waddch (win, ACS_HLINE);
waddch (win, ACS_HLINE); waddch (win, ACS_HLINE);
} }
} }
@@ -118,7 +118,7 @@ print_buttons( WINDOW *dialog, int height, int width, int selected)
*/ */
int int
dialog_checklist (const char *title, const char *prompt, int height, int width, dialog_checklist (const char *title, const char *prompt, int height, int width,
int list_height, int item_no, const char * const * items, int flag) int list_height, int item_no, const char * const * items, int flag)
{ {
int i, x, y, box_x, box_y; int i, x, y, box_x, box_y;
@@ -129,16 +129,16 @@ dialog_checklist (const char *title, const char *prompt, int height, int width,
/* Allocate space for storing item on/off status */ /* Allocate space for storing item on/off status */
if ((status = malloc (sizeof (int) * item_no)) == NULL) { if ((status = malloc (sizeof (int) * item_no)) == NULL) {
endwin (); endwin ();
fprintf (stderr, fprintf (stderr,
"\nCan't allocate memory in dialog_checklist().\n"); "\nCan't allocate memory in dialog_checklist().\n");
exit (-1); exit (-1);
} }
/* Initializes status */ /* Initializes status */
for (i = 0; i < item_no; i++) { for (i = 0; i < item_no; i++) {
status[i] = !strcasecmp (items[i * 3 + 2], "on"); status[i] = !strcasecmp (items[i * 3 + 2], "on");
if (!choice && status[i]) if (!choice && status[i])
choice = i; choice = i;
} }
@@ -157,23 +157,23 @@ dialog_checklist (const char *title, const char *prompt, int height, int width,
wattrset (dialog, border_attr); wattrset (dialog, border_attr);
mvwaddch (dialog, height-3, 0, ACS_LTEE); mvwaddch (dialog, height-3, 0, ACS_LTEE);
for (i = 0; i < width - 2; i++) for (i = 0; i < width - 2; i++)
waddch (dialog, ACS_HLINE); waddch (dialog, ACS_HLINE);
wattrset (dialog, dialog_attr); wattrset (dialog, dialog_attr);
waddch (dialog, ACS_RTEE); waddch (dialog, ACS_RTEE);
if (title != NULL && strlen(title) >= width-2 ) { if (title != NULL && strlen(title) >= width-2 ) {
/* truncate long title -- mec */ /* truncate long title -- mec */
char * title2 = malloc(width-2+1); char * title2 = malloc(width-2+1);
memcpy( title2, title, width-2 ); memcpy( title2, title, width-2 );
title2[width-2] = '\0'; title2[width-2] = '\0';
title = title2; title = title2;
} }
if (title != NULL) { if (title != NULL) {
wattrset (dialog, title_attr); wattrset (dialog, title_attr);
mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' ');
waddstr (dialog, (char *)title); waddstr (dialog, (char *)title);
waddch (dialog, ' '); waddch (dialog, ' ');
} }
wattrset (dialog, dialog_attr); wattrset (dialog, dialog_attr);
@@ -190,29 +190,29 @@ dialog_checklist (const char *title, const char *prompt, int height, int width,
/* draw a box around the list items */ /* draw a box around the list items */
draw_box (dialog, box_y, box_x, list_height + 2, list_width + 2, draw_box (dialog, box_y, box_x, list_height + 2, list_width + 2,
menubox_border_attr, menubox_attr); menubox_border_attr, menubox_attr);
/* Find length of longest item in order to center checklist */ /* Find length of longest item in order to center checklist */
check_x = 0; check_x = 0;
for (i = 0; i < item_no; i++) for (i = 0; i < item_no; i++)
check_x = MAX (check_x, + strlen (items[i * 3 + 1]) + 4); check_x = MAX (check_x, + strlen (items[i * 3 + 1]) + 4);
check_x = (list_width - check_x) / 2; check_x = (list_width - check_x) / 2;
item_x = check_x + 4; item_x = check_x + 4;
if (choice >= list_height) { if (choice >= list_height) {
scroll = choice - list_height + 1; scroll = choice - list_height + 1;
choice -= scroll; choice -= scroll;
} }
/* Print the list */ /* Print the list */
for (i = 0; i < max_choice; i++) { for (i = 0; i < max_choice; i++) {
print_item (list, items[(scroll+i) * 3 + 1], print_item (list, items[(scroll+i) * 3 + 1],
status[i+scroll], i, i == choice); status[i+scroll], i, i == choice);
} }
print_arrows(dialog, choice, item_no, scroll, print_arrows(dialog, choice, item_no, scroll,
box_y, box_x + check_x + 5, list_height); box_y, box_x + check_x + 5, list_height);
print_buttons(dialog, height, width, 0); print_buttons(dialog, height, width, 0);
@@ -221,149 +221,149 @@ dialog_checklist (const char *title, const char *prompt, int height, int width,
doupdate (); doupdate ();
while (key != ESC) { while (key != ESC) {
key = wgetch (dialog); key = wgetch (dialog);
for (i = 0; i < max_choice; i++) for (i = 0; i < max_choice; i++)
if (toupper(key) == toupper(items[(scroll+i)*3+1][0])) if (toupper(key) == toupper(items[(scroll+i)*3+1][0]))
break; break;
if ( i < max_choice || key == KEY_UP || key == KEY_DOWN || if ( i < max_choice || key == KEY_UP || key == KEY_DOWN ||
key == '+' || key == '-' ) { key == '+' || key == '-' ) {
if (key == KEY_UP || key == '-') { if (key == KEY_UP || key == '-') {
if (!choice) { if (!choice) {
if (!scroll) if (!scroll)
continue; continue;
/* Scroll list down */ /* Scroll list down */
if (list_height > 1) { if (list_height > 1) {
/* De-highlight current first item */ /* De-highlight current first item */
print_item (list, items[scroll * 3 + 1], print_item (list, items[scroll * 3 + 1],
status[scroll], 0, FALSE); status[scroll], 0, FALSE);
scrollok (list, TRUE); scrollok (list, TRUE);
wscrl (list, -1); wscrl (list, -1);
scrollok (list, FALSE); scrollok (list, FALSE);
}
scroll--;
print_item (list, items[scroll * 3 + 1],
status[scroll], 0, TRUE);
wnoutrefresh (list);
print_arrows(dialog, choice, item_no, scroll,
box_y, box_x + check_x + 5, list_height);
wrefresh (dialog);
continue; /* wait for another key press */
} else
i = choice - 1;
} else if (key == KEY_DOWN || key == '+') {
if (choice == max_choice - 1) {
if (scroll + choice >= item_no - 1)
continue;
/* Scroll list up */
if (list_height > 1) {
/* De-highlight current last item before scrolling up */
print_item (list, items[(scroll + max_choice - 1) * 3 + 1],
status[scroll + max_choice - 1],
max_choice - 1, FALSE);
scrollok (list, TRUE);
scroll (list);
scrollok (list, FALSE);
}
scroll++;
print_item (list, items[(scroll + max_choice - 1) * 3 + 1],
status[scroll + max_choice - 1],
max_choice - 1, TRUE);
wnoutrefresh (list);
print_arrows(dialog, choice, item_no, scroll,
box_y, box_x + check_x + 5, list_height);
wrefresh (dialog);
continue; /* wait for another key press */
} else
i = choice + 1;
}
if (i != choice) {
/* De-highlight current item */
print_item (list, items[(scroll + choice) * 3 + 1],
status[scroll + choice], choice, FALSE);
/* Highlight new item */
choice = i;
print_item (list, items[(scroll + choice) * 3 + 1],
status[scroll + choice], choice, TRUE);
wnoutrefresh (list);
wrefresh (dialog);
}
continue; /* wait for another key press */
}
switch (key) {
case 'H':
case 'h':
case '?':
delwin (dialog);
free (status);
return 1;
case TAB:
case KEY_LEFT:
case KEY_RIGHT:
button = ((key == KEY_LEFT ? --button : ++button) < 0)
? 1 : (button > 1 ? 0 : button);
print_buttons(dialog, height, width, button);
wrefresh (dialog);
break;
case 'S':
case 's':
case ' ':
case '\n':
if (!button) {
if (flag == FLAG_CHECK) {
status[scroll + choice] = !status[scroll + choice];
wmove (list, choice, check_x);
wattrset (list, check_selected_attr);
wprintw (list, "[%c]", status[scroll + choice] ? 'X' : ' ');
} else {
if (!status[scroll + choice]) {
for (i = 0; i < item_no; i++)
status[i] = 0;
status[scroll + choice] = 1;
for (i = 0; i < max_choice; i++)
print_item (list, items[(scroll + i) * 3 + 1],
status[scroll + i], i, i == choice);
}
}
wnoutrefresh (list);
wrefresh (dialog);
for (i = 0; i < item_no; i++) {
if (status[i]) {
if (flag == FLAG_CHECK) {
fprintf (stderr, "\"%s\" ", items[i * 3]);
} else {
fprintf (stderr, "%s", items[i * 3]);
}
}
}
} }
delwin (dialog); scroll--;
free (status); print_item (list, items[scroll * 3 + 1],
return button; status[scroll], 0, TRUE);
case 'X': wnoutrefresh (list);
case 'x':
key = ESC;
case ESC:
break;
}
/* Now, update everything... */ print_arrows(dialog, choice, item_no, scroll,
doupdate (); box_y, box_x + check_x + 5, list_height);
wrefresh (dialog);
continue; /* wait for another key press */
} else
i = choice - 1;
} else if (key == KEY_DOWN || key == '+') {
if (choice == max_choice - 1) {
if (scroll + choice >= item_no - 1)
continue;
/* Scroll list up */
if (list_height > 1) {
/* De-highlight current last item before scrolling up */
print_item (list, items[(scroll + max_choice - 1) * 3 + 1],
status[scroll + max_choice - 1],
max_choice - 1, FALSE);
scrollok (list, TRUE);
scroll (list);
scrollok (list, FALSE);
}
scroll++;
print_item (list, items[(scroll + max_choice - 1) * 3 + 1],
status[scroll + max_choice - 1],
max_choice - 1, TRUE);
wnoutrefresh (list);
print_arrows(dialog, choice, item_no, scroll,
box_y, box_x + check_x + 5, list_height);
wrefresh (dialog);
continue; /* wait for another key press */
} else
i = choice + 1;
}
if (i != choice) {
/* De-highlight current item */
print_item (list, items[(scroll + choice) * 3 + 1],
status[scroll + choice], choice, FALSE);
/* Highlight new item */
choice = i;
print_item (list, items[(scroll + choice) * 3 + 1],
status[scroll + choice], choice, TRUE);
wnoutrefresh (list);
wrefresh (dialog);
}
continue; /* wait for another key press */
}
switch (key) {
case 'H':
case 'h':
case '?':
delwin (dialog);
free (status);
return 1;
case TAB:
case KEY_LEFT:
case KEY_RIGHT:
button = ((key == KEY_LEFT ? --button : ++button) < 0)
? 1 : (button > 1 ? 0 : button);
print_buttons(dialog, height, width, button);
wrefresh (dialog);
break;
case 'S':
case 's':
case ' ':
case '\n':
if (!button) {
if (flag == FLAG_CHECK) {
status[scroll + choice] = !status[scroll + choice];
wmove (list, choice, check_x);
wattrset (list, check_selected_attr);
wprintw (list, "[%c]", status[scroll + choice] ? 'X' : ' ');
} else {
if (!status[scroll + choice]) {
for (i = 0; i < item_no; i++)
status[i] = 0;
status[scroll + choice] = 1;
for (i = 0; i < max_choice; i++)
print_item (list, items[(scroll + i) * 3 + 1],
status[scroll + i], i, i == choice);
}
}
wnoutrefresh (list);
wrefresh (dialog);
for (i = 0; i < item_no; i++) {
if (status[i]) {
if (flag == FLAG_CHECK) {
fprintf (stderr, "\"%s\" ", items[i * 3]);
} else {
fprintf (stderr, "%s", items[i * 3]);
}
}
}
}
delwin (dialog);
free (status);
return button;
case 'X':
case 'x':
key = ESC;
case ESC:
break;
}
/* Now, update everything... */
doupdate ();
} }
delwin (dialog); delwin (dialog);
free (status); free (status);
return -1; /* ESC pressed */ return -1; /* ESC pressed */
} }

View File

@@ -158,23 +158,23 @@ void color_setup (void);
void print_autowrap (WINDOW * win, const char *prompt, int width, int y, int x); void print_autowrap (WINDOW * win, const char *prompt, int width, int y, int x);
void print_button (WINDOW * win, const char *label, int y, int x, int selected); void print_button (WINDOW * win, const char *label, int y, int x, int selected);
void draw_box (WINDOW * win, int y, int x, int height, int width, chtype box, void draw_box (WINDOW * win, int y, int x, int height, int width, chtype box,
chtype border); chtype border);
void draw_shadow (WINDOW * win, int y, int x, int height, int width); void draw_shadow (WINDOW * win, int y, int x, int height, int width);
int first_alpha (const char *string, const char *exempt); int first_alpha (const char *string, const char *exempt);
int dialog_yesno (const char *title, const char *prompt, int height, int width); int dialog_yesno (const char *title, const char *prompt, int height, int width);
int dialog_msgbox (const char *title, const char *prompt, int height, int dialog_msgbox (const char *title, const char *prompt, int height,
int width, int pause); int width, int pause);
int dialog_textbox (const char *title, const char *file, int height, int width); int dialog_textbox (const char *title, const char *file, int height, int width);
int dialog_menu (const char *title, const char *prompt, int height, int width, int dialog_menu (const char *title, const char *prompt, int height, int width,
int menu_height, const char *choice, int item_no, int menu_height, const char *choice, int item_no,
const char * const * items); const char * const * items);
int dialog_checklist (const char *title, const char *prompt, int height, int dialog_checklist (const char *title, const char *prompt, int height,
int width, int list_height, int item_no, int width, int list_height, int item_no,
const char * const * items, int flag); const char * const * items, int flag);
extern unsigned char dialog_input_result[]; extern unsigned char dialog_input_result[];
int dialog_inputbox (const char *title, const char *prompt, int height, int dialog_inputbox (const char *title, const char *prompt, int height,
int width, const char *init); int width, const char *init);
/* /*
* This is the base for fictitious keys, which activate * This is the base for fictitious keys, which activate

View File

@@ -44,7 +44,7 @@ print_buttons(WINDOW *dialog, int height, int width, int selected)
*/ */
int int
dialog_inputbox (const char *title, const char *prompt, int height, int width, dialog_inputbox (const char *title, const char *prompt, int height, int width,
const char *init) const char *init)
{ {
int i, x, y, box_y, box_x, box_width; int i, x, y, box_y, box_x, box_width;
int input_x = 0, scroll = 0, key = 0, button = -1; int input_x = 0, scroll = 0, key = 0, button = -1;
@@ -65,23 +65,23 @@ dialog_inputbox (const char *title, const char *prompt, int height, int width,
wattrset (dialog, border_attr); wattrset (dialog, border_attr);
mvwaddch (dialog, height-3, 0, ACS_LTEE); mvwaddch (dialog, height-3, 0, ACS_LTEE);
for (i = 0; i < width - 2; i++) for (i = 0; i < width - 2; i++)
waddch (dialog, ACS_HLINE); waddch (dialog, ACS_HLINE);
wattrset (dialog, dialog_attr); wattrset (dialog, dialog_attr);
waddch (dialog, ACS_RTEE); waddch (dialog, ACS_RTEE);
if (title != NULL && strlen(title) >= width-2 ) { if (title != NULL && strlen(title) >= width-2 ) {
/* truncate long title -- mec */ /* truncate long title -- mec */
char * title2 = malloc(width-2+1); char * title2 = malloc(width-2+1);
memcpy( title2, title, width-2 ); memcpy( title2, title, width-2 );
title2[width-2] = '\0'; title2[width-2] = '\0';
title = title2; title = title2;
} }
if (title != NULL) { if (title != NULL) {
wattrset (dialog, title_attr); wattrset (dialog, title_attr);
mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' ');
waddstr (dialog, (char *)title); waddstr (dialog, (char *)title);
waddch (dialog, ' '); waddch (dialog, ' ');
} }
wattrset (dialog, dialog_attr); wattrset (dialog, dialog_attr);
@@ -93,7 +93,7 @@ dialog_inputbox (const char *title, const char *prompt, int height, int width,
box_y = y + 2; box_y = y + 2;
box_x = (width - box_width) / 2; box_x = (width - box_width) / 2;
draw_box (dialog, y + 1, box_x - 1, 3, box_width + 2, draw_box (dialog, y + 1, box_x - 1, 3, box_width + 2,
border_attr, dialog_attr); border_attr, dialog_attr);
print_buttons(dialog, height, width, 0); print_buttons(dialog, height, width, 0);
@@ -102,139 +102,139 @@ dialog_inputbox (const char *title, const char *prompt, int height, int width,
wattrset (dialog, inputbox_attr); wattrset (dialog, inputbox_attr);
if (!init) if (!init)
instr[0] = '\0'; instr[0] = '\0';
else else
strcpy (instr, init); strcpy (instr, init);
input_x = strlen (instr); input_x = strlen (instr);
if (input_x >= box_width) { if (input_x >= box_width) {
scroll = input_x - box_width + 1; scroll = input_x - box_width + 1;
input_x = box_width - 1; input_x = box_width - 1;
for (i = 0; i < box_width - 1; i++) for (i = 0; i < box_width - 1; i++)
waddch (dialog, instr[scroll + i]); waddch (dialog, instr[scroll + i]);
} else } else
waddstr (dialog, instr); waddstr (dialog, instr);
wmove (dialog, box_y, box_x + input_x); wmove (dialog, box_y, box_x + input_x);
wrefresh (dialog); wrefresh (dialog);
while (key != ESC) { while (key != ESC) {
key = wgetch (dialog); key = wgetch (dialog);
if (button == -1) { /* Input box selected */ if (button == -1) { /* Input box selected */
switch (key) { switch (key) {
case TAB: case TAB:
case KEY_UP: case KEY_UP:
case KEY_DOWN: case KEY_DOWN:
break; break;
case KEY_LEFT: case KEY_LEFT:
continue; continue;
case KEY_RIGHT: case KEY_RIGHT:
continue; continue;
case KEY_BACKSPACE: case KEY_BACKSPACE:
case 127: case 127:
if (input_x || scroll) { if (input_x || scroll) {
wattrset (dialog, inputbox_attr); wattrset (dialog, inputbox_attr);
if (!input_x) { if (!input_x) {
scroll = scroll < box_width - 1 ? scroll = scroll < box_width - 1 ?
0 : scroll - (box_width - 1); 0 : scroll - (box_width - 1);
wmove (dialog, box_y, box_x); wmove (dialog, box_y, box_x);
for (i = 0; i < box_width; i++) for (i = 0; i < box_width; i++)
waddch (dialog, instr[scroll + input_x + i] ? waddch (dialog, instr[scroll + input_x + i] ?
instr[scroll + input_x + i] : ' '); instr[scroll + input_x + i] : ' ');
input_x = strlen (instr) - scroll; input_x = strlen (instr) - scroll;
} else } else
input_x--; input_x--;
instr[scroll + input_x] = '\0'; instr[scroll + input_x] = '\0';
mvwaddch (dialog, box_y, input_x + box_x, ' '); mvwaddch (dialog, box_y, input_x + box_x, ' ');
wmove (dialog, box_y, input_x + box_x); wmove (dialog, box_y, input_x + box_x);
wrefresh (dialog); wrefresh (dialog);
} }
continue; continue;
default: default:
if (key < 0x100 && isprint (key)) { if (key < 0x100 && isprint (key)) {
if (scroll + input_x < MAX_LEN) { if (scroll + input_x < MAX_LEN) {
wattrset (dialog, inputbox_attr); wattrset (dialog, inputbox_attr);
instr[scroll + input_x] = key; instr[scroll + input_x] = key;
instr[scroll + input_x + 1] = '\0'; instr[scroll + input_x + 1] = '\0';
if (input_x == box_width - 1) { if (input_x == box_width - 1) {
scroll++; scroll++;
wmove (dialog, box_y, box_x); wmove (dialog, box_y, box_x);
for (i = 0; i < box_width - 1; i++) for (i = 0; i < box_width - 1; i++)
waddch (dialog, instr[scroll + i]); waddch (dialog, instr[scroll + i]);
} else { } else {
wmove (dialog, box_y, input_x++ + box_x); wmove (dialog, box_y, input_x++ + box_x);
waddch (dialog, key); waddch (dialog, key);
} }
wrefresh (dialog); wrefresh (dialog);
} else } else
flash (); /* Alarm user about overflow */ flash (); /* Alarm user about overflow */
continue; continue;
} }
} }
} }
switch (key) { switch (key) {
case 'O': case 'O':
case 'o': case 'o':
delwin (dialog); delwin (dialog);
return 0; return 0;
case 'H': case 'H':
case 'h': case 'h':
delwin (dialog); delwin (dialog);
return 1; return 1;
case KEY_UP: case KEY_UP:
case KEY_LEFT: case KEY_LEFT:
switch (button) { switch (button) {
case -1: case -1:
button = 1; /* Indicates "Cancel" button is selected */ button = 1; /* Indicates "Cancel" button is selected */
print_buttons(dialog, height, width, 1); print_buttons(dialog, height, width, 1);
break; break;
case 0: case 0:
button = -1; /* Indicates input box is selected */ button = -1; /* Indicates input box is selected */
print_buttons(dialog, height, width, 0); print_buttons(dialog, height, width, 0);
wmove (dialog, box_y, box_x + input_x); wmove (dialog, box_y, box_x + input_x);
wrefresh (dialog); wrefresh (dialog);
break; break;
case 1: case 1:
button = 0; /* Indicates "OK" button is selected */ button = 0; /* Indicates "OK" button is selected */
print_buttons(dialog, height, width, 0); print_buttons(dialog, height, width, 0);
break; break;
} }
break; break;
case TAB: case TAB:
case KEY_DOWN: case KEY_DOWN:
case KEY_RIGHT: case KEY_RIGHT:
switch (button) { switch (button) {
case -1: case -1:
button = 0; /* Indicates "OK" button is selected */ button = 0; /* Indicates "OK" button is selected */
print_buttons(dialog, height, width, 0); print_buttons(dialog, height, width, 0);
break; break;
case 0: case 0:
button = 1; /* Indicates "Cancel" button is selected */ button = 1; /* Indicates "Cancel" button is selected */
print_buttons(dialog, height, width, 1); print_buttons(dialog, height, width, 1);
break; break;
case 1: case 1:
button = -1; /* Indicates input box is selected */ button = -1; /* Indicates input box is selected */
print_buttons(dialog, height, width, 0); print_buttons(dialog, height, width, 0);
wmove (dialog, box_y, box_x + input_x); wmove (dialog, box_y, box_x + input_x);
wrefresh (dialog); wrefresh (dialog);
break; break;
} }
break; break;
case ' ': case ' ':
case '\n': case '\n':
delwin (dialog); delwin (dialog);
return (button == -1 ? 0 : button); return (button == -1 ? 0 : button);
case 'X': case 'X':
case 'x': case 'x':
key = ESC; key = ESC;
case ESC: case ESC:
break; break;
} }
} }
delwin (dialog); delwin (dialog);
return -1; /* ESC pressed */ return -1; /* ESC pressed */
} }

View File

@@ -67,19 +67,19 @@ main (int argc, const char * const * argv)
trace(TRACE_CALLS|TRACE_UPDATE); trace(TRACE_CALLS|TRACE_UPDATE);
#endif #endif
if (argc < 2) { if (argc < 2) {
Usage (argv[0]); Usage (argv[0]);
exit (-1); exit (-1);
} }
while (offset < argc - 1 && !end_common_opts) { /* Common options */ while (offset < argc - 1 && !end_common_opts) { /* Common options */
if (!strcmp (argv[offset + 1], "--title")) { if (!strcmp (argv[offset + 1], "--title")) {
if (argc - offset < 3 || title != NULL) { if (argc - offset < 3 || title != NULL) {
Usage (argv[0]); Usage (argv[0]);
exit (-1); exit (-1);
} else { } else {
title = argv[offset + 2]; title = argv[offset + 2];
offset += 2; offset += 2;
} }
} else if (!strcmp (argv[offset + 1], "--backtitle")) { } else if (!strcmp (argv[offset + 1], "--backtitle")) {
if (backtitle != NULL) { if (backtitle != NULL) {
Usage (argv[0]); Usage (argv[0]);
@@ -88,48 +88,48 @@ main (int argc, const char * const * argv)
backtitle = argv[offset + 2]; backtitle = argv[offset + 2];
offset += 2; offset += 2;
} }
} else if (!strcmp (argv[offset + 1], "--clear")) { } else if (!strcmp (argv[offset + 1], "--clear")) {
if (clear_screen) { /* Hey, "--clear" can't appear twice! */ if (clear_screen) { /* Hey, "--clear" can't appear twice! */
Usage (argv[0]); Usage (argv[0]);
exit (-1); exit (-1);
} else if (argc == 2) { /* we only want to clear the screen */ } else if (argc == 2) { /* we only want to clear the screen */
init_dialog (); init_dialog ();
refresh (); /* init_dialog() will clear the screen for us */ refresh (); /* init_dialog() will clear the screen for us */
end_dialog (); end_dialog ();
return 0; return 0;
} else { } else {
clear_screen = 1; clear_screen = 1;
offset++; offset++;
} }
} else /* no more common options */ } else /* no more common options */
end_common_opts = 1; end_common_opts = 1;
} }
if (argc - 1 == offset) { /* no more options */ if (argc - 1 == offset) { /* no more options */
Usage (argv[0]); Usage (argv[0]);
exit (-1); exit (-1);
} }
/* use a table to look for the requested mode, to avoid code duplication */ /* use a table to look for the requested mode, to avoid code duplication */
for (modePtr = modes; modePtr->name; modePtr++) /* look for the mode */ for (modePtr = modes; modePtr->name; modePtr++) /* look for the mode */
if (!strcmp (argv[offset + 1], modePtr->name)) if (!strcmp (argv[offset + 1], modePtr->name))
break; break;
if (!modePtr->name) if (!modePtr->name)
Usage (argv[0]); Usage (argv[0]);
if (argc - offset < modePtr->argmin) if (argc - offset < modePtr->argmin)
Usage (argv[0]); Usage (argv[0]);
if (modePtr->argmax && argc - offset > modePtr->argmax) if (modePtr->argmax && argc - offset > modePtr->argmax)
Usage (argv[0]); Usage (argv[0]);
init_dialog (); init_dialog ();
retval = (*(modePtr->jumper)) (title, argc - offset, argv + offset); retval = (*(modePtr->jumper)) (title, argc - offset, argv + offset);
if (clear_screen) { /* clear screen before exit */ if (clear_screen) { /* clear screen before exit */
attr_clear (stdscr, LINES, COLS, screen_attr); attr_clear (stdscr, LINES, COLS, screen_attr);
refresh (); refresh ();
} }
end_dialog(); end_dialog();
@@ -173,21 +173,21 @@ int
j_menu (const char *t, int ac, const char * const * av) j_menu (const char *t, int ac, const char * const * av)
{ {
return dialog_menu (t, av[2], atoi (av[3]), atoi (av[4]), return dialog_menu (t, av[2], atoi (av[3]), atoi (av[4]),
atoi (av[5]), av[6], (ac - 6) / 2, av + 7); atoi (av[5]), av[6], (ac - 6) / 2, av + 7);
} }
int int
j_checklist (const char *t, int ac, const char * const * av) j_checklist (const char *t, int ac, const char * const * av)
{ {
return dialog_checklist (t, av[2], atoi (av[3]), atoi (av[4]), return dialog_checklist (t, av[2], atoi (av[3]), atoi (av[4]),
atoi (av[5]), (ac - 6) / 3, av + 6, FLAG_CHECK); atoi (av[5]), (ac - 6) / 3, av + 6, FLAG_CHECK);
} }
int int
j_radiolist (const char *t, int ac, const char * const * av) j_radiolist (const char *t, int ac, const char * const * av)
{ {
return dialog_checklist (t, av[2], atoi (av[3]), atoi (av[4]), return dialog_checklist (t, av[2], atoi (av[3]), atoi (av[4]),
atoi (av[5]), (ac - 6) / 3, av + 6, FLAG_RADIO); atoi (av[5]), (ac - 6) / 3, av + 6, FLAG_RADIO);
} }
int int

View File

@@ -80,7 +80,7 @@ print_item (WINDOW * win, const char *item, int choice, int selected, int hotkey
{ {
int i; int i;
for (i = 0; i < menu_width; i++) for (i = 0; i < menu_width; i++)
waddch (win, ' '); waddch (win, ' ');
} }
#else #else
wclrtoeol(win); wclrtoeol(win);
@@ -88,12 +88,12 @@ print_item (WINDOW * win, const char *item, int choice, int selected, int hotkey
wattrset (win, selected ? item_selected_attr : item_attr); wattrset (win, selected ? item_selected_attr : item_attr);
mvwaddstr (win, choice, item_x, menu_item); mvwaddstr (win, choice, item_x, menu_item);
if (hotkey) { if (hotkey) {
wattrset (win, selected ? tag_key_selected_attr : tag_key_attr); wattrset (win, selected ? tag_key_selected_attr : tag_key_attr);
mvwaddch(win, choice, item_x+j, menu_item[j]); mvwaddch(win, choice, item_x+j, menu_item[j]);
} }
if (selected) { if (selected) {
wmove (win, choice, item_x+1); wmove (win, choice, item_x+1);
wrefresh (win); wrefresh (win);
} }
} }
@@ -102,7 +102,7 @@ print_item (WINDOW * win, const char *item, int choice, int selected, int hotkey
*/ */
static void static void
print_arrows (WINDOW * win, int item_no, int scroll, print_arrows (WINDOW * win, int item_no, int scroll,
int y, int x, int height) int y, int x, int height)
{ {
int cur_y, cur_x; int cur_y, cur_x;
@@ -111,32 +111,32 @@ print_arrows (WINDOW * win, int item_no, int scroll,
wmove(win, y, x); wmove(win, y, x);
if (scroll > 0) { if (scroll > 0) {
wattrset (win, uarrow_attr); wattrset (win, uarrow_attr);
waddch (win, ACS_UARROW); waddch (win, ACS_UARROW);
waddstr (win, "(-)"); waddstr (win, "(-)");
} }
else { else {
wattrset (win, menubox_attr); wattrset (win, menubox_attr);
waddch (win, ACS_HLINE); waddch (win, ACS_HLINE);
waddch (win, ACS_HLINE); waddch (win, ACS_HLINE);
waddch (win, ACS_HLINE); waddch (win, ACS_HLINE);
waddch (win, ACS_HLINE); waddch (win, ACS_HLINE);
} }
y = y + height + 1; y = y + height + 1;
wmove(win, y, x); wmove(win, y, x);
if ((height < item_no) && (scroll + height < item_no)) { if ((height < item_no) && (scroll + height < item_no)) {
wattrset (win, darrow_attr); wattrset (win, darrow_attr);
waddch (win, ACS_DARROW); waddch (win, ACS_DARROW);
waddstr (win, "(+)"); waddstr (win, "(+)");
} }
else { else {
wattrset (win, menubox_border_attr); wattrset (win, menubox_border_attr);
waddch (win, ACS_HLINE); waddch (win, ACS_HLINE);
waddch (win, ACS_HLINE); waddch (win, ACS_HLINE);
waddch (win, ACS_HLINE); waddch (win, ACS_HLINE);
waddch (win, ACS_HLINE); waddch (win, ACS_HLINE);
} }
wmove(win, cur_y, cur_x); wmove(win, cur_y, cur_x);
@@ -164,8 +164,8 @@ print_buttons (WINDOW *win, int height, int width, int selected)
*/ */
int int
dialog_menu (const char *title, const char *prompt, int height, int width, dialog_menu (const char *title, const char *prompt, int height, int width,
int menu_height, const char *current, int item_no, int menu_height, const char *current, int item_no,
const char * const * items) const char * const * items)
{ {
int i, j, x, y, box_x, box_y; int i, j, x, y, box_x, box_y;
@@ -188,24 +188,24 @@ dialog_menu (const char *title, const char *prompt, int height, int width,
wattrset (dialog, border_attr); wattrset (dialog, border_attr);
mvwaddch (dialog, height - 3, 0, ACS_LTEE); mvwaddch (dialog, height - 3, 0, ACS_LTEE);
for (i = 0; i < width - 2; i++) for (i = 0; i < width - 2; i++)
waddch (dialog, ACS_HLINE); waddch (dialog, ACS_HLINE);
wattrset (dialog, dialog_attr); wattrset (dialog, dialog_attr);
wbkgdset (dialog, dialog_attr & A_COLOR); wbkgdset (dialog, dialog_attr & A_COLOR);
waddch (dialog, ACS_RTEE); waddch (dialog, ACS_RTEE);
if (title != NULL && strlen(title) >= width-2 ) { if (title != NULL && strlen(title) >= width-2 ) {
/* truncate long title -- mec */ /* truncate long title -- mec */
char * title2 = malloc(width-2+1); char * title2 = malloc(width-2+1);
memcpy( title2, title, width-2 ); memcpy( title2, title, width-2 );
title2[width-2] = '\0'; title2[width-2] = '\0';
title = title2; title = title2;
} }
if (title != NULL) { if (title != NULL) {
wattrset (dialog, title_attr); wattrset (dialog, title_attr);
mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' ');
waddstr (dialog, (char *)title); waddstr (dialog, (char *)title);
waddch (dialog, ' '); waddch (dialog, ' ');
} }
wattrset (dialog, dialog_attr); wattrset (dialog, dialog_attr);
@@ -217,12 +217,12 @@ dialog_menu (const char *title, const char *prompt, int height, int width,
/* create new window for the menu */ /* create new window for the menu */
menu = subwin (dialog, menu_height, menu_width, menu = subwin (dialog, menu_height, menu_width,
y + box_y + 1, x + box_x + 1); y + box_y + 1, x + box_x + 1);
keypad (menu, TRUE); keypad (menu, TRUE);
/* draw a box around the menu items */ /* draw a box around the menu items */
draw_box (dialog, box_y, box_x, menu_height + 2, menu_width + 2, draw_box (dialog, box_y, box_x, menu_height + 2, menu_width + 2,
menubox_border_attr, menubox_attr); menubox_border_attr, menubox_attr);
/* /*
* Find length of longest item in order to center menu. * Find length of longest item in order to center menu.
@@ -230,72 +230,72 @@ dialog_menu (const char *title, const char *prompt, int height, int width,
*/ */
item_x = 0; item_x = 0;
for (i = 0; i < item_no; i++) { for (i = 0; i < item_no; i++) {
item_x = MAX (item_x, MIN(menu_width, strlen (items[i * 2 + 1]) + 2)); item_x = MAX (item_x, MIN(menu_width, strlen (items[i * 2 + 1]) + 2));
if (strcmp(current, items[i*2]) == 0) choice = i; if (strcmp(current, items[i*2]) == 0) choice = i;
} }
item_x = (menu_width - item_x) / 2; item_x = (menu_width - item_x) / 2;
/* get the scroll info from the temp file */ /* get the scroll info from the temp file */
if ( (f=fopen("lxdialog.scrltmp","r")) != NULL ) { if ( (f=fopen("lxdialog.scrltmp","r")) != NULL ) {
if ( (fscanf(f,"%d\n",&scroll) == 1) && (scroll <= choice) && if ( (fscanf(f,"%d\n",&scroll) == 1) && (scroll <= choice) &&
(scroll+max_choice > choice) && (scroll >= 0) && (scroll+max_choice > choice) && (scroll >= 0) &&
(scroll+max_choice <= item_no) ) { (scroll+max_choice <= item_no) ) {
first_item = scroll; first_item = scroll;
choice = choice - scroll; choice = choice - scroll;
fclose(f); fclose(f);
} else { } else {
scroll=0; scroll=0;
remove("lxdialog.scrltmp"); remove("lxdialog.scrltmp");
fclose(f); fclose(f);
f=NULL; f=NULL;
} }
} }
if ( (choice >= max_choice) || (f==NULL && choice >= max_choice/2) ) { if ( (choice >= max_choice) || (f==NULL && choice >= max_choice/2) ) {
if (choice >= item_no-max_choice/2) if (choice >= item_no-max_choice/2)
scroll = first_item = item_no-max_choice; scroll = first_item = item_no-max_choice;
else else
scroll = first_item = choice - max_choice/2; scroll = first_item = choice - max_choice/2;
choice = choice - scroll; choice = choice - scroll;
} }
/* Print the menu */ /* Print the menu */
for (i=0; i < max_choice; i++) { for (i=0; i < max_choice; i++) {
print_item (menu, items[(first_item + i) * 2 + 1], i, i == choice, print_item (menu, items[(first_item + i) * 2 + 1], i, i == choice,
(items[(first_item + i)*2][0] != ':')); (items[(first_item + i)*2][0] != ':'));
} }
wnoutrefresh (menu); wnoutrefresh (menu);
print_arrows(dialog, item_no, scroll, print_arrows(dialog, item_no, scroll,
box_y, box_x+item_x+1, menu_height); box_y, box_x+item_x+1, menu_height);
print_buttons (dialog, height, width, 0); print_buttons (dialog, height, width, 0);
wmove (menu, choice, item_x+1); wmove (menu, choice, item_x+1);
wrefresh (menu); wrefresh (menu);
while (key != ESC) { while (key != ESC) {
key = wgetch(menu); key = wgetch(menu);
if (key < 256 && isalpha(key)) key = tolower(key); if (key < 256 && isalpha(key)) key = tolower(key);
if (strchr("ynm", key)) if (strchr("ynm", key))
i = max_choice; i = max_choice;
else { else {
for (i = choice+1; i < max_choice; i++) { for (i = choice+1; i < max_choice; i++) {
j = first_alpha(items[(scroll+i)*2+1], "YyNnMm"); j = first_alpha(items[(scroll+i)*2+1], "YyNnMm");
if (key == tolower(items[(scroll+i)*2+1][j])) if (key == tolower(items[(scroll+i)*2+1][j]))
break; break;
} }
if (i == max_choice) if (i == max_choice)
for (i = 0; i < max_choice; i++) { for (i = 0; i < max_choice; i++) {
j = first_alpha(items[(scroll+i)*2+1], "YyNnMm"); j = first_alpha(items[(scroll+i)*2+1], "YyNnMm");
if (key == tolower(items[(scroll+i)*2+1][j])) if (key == tolower(items[(scroll+i)*2+1][j]))
break; break;
} }
} }
if (i < max_choice || if (i < max_choice ||
key == KEY_UP || key == KEY_DOWN || key == KEY_UP || key == KEY_DOWN ||
key == '-' || key == '+' || key == '-' || key == '+' ||
key == KEY_PPAGE || key == KEY_NPAGE) { key == KEY_PPAGE || key == KEY_NPAGE) {
@@ -303,9 +303,9 @@ dialog_menu (const char *title, const char *prompt, int height, int width,
print_item (menu, items[(scroll+choice)*2+1], choice, FALSE, print_item (menu, items[(scroll+choice)*2+1], choice, FALSE,
(items[(scroll+choice)*2][0] != ':')); (items[(scroll+choice)*2][0] != ':'));
if (key == KEY_UP || key == '-') { if (key == KEY_UP || key == '-') {
if (choice < 2 && scroll) { if (choice < 2 && scroll) {
/* Scroll menu down */ /* Scroll menu down */
scrollok (menu, TRUE); scrollok (menu, TRUE);
wscrl (menu, -1); wscrl (menu, -1);
scrollok (menu, FALSE); scrollok (menu, FALSE);
@@ -314,19 +314,19 @@ dialog_menu (const char *title, const char *prompt, int height, int width,
print_item (menu, items[scroll * 2 + 1], 0, FALSE, print_item (menu, items[scroll * 2 + 1], 0, FALSE,
(items[scroll*2][0] != ':')); (items[scroll*2][0] != ':'));
} else } else
choice = MAX(choice - 1, 0); choice = MAX(choice - 1, 0);
} else if (key == KEY_DOWN || key == '+') { } else if (key == KEY_DOWN || key == '+') {
print_item (menu, items[(scroll+choice)*2+1], choice, FALSE, print_item (menu, items[(scroll+choice)*2+1], choice, FALSE,
(items[(scroll+choice)*2][0] != ':')); (items[(scroll+choice)*2][0] != ':'));
if ((choice > max_choice-3) && if ((choice > max_choice-3) &&
(scroll + max_choice < item_no) (scroll + max_choice < item_no)
) { ) {
/* Scroll menu up */ /* Scroll menu up */
scrollok (menu, TRUE); scrollok (menu, TRUE);
scroll (menu); scroll (menu);
scrollok (menu, FALSE); scrollok (menu, FALSE);
@@ -338,14 +338,14 @@ dialog_menu (const char *title, const char *prompt, int height, int width,
} else } else
choice = MIN(choice+1, max_choice-1); choice = MIN(choice+1, max_choice-1);
} else if (key == KEY_PPAGE) { } else if (key == KEY_PPAGE) {
scrollok (menu, TRUE); scrollok (menu, TRUE);
for (i=0; (i < max_choice); i++) { for (i=0; (i < max_choice); i++) {
if (scroll > 0) { if (scroll > 0) {
wscrl (menu, -1); wscrl (menu, -1);
scroll--; scroll--;
print_item (menu, items[scroll * 2 + 1], 0, FALSE, print_item (menu, items[scroll * 2 + 1], 0, FALSE,
(items[scroll*2][0] != ':')); (items[scroll*2][0] != ':'));
} else { } else {
if (choice > 0) if (choice > 0)
choice--; choice--;
@@ -356,17 +356,17 @@ dialog_menu (const char *title, const char *prompt, int height, int width,
} else if (key == KEY_NPAGE) { } else if (key == KEY_NPAGE) {
for (i=0; (i < max_choice); i++) { for (i=0; (i < max_choice); i++) {
if (scroll+max_choice < item_no) { if (scroll+max_choice < item_no) {
scrollok (menu, TRUE); scrollok (menu, TRUE);
scroll(menu); scroll(menu);
scrollok (menu, FALSE); scrollok (menu, FALSE);
scroll++; scroll++;
print_item (menu, items[(scroll+max_choice-1)*2+1], print_item (menu, items[(scroll+max_choice-1)*2+1],
max_choice-1, FALSE, max_choice-1, FALSE,
(items[(scroll+max_choice-1)*2][0] != ':')); (items[(scroll+max_choice-1)*2][0] != ':'));
} else { } else {
if (choice+1 < max_choice) if (choice+1 < max_choice)
choice++; choice++;
} }
} }
} else } else
@@ -381,30 +381,30 @@ dialog_menu (const char *title, const char *prompt, int height, int width,
wnoutrefresh (dialog); wnoutrefresh (dialog);
wrefresh (menu); wrefresh (menu);
continue; /* wait for another key press */ continue; /* wait for another key press */
} }
switch (key) { switch (key) {
case KEY_LEFT: case KEY_LEFT:
case TAB: case TAB:
case KEY_RIGHT: case KEY_RIGHT:
button = ((key == KEY_LEFT ? --button : ++button) < 0) button = ((key == KEY_LEFT ? --button : ++button) < 0)
? 2 : (button > 2 ? 0 : button); ? 2 : (button > 2 ? 0 : button);
print_buttons(dialog, height, width, button); print_buttons(dialog, height, width, button);
wrefresh (menu); wrefresh (menu);
break; break;
case ' ': case ' ':
case 's': case 's':
case 'y': case 'y':
case 'n': case 'n':
case 'm': case 'm':
/* save scroll info */ /* save scroll info */
if ( (f=fopen("lxdialog.scrltmp","w")) != NULL ) { if ( (f=fopen("lxdialog.scrltmp","w")) != NULL ) {
fprintf(f,"%d\n",scroll); fprintf(f,"%d\n",scroll);
fclose(f); fclose(f);
} }
delwin (dialog); delwin (dialog);
fprintf(stderr, "%s\n", items[(scroll + choice) * 2]); fprintf(stderr, "%s\n", items[(scroll + choice) * 2]);
switch (key) { switch (key) {
case 's': return 3; case 's': return 3;
@@ -413,31 +413,31 @@ dialog_menu (const char *title, const char *prompt, int height, int width,
case 'm': return 5; case 'm': return 5;
case ' ': return 6; case ' ': return 6;
} }
return 0; return 0;
case 'h': case 'h':
case '?': case '?':
button = 2; button = 2;
case '\n': case '\n':
delwin (dialog); delwin (dialog);
if (button == 2) if (button == 2)
fprintf(stderr, "%s \"%s\"\n", fprintf(stderr, "%s \"%s\"\n",
items[(scroll + choice) * 2], items[(scroll + choice) * 2],
items[(scroll + choice) * 2 + 1] + items[(scroll + choice) * 2 + 1] +
first_alpha(items[(scroll + choice) * 2 + 1],"")); first_alpha(items[(scroll + choice) * 2 + 1],""));
else else
fprintf(stderr, "%s\n", items[(scroll + choice) * 2]); fprintf(stderr, "%s\n", items[(scroll + choice) * 2]);
remove("lxdialog.scrltmp"); remove("lxdialog.scrltmp");
return button; return button;
case 'e': case 'e':
case 'x': case 'x':
key = ESC; key = ESC;
case ESC: case ESC:
break; break;
} }
} }
delwin (dialog); delwin (dialog);
remove("lxdialog.scrltmp"); remove("lxdialog.scrltmp");
return -1; /* ESC pressed */ return -1; /* ESC pressed */
} }

View File

@@ -27,7 +27,7 @@
*/ */
int int
dialog_msgbox (const char *title, const char *prompt, int height, int width, dialog_msgbox (const char *title, const char *prompt, int height, int width,
int pause) int pause)
{ {
int i, x, y, key = 0; int i, x, y, key = 0;
WINDOW *dialog; WINDOW *dialog;
@@ -44,40 +44,40 @@ dialog_msgbox (const char *title, const char *prompt, int height, int width,
draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr); draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr);
if (title != NULL && strlen(title) >= width-2 ) { if (title != NULL && strlen(title) >= width-2 ) {
/* truncate long title -- mec */ /* truncate long title -- mec */
char * title2 = malloc(width-2+1); char * title2 = malloc(width-2+1);
memcpy( title2, title, width-2 ); memcpy( title2, title, width-2 );
title2[width-2] = '\0'; title2[width-2] = '\0';
title = title2; title = title2;
} }
if (title != NULL) { if (title != NULL) {
wattrset (dialog, title_attr); wattrset (dialog, title_attr);
mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' ');
waddstr (dialog, (char *)title); waddstr (dialog, (char *)title);
waddch (dialog, ' '); waddch (dialog, ' ');
} }
wattrset (dialog, dialog_attr); wattrset (dialog, dialog_attr);
print_autowrap (dialog, prompt, width - 2, 1, 2); print_autowrap (dialog, prompt, width - 2, 1, 2);
if (pause) { if (pause) {
wattrset (dialog, border_attr); wattrset (dialog, border_attr);
mvwaddch (dialog, height - 3, 0, ACS_LTEE); mvwaddch (dialog, height - 3, 0, ACS_LTEE);
for (i = 0; i < width - 2; i++) for (i = 0; i < width - 2; i++)
waddch (dialog, ACS_HLINE); waddch (dialog, ACS_HLINE);
wattrset (dialog, dialog_attr); wattrset (dialog, dialog_attr);
waddch (dialog, ACS_RTEE); waddch (dialog, ACS_RTEE);
print_button (dialog, " Ok ", print_button (dialog, " Ok ",
height - 2, width / 2 - 4, TRUE); height - 2, width / 2 - 4, TRUE);
wrefresh (dialog); wrefresh (dialog);
while (key != ESC && key != '\n' && key != ' ' && while (key != ESC && key != '\n' && key != ' ' &&
key != 'O' && key != 'o' && key != 'X' && key != 'x') key != 'O' && key != 'o' && key != 'X' && key != 'x')
key = wgetch (dialog); key = wgetch (dialog);
} else { } else {
key = '\n'; key = '\n';
wrefresh (dialog); wrefresh (dialog);
} }
delwin (dialog); delwin (dialog);

File diff suppressed because it is too large Load Diff

View File

@@ -34,35 +34,35 @@ const char *dialog_result;
*/ */
chtype attributes[] = chtype attributes[] =
{ {
A_NORMAL, /* screen_attr */ A_NORMAL, /* screen_attr */
A_NORMAL, /* shadow_attr */ A_NORMAL, /* shadow_attr */
A_NORMAL, /* dialog_attr */ A_NORMAL, /* dialog_attr */
A_BOLD, /* title_attr */ A_BOLD, /* title_attr */
A_NORMAL, /* border_attr */ A_NORMAL, /* border_attr */
A_REVERSE, /* button_active_attr */ A_REVERSE, /* button_active_attr */
A_DIM, /* button_inactive_attr */ A_DIM, /* button_inactive_attr */
A_REVERSE, /* button_key_active_attr */ A_REVERSE, /* button_key_active_attr */
A_BOLD, /* button_key_inactive_attr */ A_BOLD, /* button_key_inactive_attr */
A_REVERSE, /* button_label_active_attr */ A_REVERSE, /* button_label_active_attr */
A_NORMAL, /* button_label_inactive_attr */ A_NORMAL, /* button_label_inactive_attr */
A_NORMAL, /* inputbox_attr */ A_NORMAL, /* inputbox_attr */
A_NORMAL, /* inputbox_border_attr */ A_NORMAL, /* inputbox_border_attr */
A_NORMAL, /* searchbox_attr */ A_NORMAL, /* searchbox_attr */
A_BOLD, /* searchbox_title_attr */ A_BOLD, /* searchbox_title_attr */
A_NORMAL, /* searchbox_border_attr */ A_NORMAL, /* searchbox_border_attr */
A_BOLD, /* position_indicator_attr */ A_BOLD, /* position_indicator_attr */
A_NORMAL, /* menubox_attr */ A_NORMAL, /* menubox_attr */
A_NORMAL, /* menubox_border_attr */ A_NORMAL, /* menubox_border_attr */
A_NORMAL, /* item_attr */ A_NORMAL, /* item_attr */
A_REVERSE, /* item_selected_attr */ A_REVERSE, /* item_selected_attr */
A_BOLD, /* tag_attr */ A_BOLD, /* tag_attr */
A_REVERSE, /* tag_selected_attr */ A_REVERSE, /* tag_selected_attr */
A_BOLD, /* tag_key_attr */ A_BOLD, /* tag_key_attr */
A_REVERSE, /* tag_key_selected_attr */ A_REVERSE, /* tag_key_selected_attr */
A_BOLD, /* check_attr */ A_BOLD, /* check_attr */
A_REVERSE, /* check_selected_attr */ A_REVERSE, /* check_selected_attr */
A_BOLD, /* uarrow_attr */ A_BOLD, /* uarrow_attr */
A_BOLD /* darrow_attr */ A_BOLD /* darrow_attr */
}; };
@@ -103,7 +103,7 @@ int color_table[][3] =
{CHECK_SELECTED_FG, CHECK_SELECTED_BG, CHECK_SELECTED_HL}, {CHECK_SELECTED_FG, CHECK_SELECTED_BG, CHECK_SELECTED_HL},
{UARROW_FG, UARROW_BG, UARROW_HL}, {UARROW_FG, UARROW_BG, UARROW_HL},
{DARROW_FG, DARROW_BG, DARROW_HL}, {DARROW_FG, DARROW_BG, DARROW_HL},
}; /* color_table */ }; /* color_table */
/* /*
* Set window to attribute 'attr' * Set window to attribute 'attr'
@@ -115,9 +115,9 @@ attr_clear (WINDOW * win, int height, int width, chtype attr)
wattrset (win, attr); wattrset (win, attr);
for (i = 0; i < height; i++) { for (i = 0; i < height; i++) {
wmove (win, i, 0); wmove (win, i, 0);
for (j = 0; j < width; j++) for (j = 0; j < width; j++)
waddch (win, ' '); waddch (win, ' ');
} }
touchwin (win); touchwin (win);
} }
@@ -144,14 +144,14 @@ void dialog_clear (void)
void void
init_dialog (void) init_dialog (void)
{ {
initscr (); /* Init curses */ initscr (); /* Init curses */
keypad (stdscr, TRUE); keypad (stdscr, TRUE);
cbreak (); cbreak ();
noecho (); noecho ();
if (use_colors) /* Set up colors */ if (use_colors) /* Set up colors */
color_setup (); color_setup ();
dialog_clear (); dialog_clear ();
@@ -165,16 +165,16 @@ color_setup (void)
{ {
int i; int i;
if (has_colors ()) { /* Terminal supports color? */ if (has_colors ()) { /* Terminal supports color? */
start_color (); start_color ();
/* Initialize color pairs */ /* Initialize color pairs */
for (i = 0; i < ATTRIBUTE_COUNT; i++) for (i = 0; i < ATTRIBUTE_COUNT; i++)
init_pair (i + 1, color_table[i][0], color_table[i][1]); init_pair (i + 1, color_table[i][0], color_table[i][1]);
/* Setup color attributes */ /* Setup color attributes */
for (i = 0; i < ATTRIBUTE_COUNT; i++) for (i = 0; i < ATTRIBUTE_COUNT; i++)
attributes[i] = C_ATTR (color_table[i][2], i + 1); attributes[i] = C_ATTR (color_table[i][2], i + 1);
} }
} }
@@ -209,45 +209,45 @@ print_autowrap (WINDOW * win, const char *prompt, int width, int y, int x)
* Remove newlines * Remove newlines
*/ */
for(i=0; i<prompt_len; i++) { for(i=0; i<prompt_len; i++) {
if(tempstr[i] == '\n') tempstr[i] = ' '; if(tempstr[i] == '\n') tempstr[i] = ' ';
} }
if (prompt_len <= width - x * 2) { /* If prompt is short */ if (prompt_len <= width - x * 2) { /* If prompt is short */
wmove (win, y, (width - prompt_len) / 2); wmove (win, y, (width - prompt_len) / 2);
waddstr (win, tempstr); waddstr (win, tempstr);
} else { } else {
cur_x = x; cur_x = x;
cur_y = y; cur_y = y;
newl = 1; newl = 1;
word = tempstr; word = tempstr;
while (word && *word) { while (word && *word) {
sp = index(word, ' '); sp = index(word, ' ');
if (sp) if (sp)
*sp++ = 0; *sp++ = 0;
/* Wrap to next line if either the word does not fit, /* Wrap to next line if either the word does not fit,
or it is the first word of a new sentence, and it is or it is the first word of a new sentence, and it is
short, and the next word does not fit. */ short, and the next word does not fit. */
room = width - cur_x; room = width - cur_x;
wlen = strlen(word); wlen = strlen(word);
if (wlen > room || if (wlen > room ||
(newl && wlen < 4 && sp && wlen+1+strlen(sp) > room (newl && wlen < 4 && sp && wlen+1+strlen(sp) > room
&& (!(sp2 = index(sp, ' ')) || wlen+1+(sp2-sp) > room))) { && (!(sp2 = index(sp, ' ')) || wlen+1+(sp2-sp) > room))) {
cur_y++; cur_y++;
cur_x = x; cur_x = x;
} }
wmove (win, cur_y, cur_x); wmove (win, cur_y, cur_x);
waddstr (win, word); waddstr (win, word);
getyx (win, cur_y, cur_x); getyx (win, cur_y, cur_x);
cur_x++; cur_x++;
if (sp && *sp == ' ') { if (sp && *sp == ' ') {
cur_x++; /* double space */ cur_x++; /* double space */
while (*++sp == ' '); while (*++sp == ' ');
newl = 1; newl = 1;
} else } else
newl = 0; newl = 0;
word = sp; word = sp;
} }
} }
} }
@@ -265,14 +265,14 @@ print_button (WINDOW * win, const char *label, int y, int x, int selected)
temp = strspn (label, " "); temp = strspn (label, " ");
label += temp; label += temp;
wattrset (win, selected ? button_label_active_attr wattrset (win, selected ? button_label_active_attr
: button_label_inactive_attr); : button_label_inactive_attr);
for (i = 0; i < temp; i++) for (i = 0; i < temp; i++)
waddch (win, ' '); waddch (win, ' ');
wattrset (win, selected ? button_key_active_attr wattrset (win, selected ? button_key_active_attr
: button_key_inactive_attr); : button_key_inactive_attr);
waddch (win, label[0]); waddch (win, label[0]);
wattrset (win, selected ? button_label_active_attr wattrset (win, selected ? button_label_active_attr
: button_label_inactive_attr); : button_label_inactive_attr);
waddstr (win, (char *)label + 1); waddstr (win, (char *)label + 1);
wattrset (win, selected ? button_active_attr : button_inactive_attr); wattrset (win, selected ? button_active_attr : button_inactive_attr);
waddstr (win, ">"); waddstr (win, ">");
@@ -284,32 +284,32 @@ print_button (WINDOW * win, const char *label, int y, int x, int selected)
*/ */
void void
draw_box (WINDOW * win, int y, int x, int height, int width, draw_box (WINDOW * win, int y, int x, int height, int width,
chtype box, chtype border) chtype box, chtype border)
{ {
int i, j; int i, j;
wattrset (win, 0); wattrset (win, 0);
for (i = 0; i < height; i++) { for (i = 0; i < height; i++) {
wmove (win, y + i, x); wmove (win, y + i, x);
for (j = 0; j < width; j++) for (j = 0; j < width; j++)
if (!i && !j) if (!i && !j)
waddch (win, border | ACS_ULCORNER); waddch (win, border | ACS_ULCORNER);
else if (i == height - 1 && !j) else if (i == height - 1 && !j)
waddch (win, border | ACS_LLCORNER); waddch (win, border | ACS_LLCORNER);
else if (!i && j == width - 1) else if (!i && j == width - 1)
waddch (win, box | ACS_URCORNER); waddch (win, box | ACS_URCORNER);
else if (i == height - 1 && j == width - 1) else if (i == height - 1 && j == width - 1)
waddch (win, box | ACS_LRCORNER); waddch (win, box | ACS_LRCORNER);
else if (!i) else if (!i)
waddch (win, border | ACS_HLINE); waddch (win, border | ACS_HLINE);
else if (i == height - 1) else if (i == height - 1)
waddch (win, box | ACS_HLINE); waddch (win, box | ACS_HLINE);
else if (!j) else if (!j)
waddch (win, border | ACS_VLINE); waddch (win, border | ACS_VLINE);
else if (j == width - 1) else if (j == width - 1)
waddch (win, box | ACS_VLINE); waddch (win, box | ACS_VLINE);
else else
waddch (win, box | ' '); waddch (win, box | ' ');
} }
} }
@@ -322,17 +322,17 @@ draw_shadow (WINDOW * win, int y, int x, int height, int width)
{ {
int i; int i;
if (has_colors ()) { /* Whether terminal supports color? */ if (has_colors ()) { /* Whether terminal supports color? */
wattrset (win, shadow_attr); wattrset (win, shadow_attr);
wmove (win, y + height, x + 2); wmove (win, y + height, x + 2);
for (i = 0; i < width; i++) for (i = 0; i < width; i++)
waddch (win, winch (win) & A_CHARTEXT); waddch (win, winch (win) & A_CHARTEXT);
for (i = y + 1; i < y + height + 1; i++) { for (i = y + 1; i < y + height + 1; i++) {
wmove (win, i, x + width); wmove (win, i, x + width);
waddch (win, winch (win) & A_CHARTEXT); waddch (win, winch (win) & A_CHARTEXT);
waddch (win, winch (win) & A_CHARTEXT); waddch (win, winch (win) & A_CHARTEXT);
} }
wnoutrefresh (win); wnoutrefresh (win);
} }
} }
@@ -342,18 +342,18 @@ draw_shadow (WINDOW * win, int y, int x, int height, int width)
int int
first_alpha(const char *string, const char *exempt) first_alpha(const char *string, const char *exempt)
{ {
int i, in_paren=0, c; int i, in_paren=0, c;
for (i = 0; i < strlen(string); i++) { for (i = 0; i < strlen(string); i++) {
c = tolower(string[i]); c = tolower(string[i]);
if (strchr("<[(", c)) ++in_paren; if (strchr("<[(", c)) ++in_paren;
if (strchr(">])", c)) --in_paren; if (strchr(">])", c)) --in_paren;
if ((! in_paren) && isalpha(c) && if ((! in_paren) && isalpha(c) &&
strchr(exempt, c) == 0) strchr(exempt, c) == 0)
return i; return i;
} }
return 0; return 0;
} }

View File

@@ -59,23 +59,23 @@ dialog_yesno (const char *title, const char *prompt, int height, int width)
wattrset (dialog, border_attr); wattrset (dialog, border_attr);
mvwaddch (dialog, height-3, 0, ACS_LTEE); mvwaddch (dialog, height-3, 0, ACS_LTEE);
for (i = 0; i < width - 2; i++) for (i = 0; i < width - 2; i++)
waddch (dialog, ACS_HLINE); waddch (dialog, ACS_HLINE);
wattrset (dialog, dialog_attr); wattrset (dialog, dialog_attr);
waddch (dialog, ACS_RTEE); waddch (dialog, ACS_RTEE);
if (title != NULL && strlen(title) >= width-2 ) { if (title != NULL && strlen(title) >= width-2 ) {
/* truncate long title -- mec */ /* truncate long title -- mec */
char * title2 = malloc(width-2+1); char * title2 = malloc(width-2+1);
memcpy( title2, title, width-2 ); memcpy( title2, title, width-2 );
title2[width-2] = '\0'; title2[width-2] = '\0';
title = title2; title = title2;
} }
if (title != NULL) { if (title != NULL) {
wattrset (dialog, title_attr); wattrset (dialog, title_attr);
mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' ');
waddstr (dialog, (char *)title); waddstr (dialog, (char *)title);
waddch (dialog, ' '); waddch (dialog, ' ');
} }
wattrset (dialog, dialog_attr); wattrset (dialog, dialog_attr);
@@ -84,35 +84,35 @@ dialog_yesno (const char *title, const char *prompt, int height, int width)
print_buttons(dialog, height, width, 0); print_buttons(dialog, height, width, 0);
while (key != ESC) { while (key != ESC) {
key = wgetch (dialog); key = wgetch (dialog);
switch (key) { switch (key) {
case 'Y': case 'Y':
case 'y': case 'y':
delwin (dialog); delwin (dialog);
return 0; return 0;
case 'N': case 'N':
case 'n': case 'n':
delwin (dialog); delwin (dialog);
return 1; return 1;
case TAB: case TAB:
case KEY_LEFT: case KEY_LEFT:
case KEY_RIGHT: case KEY_RIGHT:
button = ((key == KEY_LEFT ? --button : ++button) < 0) button = ((key == KEY_LEFT ? --button : ++button) < 0)
? 1 : (button > 1 ? 0 : button); ? 1 : (button > 1 ? 0 : button);
print_buttons(dialog, height, width, button); print_buttons(dialog, height, width, button);
wrefresh (dialog); wrefresh (dialog);
break; break;
case ' ': case ' ':
case '\n': case '\n':
delwin (dialog); delwin (dialog);
return button; return button;
case ESC: case ESC:
break; break;
} }
} }
delwin (dialog); delwin (dialog);
return -1; /* ESC pressed */ return -1; /* ESC pressed */
} }

Some files were not shown because too many files have changed in this diff Show More