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 */
#define SE_MEM_POOL_SIZE (64 * 1024)
#define SE_MEM_POOL_SIZE (64 * 1024)
#define SE_CACHE_MEM_POOL_SIZE (256 * 1024)
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
direction of stack growth for your system; otherwise it will be
automatically deduced at run-time.
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown */
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown */
/* #undef STACK_DIRECTION */
/* 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
direction of stack growth for your system; otherwise it will be
automatically deduced at run-time.
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown */
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown */
/* #undef STACK_DIRECTION */
/* 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
direction of stack growth for your system; otherwise it will be
automatically deduced at run-time.
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown */
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown */
/* #undef STACK_DIRECTION */
/* Define to 1 if you have the ANSI C header files. */

View File

@@ -366,7 +366,7 @@
/* #undef _MGINCOREFONT_VGAS */
/* 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 */
/* #undef _MGINCORERBF_GB16 */

View File

@@ -377,7 +377,7 @@
/* #undef _MGINCOREFONT_VGAS */
/* 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 _MGINCORERBF_GB16 1

View File

@@ -377,7 +377,7 @@
/* #undef _MGINCOREFONT_VGAS */
/* 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 _MGINCORERBF_GB16 1

View File

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

View File

@@ -1,5 +1,13 @@
#!/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
# sed -i 's/\<AAA\>/__AAA/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_get_system_res_path\>/__sysres_get_system_res_path/g' `grep sysres_get_system_res_path -rl include/ src/`
tab2space
exit 0

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -78,7 +78,7 @@
extern "C" {
#endif /* __cplusplus */
#define OSEPTH_LEN_NAME 256
#define OSEPTH_LEN_NAME 256
/**
* @\type SEMAPHORE
@@ -94,7 +94,7 @@ typedef struct _sem_t
char name [OSEPTH_LEN_NAME];
} sem_t;
#define SEM_VALUE_MAX UINT_MAX
#define SEM_VALUE_MAX UINT_MAX
/*-----------------------------------------------------------------------------
** 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;
/* Values for detachstate */
#define PTHREAD_CREATE_JOINABLE 1
#define PTHREAD_CREATE_DETACHED 2
#define PTHREAD_CREATE_JOINABLE 1
#define PTHREAD_CREATE_DETACHED 2
#if 0
/* Values for scope */
@@ -257,7 +257,7 @@ int pthread_attr_getschedpolicy (const pthread_attr_t *attr,
/* Set scheduling parameters */
int pthread_attr_setschedparam (pthread_attr_t *attr,
const struct sched_param *param);
const struct sched_param *param);
/* Get scheduling parameters */
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 *prev; /* Chain cleanup buffers */
void (*routine) (void *); /* Function to call */
void *arg; /* Arg to pass */
void (*routine) (void *); /* Function to call */
void *arg; /* Arg to pass */
};
/*-----------------------------------------------------------------------------
@@ -436,7 +436,7 @@ typedef unsigned long pthread_mutex_t;
/*define pthread_mutexattr_t */
typedef struct _pthread_mutexattr_t
{
int type;
int type;
int protocol;
unsigned long prio_ceiling;
} pthread_mutexattr_t;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -14,10 +14,10 @@
* Module: semaphore.h
*
* Purpose:
* Semaphores aren't actually part of the PThreads standard.
* They are defined by the POSIX Standard:
* Semaphores aren't actually part of the PThreads 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
extern "C"
{
#endif /* __cplusplus */
#endif /* __cplusplus */
#ifndef HAVE_MODE_T
typedef unsigned int mode_t;
@@ -136,8 +136,8 @@ typedef unsigned int mode_t;
typedef struct sem_t_ * sem_t;
PTW32_DLLPORT int __cdecl sem_init (sem_t * sem,
int pshared,
unsigned int value);
int pshared,
unsigned int value);
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_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_multiple (sem_t * sem,
int count);
int count);
PTW32_DLLPORT int __cdecl sem_open (const char * name,
int oflag,
mode_t mode,
unsigned int value);
int oflag,
mode_t mode,
unsigned int value);
PTW32_DLLPORT int __cdecl sem_close (sem_t * sem);
PTW32_DLLPORT int __cdecl sem_unlink (const char * name);
PTW32_DLLPORT int __cdecl sem_getvalue (sem_t * sem,
int * sval);
int * sval);
#ifdef __cplusplus
} /* End of extern "C" */
#endif /* __cplusplus */
} /* End of extern "C" */
#endif /* __cplusplus */
#undef PTW32_LEVEL
#undef PTW32_LEVEL_MAX
#endif /* !SEMAPHORE_H */
#endif /* !SEMAPHORE_H */

