mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 21:06:52 +03:00
* dlg.h (struct Dlg_head): Separate user flags and internal
flags. Make "direction" a user flag. Adjust all dependencies. * dlg.c (run_dlg): Return ret_value.
This commit is contained in:
parent
815ee8d8e8
commit
27978d1b55
@ -1,3 +1,9 @@
|
|||||||
|
2002-08-24 Pavel Roskin <proski@gnu.org>
|
||||||
|
|
||||||
|
* dlg.h (struct Dlg_head): Separate user flags and internal
|
||||||
|
flags. Make "direction" a user flag. Adjust all dependencies.
|
||||||
|
* dlg.c (run_dlg): Return ret_value.
|
||||||
|
|
||||||
2002-08-23 Pavel Roskin <proski@gnu.org>
|
2002-08-23 Pavel Roskin <proski@gnu.org>
|
||||||
|
|
||||||
* text.c (default_edition_colors): Use more rxvt-friendly color
|
* text.c (default_edition_colors): Use more rxvt-friendly color
|
||||||
|
12
src/dlg.c
12
src/dlg.c
@ -202,7 +202,6 @@ Dlg_head *create_dlg (int y1, int x1, int lines, int cols,
|
|||||||
y1 -= 2;
|
y1 -= 2;
|
||||||
|
|
||||||
new_d = g_new0 (Dlg_head, 1);
|
new_d = g_new0 (Dlg_head, 1);
|
||||||
new_d->direction = DIR_FORWARD;
|
|
||||||
new_d->color = color_set;
|
new_d->color = color_set;
|
||||||
new_d->help_ctx = help_ctx;
|
new_d->help_ctx = help_ctx;
|
||||||
new_d->callback = callback ? callback : default_dlg_callback;
|
new_d->callback = callback ? callback : default_dlg_callback;
|
||||||
@ -381,16 +380,16 @@ int dlg_unfocus (Dlg_head *h)
|
|||||||
|
|
||||||
static void select_a_widget (Dlg_head *h, int down)
|
static void select_a_widget (Dlg_head *h, int down)
|
||||||
{
|
{
|
||||||
int direction = h->direction;
|
int dir_forward = !(h->flags & DLG_BACKWARD);
|
||||||
|
|
||||||
if (!h->current)
|
if (!h->current)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!down)
|
if (!down)
|
||||||
direction = !direction;
|
dir_forward = !dir_forward;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (direction)
|
if (dir_forward)
|
||||||
h->current = h->current->next;
|
h->current = h->current->next;
|
||||||
else
|
else
|
||||||
h->current = h->current->prev;
|
h->current = h->current->prev;
|
||||||
@ -763,7 +762,7 @@ void init_dlg (Dlg_head *h)
|
|||||||
h->refresh_pushed = 1;
|
h->refresh_pushed = 1;
|
||||||
|
|
||||||
/* Initialize direction */
|
/* Initialize direction */
|
||||||
if (!h->direction)
|
if (h->flags & DLG_BACKWARD)
|
||||||
h->current = h->first;
|
h->current = h->first;
|
||||||
|
|
||||||
if (h->initfocus != NULL)
|
if (h->initfocus != NULL)
|
||||||
@ -847,11 +846,12 @@ frontend_run_dlg (Dlg_head *h)
|
|||||||
* behavior on complex routines like the file routines, this way,
|
* behavior on complex routines like the file routines, this way,
|
||||||
* they can call the dlg_process_event without rewriting all the code
|
* they can call the dlg_process_event without rewriting all the code
|
||||||
*/
|
*/
|
||||||
void run_dlg (Dlg_head *h)
|
int run_dlg (Dlg_head *h)
|
||||||
{
|
{
|
||||||
init_dlg (h);
|
init_dlg (h);
|
||||||
frontend_run_dlg (h);
|
frontend_run_dlg (h);
|
||||||
dlg_run_done (h);
|
dlg_run_done (h);
|
||||||
|
return h->ret_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
61
src/dlg.h
61
src/dlg.h
@ -8,10 +8,6 @@
|
|||||||
#define HOT_NORMALC h->color[2]
|
#define HOT_NORMALC h->color[2]
|
||||||
#define HOT_FOCUSC h->color[3]
|
#define HOT_FOCUSC h->color[3]
|
||||||
|
|
||||||
/* Possible directions */
|
|
||||||
#define DIR_FORWARD 1
|
|
||||||
#define DIR_BACKWARD 0
|
|
||||||
|
|
||||||
/* Common return values */
|
/* Common return values */
|
||||||
#define B_EXIT 0
|
#define B_EXIT 0
|
||||||
#define B_CANCEL 1
|
#define B_CANCEL 1
|
||||||
@ -65,42 +61,38 @@ enum {
|
|||||||
DLG_PRE_EVENT /* Send before calling get_event */
|
DLG_PRE_EVENT /* Send before calling get_event */
|
||||||
} /* Dialog_Messages */;
|
} /* Dialog_Messages */;
|
||||||
|
|
||||||
typedef unsigned long widget_data;
|
|
||||||
typedef struct Dlg_head {
|
typedef struct Dlg_head {
|
||||||
int *color; /* color set */
|
|
||||||
int count; /* number of widgets */
|
|
||||||
int ret_value;
|
|
||||||
|
|
||||||
/* mouse status */
|
|
||||||
int mouse_status; /* For the autorepeat status of the mouse */
|
|
||||||
|
|
||||||
void *previous_dialog; /* Pointer to the previously running Dlg_head */
|
|
||||||
int refresh_pushed; /* Did the dialog actually run? */
|
|
||||||
|
|
||||||
/* position */
|
|
||||||
int x, y; /* Position relative to screen origin */
|
|
||||||
|
|
||||||
/* Flags */
|
|
||||||
int running;
|
|
||||||
int direction;
|
|
||||||
int send_idle_msg;
|
|
||||||
|
|
||||||
char *help_ctx;
|
|
||||||
|
|
||||||
/* Internal variables */
|
|
||||||
struct Widget_Item *current, *first, *last;
|
|
||||||
int (*callback) (struct Dlg_head *, int, int);
|
|
||||||
|
|
||||||
struct Widget_Item *initfocus;
|
|
||||||
|
|
||||||
|
/* Set by the user */
|
||||||
|
int flags; /* User flags */
|
||||||
|
char *help_ctx; /* Name of the help entry */
|
||||||
|
int *color; /* Color set */
|
||||||
char *title; /* Title of the dialog */
|
char *title; /* Title of the dialog */
|
||||||
|
|
||||||
int cols;
|
/* Set and received by the user */
|
||||||
int lines;
|
int ret_value; /* Result of run_dlg() */
|
||||||
|
|
||||||
|
/* Geometry */
|
||||||
|
int x, y; /* Position relative to screen origin */
|
||||||
|
int cols, lines; /* Width and height of the window */
|
||||||
|
|
||||||
|
/* Internal flags */
|
||||||
|
int running;
|
||||||
|
int send_idle_msg;
|
||||||
|
int mouse_status; /* For the autorepeat status of the mouse */
|
||||||
|
int refresh_pushed; /* Did the dialog actually run? */
|
||||||
|
|
||||||
|
/* Internal variables */
|
||||||
|
int count; /* number of widgets */
|
||||||
|
struct Widget_Item *current, *first, *last;
|
||||||
|
int (*callback) (struct Dlg_head *, int, int);
|
||||||
|
struct Widget_Item *initfocus;
|
||||||
|
void *previous_dialog; /* Pointer to the previously running Dlg_head */
|
||||||
|
|
||||||
int flags; /* Different flags, specified in create_dlg() */
|
|
||||||
} Dlg_head;
|
} Dlg_head;
|
||||||
|
|
||||||
|
|
||||||
/* Every Widget must have this as it's first element */
|
/* Every Widget must have this as it's first element */
|
||||||
typedef struct Widget {
|
typedef struct Widget {
|
||||||
int x, y;
|
int x, y;
|
||||||
@ -141,6 +133,7 @@ Dlg_head *create_dlg (int y1, int x1, int lines, int cols,
|
|||||||
char *help_ctx, char *name, int flags);
|
char *help_ctx, char *name, int flags);
|
||||||
|
|
||||||
/* The flags: */
|
/* The flags: */
|
||||||
|
#define DLG_BACKWARD 32 /* Tab order is reverse to the index order */
|
||||||
#define DLG_WANT_TAB 16 /* Should the tab key be sent to the dialog? */
|
#define DLG_WANT_TAB 16 /* Should the tab key be sent to the dialog? */
|
||||||
#define DLG_HAS_MENUBAR 8 /* GrossHack: Send events on row 1 to a menubar? */
|
#define DLG_HAS_MENUBAR 8 /* GrossHack: Send events on row 1 to a menubar? */
|
||||||
#define DLG_COMPACT 4 /* Suppress spaces around the frame */
|
#define DLG_COMPACT 4 /* Suppress spaces around the frame */
|
||||||
@ -153,7 +146,7 @@ int remove_widget (Dlg_head *dest, void *Widget);
|
|||||||
int destroy_widget (Widget *w);
|
int destroy_widget (Widget *w);
|
||||||
|
|
||||||
/* Runs dialog d */
|
/* Runs dialog d */
|
||||||
void run_dlg (Dlg_head *d);
|
int run_dlg (Dlg_head *d);
|
||||||
|
|
||||||
void dlg_run_done (Dlg_head *h);
|
void dlg_run_done (Dlg_head *h);
|
||||||
void dlg_process_event (Dlg_head *h, int key, Gpm_Event *event);
|
void dlg_process_event (Dlg_head *h, int key, Gpm_Event *event);
|
||||||
|
@ -211,15 +211,9 @@ int query_dialog (char *header, char *text, int flags, int count, ...)
|
|||||||
|
|
||||||
/* prepare dialog */
|
/* prepare dialog */
|
||||||
query_dlg = create_dlg (ypos, xpos, lines, cols, query_colors,
|
query_dlg = create_dlg (ypos, xpos, lines, cols, query_colors,
|
||||||
query_callback, "[QueryBox]", "query", DLG_NONE);
|
query_callback, "[QueryBox]", "query", DLG_BACKWARD);
|
||||||
x_set_dialog_title (query_dlg, header);
|
x_set_dialog_title (query_dlg, header);
|
||||||
|
|
||||||
/* The data we need to pass to the callback */
|
|
||||||
query_dlg->cols = cols;
|
|
||||||
query_dlg->lines = lines;
|
|
||||||
|
|
||||||
query_dlg->direction = DIR_BACKWARD;
|
|
||||||
|
|
||||||
if (count > 0){
|
if (count > 0){
|
||||||
|
|
||||||
cols = (cols-win_len-2)/2+2;
|
cols = (cols-win_len-2)/2+2;
|
||||||
|
Loading…
Reference in New Issue
Block a user