View File

@@ -74,12 +74,12 @@ extern "C" {
#define MAX_PHRASE_LENGTH 20
#define SELECT_KEY_LENGTH 16
#define END_KEY_LENGTH 16
#define MAX_SEL_LENGTH 58
#define MAX_SEL_LENGTH 58
#define InputAreaX 16
/* key of toggle input method */
#define NR_INPUTMETHOD 10
#define NR_INPUTMETHOD 10
typedef struct {
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");
}
#elif defined(WIN32)
strcpy (file_name, tabpath);
strcat (file_name, "usrphrase.tab");
strcpy (file_name, tabpath);
strcat (file_name, "usrphrase.tab");
#endif
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -30,7 +30,7 @@ static int list_width, check_x, item_x, checkflag;
*/
static void
print_item (WINDOW * win, const char *item, int status,
int choice, int selected)
int choice, int selected)
{
int i;
@@ -38,22 +38,22 @@ print_item (WINDOW * win, const char *item, int status,
wattrset (win, menubox_attr);
wmove (win, choice, 0);
for (i = 0; i < list_width; i++)
waddch (win, ' ');
waddch (win, ' ');
wmove (win, choice, check_x);
wattrset (win, selected ? check_selected_attr : check_attr);
if (checkflag == FLAG_CHECK)
wprintw (win, "[%c]", status ? 'X' : ' ');
wprintw (win, "[%c]", status ? 'X' : ' ');
else
wprintw (win, "(%c)", status ? 'X' : ' ');
wprintw (win, "(%c)", status ? 'X' : ' ');
wattrset (win, selected ? tag_selected_attr : tag_attr);
mvwaddch(win, choice, item_x, item[0]);
wattrset (win, selected ? item_selected_attr : item_attr);
waddstr (win, (char *)item+1);
if (selected) {
wmove (win, choice, check_x+1);
wrefresh (win);
wmove (win, choice, check_x+1);
wrefresh (win);
}
}
@@ -62,37 +62,37 @@ print_item (WINDOW * win, const char *item, int status,
*/
static void
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);
if (scroll > 0) {
wattrset (win, uarrow_attr);
waddch (win, ACS_UARROW);
waddstr (win, "(-)");
wattrset (win, uarrow_attr);
waddch (win, ACS_UARROW);
waddstr (win, "(-)");
}
else {
wattrset (win, menubox_attr);
waddch (win, ACS_HLINE);
waddch (win, ACS_HLINE);
waddch (win, ACS_HLINE);
waddch (win, ACS_HLINE);
wattrset (win, menubox_attr);
waddch (win, ACS_HLINE);
waddch (win, ACS_HLINE);
waddch (win, ACS_HLINE);
waddch (win, ACS_HLINE);
}
y = y + height + 1;
wmove(win, y, x);
if ((height < item_no) && (scroll + choice < item_no - 1)) {
wattrset (win, darrow_attr);
waddch (win, ACS_DARROW);
waddstr (win, "(+)");
wattrset (win, darrow_attr);
waddch (win, ACS_DARROW);
waddstr (win, "(+)");
}
else {
wattrset (win, menubox_border_attr);
waddch (win, ACS_HLINE);
waddch (win, ACS_HLINE);
waddch (win, ACS_HLINE);
waddch (win, ACS_HLINE);
wattrset (win, menubox_border_attr);
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
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;
@@ -129,16 +129,16 @@ dialog_checklist (const char *title, const char *prompt, int height, int width,
/* Allocate space for storing item on/off status */
if ((status = malloc (sizeof (int) * item_no)) == NULL) {
endwin ();
fprintf (stderr,
"\nCan't allocate memory in dialog_checklist().\n");
exit (-1);
endwin ();
fprintf (stderr,
"\nCan't allocate memory in dialog_checklist().\n");
exit (-1);
}
/* Initializes status */
for (i = 0; i < item_no; i++) {
status[i] = !strcasecmp (items[i * 3 + 2], "on");
if (!choice && status[i])
status[i] = !strcasecmp (items[i * 3 + 2], "on");
if (!choice && status[i])
choice = i;
}
@@ -157,23 +157,23 @@ dialog_checklist (const char *title, const char *prompt, int height, int width,
wattrset (dialog, border_attr);
mvwaddch (dialog, height-3, 0, ACS_LTEE);
for (i = 0; i < width - 2; i++)
waddch (dialog, ACS_HLINE);
waddch (dialog, ACS_HLINE);
wattrset (dialog, dialog_attr);
waddch (dialog, ACS_RTEE);
if (title != NULL && strlen(title) >= width-2 ) {
/* truncate long title -- mec */
char * title2 = malloc(width-2+1);
memcpy( title2, title, width-2 );
title2[width-2] = '\0';
title = title2;
/* truncate long title -- mec */
char * title2 = malloc(width-2+1);
memcpy( title2, title, width-2 );
title2[width-2] = '\0';
title = title2;
}
if (title != NULL) {
wattrset (dialog, title_attr);
mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' ');
waddstr (dialog, (char *)title);
waddch (dialog, ' ');
wattrset (dialog, title_attr);
mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' ');
waddstr (dialog, (char *)title);
waddch (dialog, ' ');
}
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_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 */
check_x = 0;
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;
item_x = check_x + 4;
if (choice >= list_height) {
scroll = choice - list_height + 1;
choice -= scroll;
scroll = choice - list_height + 1;
choice -= scroll;
}
/* Print the list */
for (i = 0; i < max_choice; i++) {
print_item (list, items[(scroll+i) * 3 + 1],
status[i+scroll], i, i == choice);
print_item (list, items[(scroll+i) * 3 + 1],
status[i+scroll], i, i == choice);
}
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);
@@ -221,149 +221,149 @@ dialog_checklist (const char *title, const char *prompt, int height, int width,
doupdate ();
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]))
break;
if ( i < max_choice || key == KEY_UP || key == KEY_DOWN ||
key == '+' || key == '-' ) {
if (key == KEY_UP || key == '-') {
if (!choice) {
if (!scroll)
continue;
/* Scroll list down */
if (list_height > 1) {
/* De-highlight current first item */
print_item (list, items[scroll * 3 + 1],
status[scroll], 0, FALSE);
scrollok (list, TRUE);
wscrl (list, -1);
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]);
}
}
}
if ( i < max_choice || key == KEY_UP || key == KEY_DOWN ||
key == '+' || key == '-' ) {
if (key == KEY_UP || key == '-') {
if (!choice) {
if (!scroll)
continue;
/* Scroll list down */
if (list_height > 1) {
/* De-highlight current first item */
print_item (list, items[scroll * 3 + 1],
status[scroll], 0, FALSE);
scrollok (list, TRUE);
wscrl (list, -1);
scrollok (list, FALSE);
}
delwin (dialog);
free (status);
return button;
case 'X':
case 'x':
key = ESC;
case ESC:
break;
}
scroll--;
print_item (list, items[scroll * 3 + 1],
status[scroll], 0, TRUE);
wnoutrefresh (list);
/* Now, update everything... */
doupdate ();
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);
free (status);
return button;
case 'X':
case 'x':
key = ESC;
case ESC:
break;
}
/* Now, update everything... */
doupdate ();
}
delwin (dialog);
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_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,
chtype border);
chtype border);
void draw_shadow (WINDOW * win, int y, int x, int height, int width);
int first_alpha (const char *string, const char *exempt);
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 width, int pause);
int width, int pause);
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 menu_height, const char *choice, int item_no,
const char * const * items);
int menu_height, const char *choice, int item_no,
const char * const * items);
int 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 width, int list_height, int item_no,
const char * const * items, int flag);
extern unsigned char dialog_input_result[];
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

View File

@@ -44,7 +44,7 @@ print_buttons(WINDOW *dialog, int height, int width, int selected)
*/
int
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 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);
mvwaddch (dialog, height-3, 0, ACS_LTEE);
for (i = 0; i < width - 2; i++)
waddch (dialog, ACS_HLINE);
waddch (dialog, ACS_HLINE);
wattrset (dialog, dialog_attr);
waddch (dialog, ACS_RTEE);
if (title != NULL && strlen(title) >= width-2 ) {
/* truncate long title -- mec */
char * title2 = malloc(width-2+1);
memcpy( title2, title, width-2 );
title2[width-2] = '\0';
title = title2;
/* truncate long title -- mec */
char * title2 = malloc(width-2+1);
memcpy( title2, title, width-2 );
title2[width-2] = '\0';
title = title2;
}
if (title != NULL) {
wattrset (dialog, title_attr);
mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' ');
waddstr (dialog, (char *)title);
waddch (dialog, ' ');
wattrset (dialog, title_attr);
mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' ');
waddstr (dialog, (char *)title);
waddch (dialog, ' ');
}
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_x = (width - 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);
@@ -102,139 +102,139 @@ dialog_inputbox (const char *title, const char *prompt, int height, int width,
wattrset (dialog, inputbox_attr);
if (!init)
instr[0] = '\0';
instr[0] = '\0';
else
strcpy (instr, init);
strcpy (instr, init);
input_x = strlen (instr);
if (input_x >= box_width) {
scroll = input_x - box_width + 1;
input_x = box_width - 1;
for (i = 0; i < box_width - 1; i++)
waddch (dialog, instr[scroll + i]);
scroll = input_x - box_width + 1;
input_x = box_width - 1;
for (i = 0; i < box_width - 1; i++)
waddch (dialog, instr[scroll + i]);
} else
waddstr (dialog, instr);
waddstr (dialog, instr);
wmove (dialog, box_y, box_x + input_x);
wrefresh (dialog);
while (key != ESC) {
key = wgetch (dialog);
key = wgetch (dialog);
if (button == -1) { /* Input box selected */
switch (key) {
case TAB:
case KEY_UP:
case KEY_DOWN:
break;
case KEY_LEFT:
continue;
case KEY_RIGHT:
continue;
case KEY_BACKSPACE:
case 127:
if (input_x || scroll) {
wattrset (dialog, inputbox_attr);
if (!input_x) {
scroll = scroll < box_width - 1 ?
0 : scroll - (box_width - 1);
wmove (dialog, box_y, box_x);
for (i = 0; i < box_width; i++)
waddch (dialog, instr[scroll + input_x + i] ?
instr[scroll + input_x + i] : ' ');
input_x = strlen (instr) - scroll;
} else
input_x--;
instr[scroll + input_x] = '\0';
mvwaddch (dialog, box_y, input_x + box_x, ' ');
wmove (dialog, box_y, input_x + box_x);
wrefresh (dialog);
}
continue;
default:
if (key < 0x100 && isprint (key)) {
if (scroll + input_x < MAX_LEN) {
wattrset (dialog, inputbox_attr);
instr[scroll + input_x] = key;
instr[scroll + input_x + 1] = '\0';
if (input_x == box_width - 1) {
scroll++;
wmove (dialog, box_y, box_x);
for (i = 0; i < box_width - 1; i++)
waddch (dialog, instr[scroll + i]);
} else {
wmove (dialog, box_y, input_x++ + box_x);
waddch (dialog, key);
}
wrefresh (dialog);
} else
flash (); /* Alarm user about overflow */
continue;
}
}
}
switch (key) {
case 'O':
case 'o':
delwin (dialog);
return 0;
case 'H':
case 'h':
delwin (dialog);
return 1;
case KEY_UP:
case KEY_LEFT:
switch (button) {
case -1:
button = 1; /* Indicates "Cancel" button is selected */
print_buttons(dialog, height, width, 1);
break;
case 0:
button = -1; /* Indicates input box is selected */
print_buttons(dialog, height, width, 0);
wmove (dialog, box_y, box_x + input_x);
wrefresh (dialog);
break;
case 1:
button = 0; /* Indicates "OK" button is selected */
print_buttons(dialog, height, width, 0);
break;
}
break;
case TAB:
case KEY_DOWN:
case KEY_RIGHT:
switch (button) {
case -1:
button = 0; /* Indicates "OK" button is selected */
print_buttons(dialog, height, width, 0);
break;
case 0:
button = 1; /* Indicates "Cancel" button is selected */
print_buttons(dialog, height, width, 1);
break;
case 1:
button = -1; /* Indicates input box is selected */
print_buttons(dialog, height, width, 0);
wmove (dialog, box_y, box_x + input_x);
wrefresh (dialog);
break;
}
break;
case ' ':
case '\n':
delwin (dialog);
return (button == -1 ? 0 : button);
case 'X':
case 'x':
key = ESC;
case ESC:
break;
}
if (button == -1) { /* Input box selected */
switch (key) {
case TAB:
case KEY_UP:
case KEY_DOWN:
break;
case KEY_LEFT:
continue;
case KEY_RIGHT:
continue;
case KEY_BACKSPACE:
case 127:
if (input_x || scroll) {
wattrset (dialog, inputbox_attr);
if (!input_x) {
scroll = scroll < box_width - 1 ?
0 : scroll - (box_width - 1);
wmove (dialog, box_y, box_x);
for (i = 0; i < box_width; i++)
waddch (dialog, instr[scroll + input_x + i] ?
instr[scroll + input_x + i] : ' ');
input_x = strlen (instr) - scroll;
} else
input_x--;
instr[scroll + input_x] = '\0';
mvwaddch (dialog, box_y, input_x + box_x, ' ');
wmove (dialog, box_y, input_x + box_x);
wrefresh (dialog);
}
continue;
default:
if (key < 0x100 && isprint (key)) {
if (scroll + input_x < MAX_LEN) {
wattrset (dialog, inputbox_attr);
instr[scroll + input_x] = key;
instr[scroll + input_x + 1] = '\0';
if (input_x == box_width - 1) {
scroll++;
wmove (dialog, box_y, box_x);
for (i = 0; i < box_width - 1; i++)
waddch (dialog, instr[scroll + i]);
} else {
wmove (dialog, box_y, input_x++ + box_x);
waddch (dialog, key);
}
wrefresh (dialog);
} else
flash (); /* Alarm user about overflow */
continue;
}
}
}
switch (key) {
case 'O':
case 'o':
delwin (dialog);
return 0;
case 'H':
case 'h':
delwin (dialog);
return 1;
case KEY_UP:
case KEY_LEFT:
switch (button) {
case -1:
button = 1; /* Indicates "Cancel" button is selected */
print_buttons(dialog, height, width, 1);
break;
case 0:
button = -1; /* Indicates input box is selected */
print_buttons(dialog, height, width, 0);
wmove (dialog, box_y, box_x + input_x);
wrefresh (dialog);
break;
case 1:
button = 0; /* Indicates "OK" button is selected */
print_buttons(dialog, height, width, 0);
break;
}
break;
case TAB:
case KEY_DOWN:
case KEY_RIGHT:
switch (button) {
case -1:
button = 0; /* Indicates "OK" button is selected */
print_buttons(dialog, height, width, 0);
break;
case 0:
button = 1; /* Indicates "Cancel" button is selected */
print_buttons(dialog, height, width, 1);
break;
case 1:
button = -1; /* Indicates input box is selected */
print_buttons(dialog, height, width, 0);
wmove (dialog, box_y, box_x + input_x);
wrefresh (dialog);
break;
}
break;
case ' ':
case '\n':
delwin (dialog);
return (button == -1 ? 0 : button);
case 'X':
case 'x':
key = ESC;
case ESC:
break;
}
}
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);
#endif
if (argc < 2) {
Usage (argv[0]);
exit (-1);
Usage (argv[0]);
exit (-1);
}
while (offset < argc - 1 && !end_common_opts) { /* Common options */
if (!strcmp (argv[offset + 1], "--title")) {
if (argc - offset < 3 || title != NULL) {
Usage (argv[0]);
exit (-1);
} else {
title = argv[offset + 2];
offset += 2;
}
while (offset < argc - 1 && !end_common_opts) { /* Common options */
if (!strcmp (argv[offset + 1], "--title")) {
if (argc - offset < 3 || title != NULL) {
Usage (argv[0]);
exit (-1);
} else {
title = argv[offset + 2];
offset += 2;
}
} else if (!strcmp (argv[offset + 1], "--backtitle")) {
if (backtitle != NULL) {
Usage (argv[0]);
@@ -88,48 +88,48 @@ main (int argc, const char * const * argv)
backtitle = argv[offset + 2];
offset += 2;
}
} else if (!strcmp (argv[offset + 1], "--clear")) {
if (clear_screen) { /* Hey, "--clear" can't appear twice! */
Usage (argv[0]);
exit (-1);
} else if (argc == 2) { /* we only want to clear the screen */
init_dialog ();
refresh (); /* init_dialog() will clear the screen for us */
end_dialog ();
return 0;
} else {
clear_screen = 1;
offset++;
}
} else /* no more common options */
end_common_opts = 1;
} else if (!strcmp (argv[offset + 1], "--clear")) {
if (clear_screen) { /* Hey, "--clear" can't appear twice! */
Usage (argv[0]);
exit (-1);
} else if (argc == 2) { /* we only want to clear the screen */
init_dialog ();
refresh (); /* init_dialog() will clear the screen for us */
end_dialog ();
return 0;
} else {
clear_screen = 1;
offset++;
}
} else /* no more common options */
end_common_opts = 1;
}
if (argc - 1 == offset) { /* no more options */
Usage (argv[0]);
exit (-1);
if (argc - 1 == offset) { /* no more options */
Usage (argv[0]);
exit (-1);
}
/* use a table to look for the requested mode, to avoid code duplication */
for (modePtr = modes; modePtr->name; modePtr++) /* look for the mode */
if (!strcmp (argv[offset + 1], modePtr->name))
break;
for (modePtr = modes; modePtr->name; modePtr++) /* look for the mode */
if (!strcmp (argv[offset + 1], modePtr->name))
break;
if (!modePtr->name)
Usage (argv[0]);
Usage (argv[0]);
if (argc - offset < modePtr->argmin)
Usage (argv[0]);
Usage (argv[0]);
if (modePtr->argmax && argc - offset > modePtr->argmax)
Usage (argv[0]);
Usage (argv[0]);
init_dialog ();
retval = (*(modePtr->jumper)) (title, argc - offset, argv + offset);
if (clear_screen) { /* clear screen before exit */
attr_clear (stdscr, LINES, COLS, screen_attr);
refresh ();
if (clear_screen) { /* clear screen before exit */
attr_clear (stdscr, LINES, COLS, screen_attr);
refresh ();
}
end_dialog();
@@ -173,21 +173,21 @@ int
j_menu (const char *t, int ac, const char * const * av)
{
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
j_checklist (const char *t, int ac, const char * const * av)
{
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
j_radiolist (const char *t, int ac, const char * const * av)
{
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

View File

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

View File

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