mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 04:46:55 +03:00
Merge branch '2919_group'
* 2919_group: (31 commits) Update po/*.po files. WGroup: support colors. WGroup: support state. Make WST_CONSTRUCT a default widget state. WGroup: support key events. Make keybind map a member of Widget. (dlg_key_event): clarify post-hotkey handling. WGroup: support mouse events. (widget_draw): support groups. Show console content only in midnight_callback (MSG_DRAW). WDialog: use WBackground in frameless dialogs (screens). Create WBackground widget. Create WFrame widget. WGroup: support draw. WDialog set/change size API: move to WGroup. Send new widget size as parameter of MSG_RESIZE message. WEdit: use WRect to save previous location. (dlg_set_position): use WRect. Create WRect class. Update cursor API: support groups. ...
This commit is contained in:
commit
a55b3fb684
@ -9,13 +9,17 @@
|
||||
/* main forward declarations */
|
||||
struct Widget;
|
||||
typedef struct Widget Widget;
|
||||
struct WDialog;
|
||||
typedef struct WDialog WDialog;
|
||||
struct WGroup;
|
||||
typedef struct WGroup WGroup;
|
||||
|
||||
/* Please note that the first element in all the widgets is a */
|
||||
/* widget variable of type Widget. We abuse this fact everywhere */
|
||||
|
||||
#include "lib/widget/rect.h"
|
||||
#include "lib/widget/widget-common.h"
|
||||
#include "lib/widget/group.h"
|
||||
#include "lib/widget/background.h"
|
||||
#include "lib/widget/frame.h"
|
||||
#include "lib/widget/dialog.h"
|
||||
#include "lib/widget/history.h"
|
||||
#include "lib/widget/button.h"
|
||||
|
@ -2,12 +2,15 @@
|
||||
noinst_LTLIBRARIES = libmcwidget.la
|
||||
|
||||
libmcwidget_la_SOURCES = \
|
||||
background.c background.h \
|
||||
button.c button.h \
|
||||
buttonbar.c buttonbar.h \
|
||||
check.c check.h \
|
||||
dialog.c dialog.h \
|
||||
dialog-switch.c dialog-switch.h \
|
||||
frame.c frame.h \
|
||||
gauge.c gauge.h \
|
||||
group.c group.h \
|
||||
groupbox.c groupbox.h \
|
||||
hline.c hline.h \
|
||||
history.c history.h \
|
||||
@ -20,6 +23,7 @@ libmcwidget_la_SOURCES = \
|
||||
mouse.c mouse.h \
|
||||
quick.c quick.h \
|
||||
radio.c radio.h \
|
||||
rect.c rect.h \
|
||||
widget-common.c widget-common.h \
|
||||
wtools.c wtools.h
|
||||
|
||||
|
128
lib/widget/background.c
Normal file
128
lib/widget/background.c
Normal file
@ -0,0 +1,128 @@
|
||||
/*
|
||||
Widgets for the Midnight Commander
|
||||
|
||||
Copyright (C) 2020
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Authors:
|
||||
Andrew Borodin <aborodin@vmail.ru>, 2020
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander is free software: you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
The Midnight Commander is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file hline.c
|
||||
* \brief Source: WBackground widget (background area of dialog)
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/tty/tty.h"
|
||||
#include "lib/tty/color.h"
|
||||
#include "lib/widget.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
/*** file scope macro definitions ****************************************************************/
|
||||
|
||||
/*** file scope type declarations ****************************************************************/
|
||||
|
||||
/*** file scope variables ************************************************************************/
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** file scope functions ************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static const int *
|
||||
background_get_colors (const Widget * w)
|
||||
{
|
||||
return &(CONST_BACKGROUND (w)->color);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
background_adjust (WBackground * b)
|
||||
{
|
||||
Widget *w = WIDGET (b);
|
||||
Widget *wo = WIDGET (w->owner);
|
||||
|
||||
w->y = wo->y;
|
||||
w->x = wo->x;
|
||||
w->lines = wo->lines;
|
||||
w->cols = wo->cols;
|
||||
|
||||
w->pos_flags |= WPOS_KEEP_ALL;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
background_draw (const WBackground * b)
|
||||
{
|
||||
const Widget *w = CONST_WIDGET (b);
|
||||
|
||||
tty_setcolor (b->color);
|
||||
tty_fill_region (w->y, w->x, w->lines, w->cols, b->pattern);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
cb_ret_t
|
||||
background_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
|
||||
{
|
||||
WBackground *b = BACKGROUND (w);
|
||||
|
||||
switch (msg)
|
||||
{
|
||||
case MSG_INIT:
|
||||
background_adjust (b);
|
||||
return MSG_HANDLED;
|
||||
|
||||
case MSG_DRAW:
|
||||
background_draw (b);
|
||||
return MSG_HANDLED;
|
||||
|
||||
default:
|
||||
return widget_default_callback (w, sender, msg, parm, data);
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
WBackground *
|
||||
background_new (int y, int x, int lines, int cols, int color, unsigned char pattern,
|
||||
widget_cb_fn callback)
|
||||
{
|
||||
WBackground *b;
|
||||
Widget *w;
|
||||
|
||||
b = g_new (WBackground, 1);
|
||||
w = WIDGET (b);
|
||||
widget_init (w, y, x, lines, cols, callback != NULL ? callback : background_callback, NULL);
|
||||
w->get_colors = background_get_colors;
|
||||
|
||||
b->color = color;
|
||||
b->pattern = pattern;
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
36
lib/widget/background.h
Normal file
36
lib/widget/background.h
Normal file
@ -0,0 +1,36 @@
|
||||
|
||||
/** \file background.h
|
||||
* \brief Header: WBackground widget
|
||||
*/
|
||||
|
||||
#ifndef MC__WIDGET_BACKGROUND_H
|
||||
#define MC__WIDGET_BACKGROUND_H
|
||||
|
||||
/*** typedefs(not structures) and defined constants **********************************************/
|
||||
|
||||
#define BACKGROUND(x) ((WBackground *)(x))
|
||||
#define CONST_BACKGROUND(x) ((const WBackground *)(x))
|
||||
|
||||
/*** enums ***************************************************************************************/
|
||||
|
||||
/*** structures declarations (and typedefs of structures)*****************************************/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Widget widget;
|
||||
|
||||
int color; /* Color to fill area */
|
||||
unsigned char pattern; /* Symbol to fill area */
|
||||
} WBackground;
|
||||
|
||||
/*** global variables defined in .c file *********************************************************/
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
WBackground *background_new (int y, int x, int lines, int cols, int color, unsigned char pattern,
|
||||
widget_cb_fn callback);
|
||||
cb_ret_t background_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data);
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
|
||||
#endif /* MC__WIDGET_BACKGROUND_H */
|
@ -62,7 +62,8 @@ cb_ret_t
|
||||
button_default_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
|
||||
{
|
||||
WButton *b = BUTTON (w);
|
||||
WDialog *h = w->owner;
|
||||
WGroup *g = w->owner;
|
||||
WDialog *h = DIALOG (g);
|
||||
int off = 0;
|
||||
|
||||
switch (msg)
|
||||
@ -74,7 +75,7 @@ button_default_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm
|
||||
* when hotkeys are sent to all widgets before the key is
|
||||
* handled by the current widget.
|
||||
*/
|
||||
if (parm == '\n' && WIDGET (h->current->data) == w)
|
||||
if (parm == '\n' && WIDGET (g->current->data) == w)
|
||||
{
|
||||
send_message (w, sender, MSG_KEY, ' ', data);
|
||||
return MSG_HANDLED;
|
||||
|
@ -44,7 +44,6 @@
|
||||
#include "lib/skin.h"
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/util.h"
|
||||
#include "lib/keybind.h" /* global_keymap_t */
|
||||
#include "lib/widget.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
@ -284,5 +283,5 @@ buttonbar_set_label (WButtonBar * bb, int idx, const char *text, const global_ke
|
||||
WButtonBar *
|
||||
find_buttonbar (const WDialog * h)
|
||||
{
|
||||
return BUTTONBAR (find_widget_type (h, buttonbar_callback));
|
||||
return BUTTONBAR (widget_find_by_type (CONST_WIDGET (h), buttonbar_callback));
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ dialog_switch_resize (WDialog * d)
|
||||
if (widget_get_state (WIDGET (d), WST_ACTIVE))
|
||||
send_message (d, NULL, MSG_RESIZE, 0, NULL);
|
||||
else
|
||||
d->winch_pending = TRUE;
|
||||
GROUP (d)->winch_pending = TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -293,7 +293,7 @@ dialog_switch_got_winch (void)
|
||||
|
||||
for (dlg = mc_dialogs; dlg != NULL; dlg = g_list_next (dlg))
|
||||
if (dlg != mc_current)
|
||||
DIALOG (dlg->data)->winch_pending = TRUE;
|
||||
GROUP (dlg->data)->winch_pending = TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -13,11 +13,11 @@
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/hook.h" /* hook_t */
|
||||
#include "lib/keybind.h" /* global_keymap_t */
|
||||
|
||||
/*** typedefs(not structures) and defined constants **********************************************/
|
||||
|
||||
#define DIALOG(x) ((WDialog *)(x))
|
||||
#define CONST_DIALOG(x) ((const WDialog *)(x))
|
||||
|
||||
/* Common return values */
|
||||
/* ATTENTION: avoid overlapping with FileProgressStatus values */
|
||||
@ -42,6 +42,8 @@ typedef enum
|
||||
|
||||
/*** typedefs(not structures) ********************************************************************/
|
||||
|
||||
typedef struct WDialog WDialog;
|
||||
|
||||
/* get string representation of shortcut assigned with command */
|
||||
/* as menu is a widget of dialog, ask dialog about shortcut string */
|
||||
typedef char *(*dlg_shortcut_str) (long command);
|
||||
@ -58,27 +60,20 @@ typedef cb_ret_t (*menu_exec_fn) (int command);
|
||||
|
||||
struct WDialog
|
||||
{
|
||||
Widget widget;
|
||||
WGroup group; /* base class */
|
||||
|
||||
/* Set by the user */
|
||||
gboolean compact; /* Suppress spaces around the frame */
|
||||
const char *help_ctx; /* Name of the help entry */
|
||||
const int *color; /* Color set. Unused in viewer and editor */
|
||||
char *title; /* Title of the dialog */
|
||||
const int *colors; /* Color set. Unused in viewer and editor */
|
||||
|
||||
/* Set and received by the user */
|
||||
int ret_value; /* Result of dlg_run() */
|
||||
|
||||
/* Internal flags */
|
||||
gboolean winch_pending; /* SIGWINCH signal has been got. Resize dialog after rise */
|
||||
int mouse_status; /* For the autorepeat status of the mouse */
|
||||
|
||||
/* Internal variables */
|
||||
GList *widgets; /* widgets list */
|
||||
GList *current; /* Currently active widget */
|
||||
unsigned long widget_id; /* maximum id of all widgets */
|
||||
void *data; /* Data can be passed to dialog */
|
||||
char *event_group; /* Name of event group for this dialog */
|
||||
Widget *bg; /* WFrame or WBackground */
|
||||
|
||||
dlg_shortcut_str get_shortcut; /* Shortcut string */
|
||||
dlg_title_str get_title; /* useless for modal dialogs */
|
||||
@ -111,18 +106,6 @@ WDialog *dlg_create (gboolean modal, int y1, int x1, int lines, int cols,
|
||||
|
||||
void dlg_set_default_colors (void);
|
||||
|
||||
unsigned long add_widget_autopos (WDialog * dest, void *w, widget_pos_flags_t pos_flags,
|
||||
const void *before);
|
||||
unsigned long add_widget (WDialog * dest, void *w);
|
||||
unsigned long add_widget_before (WDialog * h, void *w, void *before);
|
||||
void del_widget (void *w);
|
||||
|
||||
/* sets size of dialog, leaving positioning to automatic mehtods
|
||||
according to dialog flags */
|
||||
void dlg_set_size (WDialog * h, int lines, int cols);
|
||||
/* this function allows to set dialog position */
|
||||
void dlg_set_position (WDialog * h, int y, int x, int lines, int cols);
|
||||
|
||||
void dlg_init (WDialog * h);
|
||||
int dlg_run (WDialog * d);
|
||||
void dlg_destroy (WDialog * h);
|
||||
@ -131,67 +114,19 @@ void dlg_run_done (WDialog * h);
|
||||
void dlg_save_history (WDialog * h);
|
||||
void dlg_process_event (WDialog * h, int key, Gpm_Event * event);
|
||||
|
||||
void dlg_set_title (WDialog * h, const char *title);
|
||||
char *dlg_get_title (const WDialog * h, size_t len);
|
||||
|
||||
void dlg_draw (WDialog * h);
|
||||
|
||||
void dlg_broadcast_msg (WDialog * h, widget_msg_t message);
|
||||
|
||||
/* Default callback for dialogs */
|
||||
/* Default callbacks for dialogs */
|
||||
cb_ret_t dlg_default_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data);
|
||||
void dlg_default_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event);
|
||||
|
||||
/* Default paint routine for dialogs */
|
||||
void dlg_default_repaint (WDialog * h);
|
||||
|
||||
void dlg_erase (WDialog * h);
|
||||
void dlg_stop (WDialog * h);
|
||||
|
||||
/* Widget selection */
|
||||
void dlg_select_prev_widget (WDialog * h);
|
||||
void dlg_select_next_widget (WDialog * h);
|
||||
Widget *find_widget_type (const WDialog * h, widget_cb_fn callback);
|
||||
GList *dlg_find (const WDialog * h, const Widget * w);
|
||||
Widget *dlg_find_by_id (const WDialog * h, unsigned long id);
|
||||
void dlg_select_by_id (const WDialog * h, unsigned long id);
|
||||
|
||||
/* Redraw all dialogs */
|
||||
void do_refresh (void);
|
||||
|
||||
/* Used in load_prompt() */
|
||||
void update_cursor (WDialog * h);
|
||||
|
||||
void dlg_set_current_widget_next (WDialog * h);
|
||||
void dlg_set_current_widget_prev (WDialog * h);
|
||||
|
||||
GList *dlg_get_widget_next_of (GList * w);
|
||||
GList *dlg_get_widget_prev_of (GList * w);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** inline functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static inline unsigned long
|
||||
dlg_get_current_widget_id (const WDialog * h)
|
||||
{
|
||||
return WIDGET (h->current->data)->id;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Select current widget in the Dialog.
|
||||
*
|
||||
* @param h WDialog object
|
||||
*/
|
||||
|
||||
static inline void
|
||||
dlg_select_current_widget (WDialog * h)
|
||||
{
|
||||
if (h->current != NULL)
|
||||
widget_select (WIDGET (h->current->data));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
#endif /* MC__DIALOG_H */
|
||||
|
162
lib/widget/frame.c
Normal file
162
lib/widget/frame.c
Normal file
@ -0,0 +1,162 @@
|
||||
/*
|
||||
Widgets for the Midnight Commander
|
||||
|
||||
Copyright (C) 2020
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Authors:
|
||||
Andrew Borodin <aborodin@vmail.ru>, 2020
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander is free software: you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
The Midnight Commander is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file frame.c
|
||||
* \brief Source: WFrame widget (frame of dialogs)
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/tty/tty.h"
|
||||
#include "lib/tty/color.h"
|
||||
#include "lib/skin.h"
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/util.h" /* MC_PTR_FREE */
|
||||
#include "lib/widget.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
/*** file scope macro definitions ****************************************************************/
|
||||
|
||||
/*** file scope type declarations ****************************************************************/
|
||||
|
||||
/*** file scope variables ************************************************************************/
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** file scope functions ************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
frame_adjust (WFrame * f)
|
||||
{
|
||||
Widget *w = WIDGET (f);
|
||||
Widget *wo = WIDGET (w->owner);
|
||||
|
||||
w->y = wo->y;
|
||||
w->x = wo->x;
|
||||
w->lines = wo->lines;
|
||||
w->cols = wo->cols;
|
||||
|
||||
w->pos_flags |= WPOS_KEEP_ALL;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
frame_draw (const WFrame * f)
|
||||
{
|
||||
const Widget *w = CONST_WIDGET (f);
|
||||
int d = f->compact ? 0 : 1;
|
||||
const int *colors;
|
||||
|
||||
colors = widget_get_colors (w);
|
||||
|
||||
tty_setcolor (colors[FRAME_COLOR_NORMAL]);
|
||||
tty_fill_region (w->y, w->x, w->lines, w->cols, ' ');
|
||||
tty_draw_box (w->y + d, w->x + d, w->lines - 2 * d, w->cols - 2 * d, f->single);
|
||||
|
||||
if (f->title != NULL)
|
||||
{
|
||||
/* TODO: truncate long title */
|
||||
tty_setcolor (colors[FRAME_COLOR_TITLE]);
|
||||
widget_gotoyx (w, d, (w->cols - str_term_width1 (f->title)) / 2);
|
||||
tty_print_string (f->title);
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
WFrame *
|
||||
frame_new (int y, int x, int lines, int cols, const char *title, gboolean single, gboolean compact)
|
||||
{
|
||||
WFrame *f;
|
||||
Widget *w;
|
||||
|
||||
f = g_new (WFrame, 1);
|
||||
w = WIDGET (f);
|
||||
widget_init (w, y, x, lines, cols, frame_callback, NULL);
|
||||
|
||||
f->single = single;
|
||||
f->compact = compact;
|
||||
|
||||
f->title = NULL;
|
||||
frame_set_title (f, title);
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
cb_ret_t
|
||||
frame_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
|
||||
{
|
||||
WFrame *f = FRAME (w);
|
||||
|
||||
switch (msg)
|
||||
{
|
||||
case MSG_INIT:
|
||||
frame_adjust (f);
|
||||
return MSG_HANDLED;
|
||||
|
||||
case MSG_DRAW:
|
||||
frame_draw (f);
|
||||
return MSG_HANDLED;
|
||||
|
||||
case MSG_DESTROY:
|
||||
g_free (f->title);
|
||||
return MSG_HANDLED;
|
||||
|
||||
default:
|
||||
return widget_default_callback (w, sender, msg, parm, data);
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
frame_set_title (WFrame * f, const char *title)
|
||||
{
|
||||
MC_PTR_FREE (f->title);
|
||||
|
||||
/* Strip existing spaces, add one space before and after the title */
|
||||
if (title != NULL && *title != '\0')
|
||||
{
|
||||
char *t;
|
||||
|
||||
t = g_strstrip (g_strdup (title));
|
||||
if (*t != '\0')
|
||||
f->title = g_strdup_printf (" %s ", t);
|
||||
g_free (t);
|
||||
}
|
||||
|
||||
widget_draw (WIDGET (f));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
43
lib/widget/frame.h
Normal file
43
lib/widget/frame.h
Normal file
@ -0,0 +1,43 @@
|
||||
|
||||
/** \file frame.h
|
||||
* \brief Header: WFrame widget
|
||||
*/
|
||||
|
||||
#ifndef MC__WIDGET_FRAME_H
|
||||
#define MC__WIDGET_FRAME_H
|
||||
|
||||
/*** typedefs(not structures) and defined constants **********************************************/
|
||||
|
||||
#define FRAME(x) ((WFrame *)(x))
|
||||
#define CONST_FRAME(x) ((const WFrame *)(x))
|
||||
|
||||
#define FRAME_COLOR_NORMAL DLG_COLOR_NORMAL
|
||||
#define FRAME_COLOR_TITLE DLG_COLOR_TITLE
|
||||
|
||||
/*** enums ***************************************************************************************/
|
||||
|
||||
/*** typedefs(not structures) ********************************************************************/
|
||||
|
||||
/*** structures declarations (and typedefs of structures)*****************************************/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Widget widget;
|
||||
|
||||
char *title;
|
||||
gboolean single;
|
||||
gboolean compact;
|
||||
} WFrame;
|
||||
|
||||
/*** global variables defined in .c file *********************************************************/
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
WFrame *frame_new (int y, int x, int lines, int cols, const char *title, gboolean single,
|
||||
gboolean compact);
|
||||
cb_ret_t frame_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data);
|
||||
void frame_set_title (WFrame * f, const char *title);
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
|
||||
#endif /* MC__WIDGET_FRAME_H */
|
@ -58,15 +58,16 @@ static cb_ret_t
|
||||
gauge_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
|
||||
{
|
||||
WGauge *g = GAUGE (w);
|
||||
WDialog *h = w->owner;
|
||||
const int *colors;
|
||||
|
||||
switch (msg)
|
||||
{
|
||||
case MSG_DRAW:
|
||||
colors = widget_get_colors (w);
|
||||
widget_gotoyx (w, 0, 0);
|
||||
if (!g->shown)
|
||||
{
|
||||
tty_setcolor (h->color[DLG_COLOR_NORMAL]);
|
||||
tty_setcolor (colors[DLG_COLOR_NORMAL]);
|
||||
tty_printf ("%*s", w->cols, "");
|
||||
}
|
||||
else
|
||||
@ -98,16 +99,16 @@ gauge_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d
|
||||
{
|
||||
tty_setcolor (GAUGE_COLOR);
|
||||
tty_printf ("%*s", columns, "");
|
||||
tty_setcolor (h->color[DLG_COLOR_NORMAL]);
|
||||
tty_setcolor (colors[DLG_COLOR_NORMAL]);
|
||||
tty_printf ("%*s] %3d%%", gauge_len - columns, "", percentage);
|
||||
}
|
||||
else
|
||||
{
|
||||
tty_setcolor (h->color[DLG_COLOR_NORMAL]);
|
||||
tty_setcolor (colors[DLG_COLOR_NORMAL]);
|
||||
tty_printf ("%*s", gauge_len - columns, "");
|
||||
tty_setcolor (GAUGE_COLOR);
|
||||
tty_printf ("%*s", columns, "");
|
||||
tty_setcolor (h->color[DLG_COLOR_NORMAL]);
|
||||
tty_setcolor (colors[DLG_COLOR_NORMAL]);
|
||||
tty_printf ("] %3d%%", percentage);
|
||||
}
|
||||
}
|
||||
|
895
lib/widget/group.c
Normal file
895
lib/widget/group.c
Normal file
@ -0,0 +1,895 @@
|
||||
/*
|
||||
Widget group features module for the Midnight Commander
|
||||
|
||||
Copyright (C) 2020
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Andrew Borodin <aborodin@vmail.ru>, 2020
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander is free software: you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
The Midnight Commander is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file group.c
|
||||
* \brief Source: widget group features module
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
|
||||
#include "lib/tty/key.h" /* ALT() */
|
||||
|
||||
#include "lib/widget.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
/*** file scope macro definitions ****************************************************************/
|
||||
|
||||
/*** file scope type declarations ****************************************************************/
|
||||
|
||||
/* Control widget positions in a group */
|
||||
typedef struct
|
||||
{
|
||||
int shift_x;
|
||||
int scale_x;
|
||||
int shift_y;
|
||||
int scale_y;
|
||||
} widget_shift_scale_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
widget_state_t state;
|
||||
gboolean enable;
|
||||
} widget_state_info_t;
|
||||
|
||||
/*** file scope variables ************************************************************************/
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** file scope functions ************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
group_widget_init (void *data, void *user_data)
|
||||
{
|
||||
(void) user_data;
|
||||
|
||||
send_message (WIDGET (data), NULL, MSG_INIT, 0, NULL);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static GList *
|
||||
group_get_next_or_prev_of (GList * list, gboolean next)
|
||||
{
|
||||
GList *l = NULL;
|
||||
|
||||
if (list != NULL)
|
||||
{
|
||||
WGroup *owner = WIDGET (list->data)->owner;
|
||||
|
||||
if (owner != NULL)
|
||||
{
|
||||
if (next)
|
||||
{
|
||||
l = g_list_next (list);
|
||||
if (l == NULL)
|
||||
l = owner->widgets;
|
||||
}
|
||||
else
|
||||
{
|
||||
l = g_list_previous (list);
|
||||
if (l == NULL)
|
||||
l = g_list_last (owner->widgets);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
group_select_next_or_prev (WGroup * g, gboolean next)
|
||||
{
|
||||
if (g->widgets != NULL && g->current != NULL)
|
||||
{
|
||||
GList *l = g->current;
|
||||
Widget *w;
|
||||
|
||||
do
|
||||
{
|
||||
l = group_get_next_or_prev_of (l, next);
|
||||
w = WIDGET (l->data);
|
||||
}
|
||||
while ((widget_get_state (w, WST_DISABLED) || !widget_get_options (w, WOP_SELECTABLE))
|
||||
&& l != g->current);
|
||||
|
||||
widget_select (l->data);
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
group_widget_set_state (gpointer data, gpointer user_data)
|
||||
{
|
||||
widget_state_info_t *state = (widget_state_info_t *) user_data;
|
||||
|
||||
widget_set_state (WIDGET (data), state->state, state->enable);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Send broadcast message to all widgets in the group that have specified options.
|
||||
*
|
||||
* @param g WGroup object
|
||||
* @param msg message sent to widgets
|
||||
* @param reverse if TRUE, send message in reverse order, FALSE -- in direct one.
|
||||
* @param options if WOP_DEFAULT, the message is sent to all widgets. Else message is sent to widgets
|
||||
* that have specified options.
|
||||
*/
|
||||
|
||||
static void
|
||||
group_send_broadcast_msg_custom (WGroup * g, widget_msg_t msg, gboolean reverse,
|
||||
widget_options_t options)
|
||||
{
|
||||
GList *p, *first;
|
||||
|
||||
if (g->widgets == NULL)
|
||||
return;
|
||||
|
||||
if (g->current == NULL)
|
||||
g->current = g->widgets;
|
||||
|
||||
p = group_get_next_or_prev_of (g->current, !reverse);
|
||||
first = p;
|
||||
|
||||
do
|
||||
{
|
||||
Widget *w = WIDGET (p->data);
|
||||
|
||||
p = group_get_next_or_prev_of (p, !reverse);
|
||||
|
||||
if (options == WOP_DEFAULT || (options & w->options) != 0)
|
||||
send_message (w, NULL, msg, 0, NULL);
|
||||
}
|
||||
while (first != p);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Default group callback function to find widget in the group.
|
||||
*
|
||||
* @param w WGroup object
|
||||
* @param what widget to find
|
||||
*
|
||||
* @return holder of @what if found, NULL otherwise
|
||||
*/
|
||||
|
||||
static GList *
|
||||
group_default_find (const Widget * w, const Widget * what)
|
||||
{
|
||||
GList *w0;
|
||||
|
||||
w0 = widget_default_find (w, what);
|
||||
if (w0 == NULL)
|
||||
{
|
||||
GList *iter;
|
||||
|
||||
for (iter = GROUP (w)->widgets; iter != NULL; iter = g_list_next (iter))
|
||||
{
|
||||
w0 = widget_find (WIDGET (iter->data), what);
|
||||
if (w0 != NULL)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return w0;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Default group callback function to find widget in the group using widget callback.
|
||||
*
|
||||
* @param w WGroup object
|
||||
* @param cb widget callback
|
||||
*
|
||||
* @return widget object if found, NULL otherwise
|
||||
*/
|
||||
|
||||
static Widget *
|
||||
group_default_find_by_type (const Widget * w, widget_cb_fn cb)
|
||||
{
|
||||
Widget *w0;
|
||||
|
||||
w0 = widget_default_find_by_type (w, cb);
|
||||
if (w0 == NULL)
|
||||
{
|
||||
GList *iter;
|
||||
|
||||
for (iter = GROUP (w)->widgets; iter != NULL; iter = g_list_next (iter))
|
||||
{
|
||||
w0 = widget_find_by_type (WIDGET (iter->data), cb);
|
||||
if (w0 != NULL)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return w0;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Default group callback function to find widget by widget ID in the group.
|
||||
*
|
||||
* @param w WGroup object
|
||||
* @param id widget ID
|
||||
*
|
||||
* @return widget object if widget with specified id is found in group, NULL otherwise
|
||||
*/
|
||||
|
||||
static Widget *
|
||||
group_default_find_by_id (const Widget * w, unsigned long id)
|
||||
{
|
||||
Widget *w0;
|
||||
|
||||
w0 = widget_default_find_by_id (w, id);
|
||||
if (w0 == NULL)
|
||||
{
|
||||
GList *iter;
|
||||
|
||||
for (iter = GROUP (w)->widgets; iter != NULL; iter = g_list_next (iter))
|
||||
{
|
||||
w0 = widget_find_by_id (WIDGET (iter->data), id);
|
||||
if (w0 != NULL)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return w0;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Update cursor position in the active widget of the group.
|
||||
*
|
||||
* @param g WGroup object
|
||||
*
|
||||
* @return MSG_HANDLED if cursor was updated in the specified group, MSG_NOT_HANDLED otherwise
|
||||
*/
|
||||
|
||||
static cb_ret_t
|
||||
group_update_cursor (WGroup * g)
|
||||
{
|
||||
GList *p = g->current;
|
||||
|
||||
if (p != NULL && widget_get_state (WIDGET (g), WST_ACTIVE))
|
||||
do
|
||||
{
|
||||
Widget *w = WIDGET (p->data);
|
||||
|
||||
if (widget_get_options (w, WOP_WANT_CURSOR) && !widget_get_state (w, WST_DISABLED)
|
||||
&& widget_update_cursor (WIDGET (p->data)))
|
||||
return MSG_HANDLED;
|
||||
|
||||
p = group_get_widget_next_of (p);
|
||||
}
|
||||
while (p != g->current);
|
||||
|
||||
return MSG_NOT_HANDLED;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
group_widget_set_position (gpointer data, gpointer user_data)
|
||||
{
|
||||
/* there are, mainly, 2 generally possible situations:
|
||||
* 1. control sticks to one side - it should be moved
|
||||
* 2. control sticks to two sides of one direction - it should be sized
|
||||
*/
|
||||
|
||||
Widget *c = WIDGET (data);
|
||||
Widget *g = WIDGET (c->owner);
|
||||
const widget_shift_scale_t *wss = (const widget_shift_scale_t *) user_data;
|
||||
WRect r = { c->y, c->x, c->lines, c->cols };
|
||||
|
||||
if ((c->pos_flags & WPOS_CENTER_HORZ) != 0)
|
||||
r.x = g->x + (g->cols - c->cols) / 2;
|
||||
else if ((c->pos_flags & WPOS_KEEP_LEFT) != 0 && (c->pos_flags & WPOS_KEEP_RIGHT) != 0)
|
||||
{
|
||||
r.x += wss->shift_x;
|
||||
r.cols += wss->scale_x;
|
||||
}
|
||||
else if ((c->pos_flags & WPOS_KEEP_LEFT) != 0)
|
||||
r.x += wss->shift_x;
|
||||
else if ((c->pos_flags & WPOS_KEEP_RIGHT) != 0)
|
||||
r.x += wss->shift_x + wss->scale_x;
|
||||
|
||||
if ((c->pos_flags & WPOS_CENTER_VERT) != 0)
|
||||
r.y = g->y + (g->lines - c->lines) / 2;
|
||||
else if ((c->pos_flags & WPOS_KEEP_TOP) != 0 && (c->pos_flags & WPOS_KEEP_BOTTOM) != 0)
|
||||
{
|
||||
r.y += wss->shift_y;
|
||||
r.lines += wss->scale_y;
|
||||
}
|
||||
else if ((c->pos_flags & WPOS_KEEP_TOP) != 0)
|
||||
r.y += wss->shift_y;
|
||||
else if ((c->pos_flags & WPOS_KEEP_BOTTOM) != 0)
|
||||
r.y += wss->shift_y + wss->scale_y;
|
||||
|
||||
send_message (c, NULL, MSG_RESIZE, 0, &r);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
group_set_position (WGroup * g, const WRect * r)
|
||||
{
|
||||
Widget *w = WIDGET (g);
|
||||
widget_shift_scale_t wss;
|
||||
/* save old positions, will be used to reposition childs */
|
||||
WRect or = { w->y, w->x, w->lines, w->cols };
|
||||
|
||||
w->x = r->x;
|
||||
w->y = r->y;
|
||||
w->lines = r->lines;
|
||||
w->cols = r->cols;
|
||||
|
||||
/* dialog is empty */
|
||||
if (g->widgets == NULL)
|
||||
return;
|
||||
|
||||
if (g->current == NULL)
|
||||
g->current = g->widgets;
|
||||
|
||||
/* values by which controls should be moved */
|
||||
wss.shift_x = w->x - or.x;
|
||||
wss.scale_x = w->cols - or.cols;
|
||||
wss.shift_y = w->y - or.y;
|
||||
wss.scale_y = w->lines - or.lines;
|
||||
|
||||
if (wss.shift_x != 0 || wss.shift_y != 0 || wss.scale_x != 0 || wss.scale_y != 0)
|
||||
g_list_foreach (g->widgets, group_widget_set_position, &wss);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
group_default_resize (WGroup * g, WRect * r)
|
||||
{
|
||||
/* This is default resizing mechanism.
|
||||
* The main idea of this code is to resize dialog according to flags
|
||||
* (if any of flags require automatic resizing, like WPOS_CENTER,
|
||||
* end after that reposition controls in dialog according to flags of widget)
|
||||
*/
|
||||
|
||||
Widget *w = WIDGET (g);
|
||||
WRect r0;
|
||||
|
||||
if (r == NULL)
|
||||
rect_init (&r0, w->y, w->x, w->lines, w->cols);
|
||||
else
|
||||
r0 = *r;
|
||||
|
||||
widget_adjust_position (w->pos_flags, &r0.y, &r0.x, &r0.lines, &r0.cols);
|
||||
group_set_position (g, &r0);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
group_draw (WGroup * g)
|
||||
{
|
||||
Widget *wg = WIDGET (g);
|
||||
|
||||
/* draw all widgets in Z-order, from first to last */
|
||||
if (widget_get_state (wg, WST_ACTIVE))
|
||||
{
|
||||
GList *p;
|
||||
|
||||
if (g->winch_pending)
|
||||
{
|
||||
g->winch_pending = FALSE;
|
||||
send_message (wg, NULL, MSG_RESIZE, 0, NULL);
|
||||
}
|
||||
|
||||
for (p = g->widgets; p != NULL; p = g_list_next (p))
|
||||
widget_draw (WIDGET (p->data));
|
||||
|
||||
widget_update_cursor (wg);
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static cb_ret_t
|
||||
group_handle_key (WGroup * g, int key)
|
||||
{
|
||||
cb_ret_t handled;
|
||||
|
||||
/* first try the hotkey */
|
||||
handled = send_message (g, NULL, MSG_HOTKEY, key, NULL);
|
||||
|
||||
/* not used - then try widget_callback */
|
||||
if (handled == MSG_NOT_HANDLED)
|
||||
handled = send_message (g->current->data, NULL, MSG_KEY, key, NULL);
|
||||
|
||||
/* not used - try to use the unhandled case */
|
||||
if (handled == MSG_NOT_HANDLED)
|
||||
handled = send_message (g, g->current->data, MSG_UNHANDLED_KEY, key, NULL);
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static cb_ret_t
|
||||
group_handle_hotkey (WGroup * g, int key)
|
||||
{
|
||||
GList *current;
|
||||
Widget *w;
|
||||
cb_ret_t handled = MSG_NOT_HANDLED;
|
||||
int c;
|
||||
|
||||
if (g->widgets == NULL)
|
||||
return MSG_NOT_HANDLED;
|
||||
|
||||
if (g->current == NULL)
|
||||
g->current = g->widgets;
|
||||
|
||||
w = WIDGET (g->current->data);
|
||||
|
||||
if (widget_get_state (w, WST_DISABLED))
|
||||
return MSG_NOT_HANDLED;
|
||||
|
||||
/* Explanation: we don't send letter hotkeys to other widgets
|
||||
* if the currently selected widget is an input line */
|
||||
if (widget_get_options (w, WOP_IS_INPUT))
|
||||
{
|
||||
/* skip ascii control characters, anything else can valid character in some encoding */
|
||||
if (key >= 32 && key < 256)
|
||||
return MSG_NOT_HANDLED;
|
||||
}
|
||||
|
||||
/* If it's an alt key, send the message */
|
||||
c = key & ~ALT (0);
|
||||
if (key & ALT (0) && g_ascii_isalpha (c))
|
||||
key = g_ascii_tolower (c);
|
||||
|
||||
if (widget_get_options (w, WOP_WANT_HOTKEY))
|
||||
handled = send_message (w, NULL, MSG_HOTKEY, key, NULL);
|
||||
|
||||
/* If not used, send hotkey to other widgets */
|
||||
if (handled == MSG_HANDLED)
|
||||
return MSG_HANDLED;
|
||||
|
||||
current = group_get_widget_next_of (g->current);
|
||||
|
||||
/* send it to all widgets */
|
||||
while (g->current != current && handled == MSG_NOT_HANDLED)
|
||||
{
|
||||
w = WIDGET (current->data);
|
||||
|
||||
if (widget_get_options (w, WOP_WANT_HOTKEY) && !widget_get_state (w, WST_DISABLED))
|
||||
handled = send_message (w, NULL, MSG_HOTKEY, key, NULL);
|
||||
|
||||
if (handled == MSG_NOT_HANDLED)
|
||||
current = group_get_widget_next_of (current);
|
||||
}
|
||||
|
||||
if (handled == MSG_HANDLED)
|
||||
{
|
||||
w = WIDGET (current->data);
|
||||
widget_select (w);
|
||||
send_message (g, w, MSG_HOTKEY_HANDLED, 0, NULL);
|
||||
}
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Initialize group.
|
||||
*
|
||||
* @param g WGroup widget
|
||||
* @param y1 y-coordinate of top-left corner
|
||||
* @param x1 x-coordinate of top-left corner
|
||||
* @param lines group height
|
||||
* @param cols group width
|
||||
* @param callback group callback
|
||||
* @param mouse_callback group mouse handler
|
||||
*/
|
||||
|
||||
void
|
||||
group_init (WGroup * g, int y1, int x1, int lines, int cols, widget_cb_fn callback,
|
||||
widget_mouse_cb_fn mouse_callback)
|
||||
{
|
||||
Widget *w = WIDGET (g);
|
||||
|
||||
widget_init (w, y1, x1, lines, cols, callback != NULL ? callback : group_default_callback,
|
||||
mouse_callback);
|
||||
|
||||
w->mouse_handler = group_handle_mouse_event;
|
||||
|
||||
w->find = group_default_find;
|
||||
w->find_by_type = group_default_find_by_type;
|
||||
w->find_by_id = group_default_find_by_id;
|
||||
|
||||
w->set_state = group_default_set_state;
|
||||
|
||||
g->mouse_status = MOU_UNHANDLED;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
cb_ret_t
|
||||
group_default_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
|
||||
{
|
||||
WGroup *g = GROUP (w);
|
||||
|
||||
switch (msg)
|
||||
{
|
||||
case MSG_INIT:
|
||||
g_list_foreach (g->widgets, group_widget_init, NULL);
|
||||
return MSG_HANDLED;
|
||||
|
||||
case MSG_DRAW:
|
||||
group_draw (g);
|
||||
return MSG_HANDLED;
|
||||
|
||||
case MSG_KEY:
|
||||
return group_handle_key (g, parm);
|
||||
|
||||
case MSG_HOTKEY:
|
||||
return group_handle_hotkey (g, parm);
|
||||
|
||||
case MSG_CURSOR:
|
||||
return group_update_cursor (g);
|
||||
|
||||
case MSG_RESIZE:
|
||||
group_default_resize (g, RECT (data));
|
||||
return MSG_HANDLED;
|
||||
|
||||
case MSG_DESTROY:
|
||||
g_list_foreach (g->widgets, (GFunc) widget_destroy, NULL);
|
||||
g_list_free (g->widgets);
|
||||
return MSG_HANDLED;
|
||||
|
||||
default:
|
||||
return widget_default_callback (w, sender, msg, parm, data);
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Change state of group.
|
||||
*
|
||||
* @param w group
|
||||
* @param state widget state flag to modify
|
||||
* @param enable specifies whether to turn the flag on (TRUE) or off (FALSE).
|
||||
* Only one flag per call can be modified.
|
||||
* @return MSG_HANDLED if set was handled successfully, MSG_NOT_HANDLED otherwise.
|
||||
*/
|
||||
cb_ret_t
|
||||
group_default_set_state (Widget * w, widget_state_t state, gboolean enable)
|
||||
{
|
||||
gboolean ret = MSG_HANDLED;
|
||||
WGroup *g = GROUP (w);
|
||||
widget_state_info_t st = {
|
||||
.state = state,
|
||||
.enable = enable
|
||||
};
|
||||
|
||||
ret = widget_default_set_state (w, state, enable);
|
||||
|
||||
if (state == WST_ACTIVE || state == WST_SUSPENDED || state == WST_CLOSED)
|
||||
/* inform all child widgets */
|
||||
g_list_foreach (g->widgets, group_widget_set_state, &st);
|
||||
|
||||
if ((w->state & WST_ACTIVE) != 0)
|
||||
{
|
||||
if ((w->state & WST_FOCUSED) != 0)
|
||||
{
|
||||
/* update current widget */
|
||||
if (g->current != NULL)
|
||||
widget_set_state (WIDGET (g->current->data), WST_FOCUSED, enable);
|
||||
}
|
||||
else
|
||||
/* inform all child widgets */
|
||||
g_list_foreach (g->widgets, group_widget_set_state, &st);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Handling mouse events.
|
||||
*
|
||||
* @param g WGroup object
|
||||
* @param event GPM mouse event
|
||||
*
|
||||
* @return result of mouse event handling
|
||||
*/
|
||||
int
|
||||
group_handle_mouse_event (Widget * w, Gpm_Event * event)
|
||||
{
|
||||
WGroup *g = GROUP (w);
|
||||
|
||||
if (g->widgets != NULL)
|
||||
{
|
||||
GList *p;
|
||||
|
||||
/* send the event to widgets in reverse Z-order */
|
||||
p = g_list_last (g->widgets);
|
||||
do
|
||||
{
|
||||
Widget *wp = WIDGET (p->data);
|
||||
|
||||
if (!widget_get_state (wp, WST_DISABLED))
|
||||
{
|
||||
/* put global cursor position to the widget */
|
||||
int ret;
|
||||
|
||||
ret = wp->mouse_handler (wp, event);
|
||||
if (ret != MOU_UNHANDLED)
|
||||
return ret;
|
||||
}
|
||||
|
||||
p = g_list_previous (p);
|
||||
}
|
||||
while (p != NULL);
|
||||
}
|
||||
|
||||
return MOU_UNHANDLED;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Insert widget to group before specified widget with specified positioning.
|
||||
* Make the inserted widget current.
|
||||
*
|
||||
* @param g WGroup object
|
||||
* @param w widget to be added
|
||||
* @pos positioning flags
|
||||
* @param before add @w before this widget
|
||||
*
|
||||
* @return widget ID
|
||||
*/
|
||||
|
||||
unsigned long
|
||||
group_add_widget_autopos (WGroup * g, void *w, widget_pos_flags_t pos_flags, const void *before)
|
||||
{
|
||||
Widget *wg = WIDGET (g);
|
||||
Widget *ww = WIDGET (w);
|
||||
GList *new_current;
|
||||
|
||||
/* Don't accept NULL widget. This shouldn't happen */
|
||||
assert (ww != NULL);
|
||||
|
||||
if ((pos_flags & WPOS_CENTER_HORZ) != 0)
|
||||
ww->x = (wg->cols - ww->cols) / 2;
|
||||
ww->x += wg->x;
|
||||
|
||||
if ((pos_flags & WPOS_CENTER_VERT) != 0)
|
||||
ww->y = (wg->lines - ww->lines) / 2;
|
||||
ww->y += wg->y;
|
||||
|
||||
ww->owner = g;
|
||||
ww->pos_flags = pos_flags;
|
||||
|
||||
if (g->widgets == NULL || before == NULL)
|
||||
{
|
||||
g->widgets = g_list_append (g->widgets, ww);
|
||||
new_current = g_list_last (g->widgets);
|
||||
}
|
||||
else
|
||||
{
|
||||
GList *b;
|
||||
|
||||
b = g_list_find (g->widgets, before);
|
||||
|
||||
/* don't accept widget not from group. This shouldn't happen */
|
||||
assert (b != NULL);
|
||||
|
||||
b = g_list_next (b);
|
||||
g->widgets = g_list_insert_before (g->widgets, b, ww);
|
||||
if (b != NULL)
|
||||
new_current = g_list_previous (b);
|
||||
else
|
||||
new_current = g_list_last (g->widgets);
|
||||
}
|
||||
|
||||
/* widget has been added at runtime */
|
||||
if (widget_get_state (wg, WST_ACTIVE))
|
||||
{
|
||||
group_widget_init (ww, NULL);
|
||||
widget_select (ww);
|
||||
}
|
||||
else
|
||||
g->current = new_current;
|
||||
|
||||
return ww->id;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Remove widget from group.
|
||||
*
|
||||
* @param w Widget object
|
||||
*/
|
||||
void
|
||||
group_remove_widget (void *w)
|
||||
{
|
||||
WGroup *g;
|
||||
GList *d;
|
||||
|
||||
/* Don't accept NULL widget. This shouldn't happen */
|
||||
assert (w != NULL);
|
||||
|
||||
g = WIDGET (w)->owner;
|
||||
|
||||
d = g_list_find (g->widgets, w);
|
||||
if (d == g->current)
|
||||
group_set_current_widget_next (g);
|
||||
|
||||
g->widgets = g_list_delete_link (g->widgets, d);
|
||||
if (g->widgets == NULL)
|
||||
g->current = NULL;
|
||||
|
||||
/* widget has been deleted at runtime */
|
||||
if (widget_get_state (WIDGET (g), WST_ACTIVE))
|
||||
{
|
||||
group_draw (g);
|
||||
group_select_current_widget (g);
|
||||
}
|
||||
|
||||
WIDGET (w)->owner = NULL;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Switch current widget to widget after current in group.
|
||||
*
|
||||
* @param g WGroup object
|
||||
*/
|
||||
|
||||
void
|
||||
group_set_current_widget_next (WGroup * g)
|
||||
{
|
||||
g->current = group_get_next_or_prev_of (g->current, TRUE);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Switch current widget to widget before current in group.
|
||||
*
|
||||
* @param g WGroup object
|
||||
*/
|
||||
|
||||
void
|
||||
group_set_current_widget_prev (WGroup * g)
|
||||
{
|
||||
g->current = group_get_next_or_prev_of (g->current, FALSE);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Get widget that is after specified widget in group.
|
||||
*
|
||||
* @param w widget holder
|
||||
*
|
||||
* @return widget that is after "w" or NULL if "w" is NULL or widget doesn't have owner
|
||||
*/
|
||||
|
||||
GList *
|
||||
group_get_widget_next_of (GList * w)
|
||||
{
|
||||
return group_get_next_or_prev_of (w, TRUE);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Get widget that is before specified widget in group.
|
||||
*
|
||||
* @param w widget holder
|
||||
*
|
||||
* @return widget that is before "w" or NULL if "w" is NULL or widget doesn't have owner
|
||||
*/
|
||||
|
||||
GList *
|
||||
group_get_widget_prev_of (GList * w)
|
||||
{
|
||||
return group_get_next_or_prev_of (w, FALSE);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Try to select next widget in the Z order.
|
||||
*
|
||||
* @param g WGroup object
|
||||
*/
|
||||
|
||||
void
|
||||
group_select_next_widget (WGroup * g)
|
||||
{
|
||||
group_select_next_or_prev (g, TRUE);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Try to select previous widget in the Z order.
|
||||
*
|
||||
* @param g WGroup object
|
||||
*/
|
||||
|
||||
void
|
||||
group_select_prev_widget (WGroup * g)
|
||||
{
|
||||
group_select_next_or_prev (g, FALSE);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Find the widget with the specified ID in the group and select it
|
||||
*
|
||||
* @param g WGroup object
|
||||
* @param id widget ID
|
||||
*/
|
||||
|
||||
void
|
||||
group_select_widget_by_id (const WGroup * g, unsigned long id)
|
||||
{
|
||||
Widget *w;
|
||||
|
||||
w = widget_find_by_id (CONST_WIDGET (g), id);
|
||||
if (w != NULL)
|
||||
widget_select (w);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Send broadcast message to all widgets in the group.
|
||||
*
|
||||
* @param g WGroup object
|
||||
* @param msg message sent to widgets
|
||||
*/
|
||||
|
||||
void
|
||||
group_send_broadcast_msg (WGroup * g, widget_msg_t msg)
|
||||
{
|
||||
group_send_broadcast_msg_custom (g, msg, FALSE, WOP_DEFAULT);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
125
lib/widget/group.h
Normal file
125
lib/widget/group.h
Normal file
@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Widget group features module for Midnight Commander
|
||||
*/
|
||||
|
||||
/** \file group.h
|
||||
* \brief Header: widget group features module
|
||||
*/
|
||||
|
||||
#ifndef MC__GROUP_H
|
||||
#define MC__GROUP_H
|
||||
|
||||
#include "lib/global.h"
|
||||
|
||||
/*** typedefs(not structures) and defined constants **********************************************/
|
||||
|
||||
#define GROUP(x) ((WGroup *)(x))
|
||||
#define CONST_GROUP(x) ((const WGroup *)(x))
|
||||
|
||||
/*** enums ***************************************************************************************/
|
||||
|
||||
/*** typedefs(not structures) ********************************************************************/
|
||||
|
||||
/*** structures declarations (and typedefs of structures)*****************************************/
|
||||
|
||||
struct WGroup
|
||||
{
|
||||
Widget widget;
|
||||
|
||||
/* Group members */
|
||||
GList *widgets; /* widgets list */
|
||||
GList *current; /* Currently active widget */
|
||||
|
||||
gboolean winch_pending; /* SIGWINCH signal has been got. Resize group after rise */
|
||||
int mouse_status; /* For the autorepeat status of the mouse */
|
||||
};
|
||||
|
||||
/*** global variables defined in .c file *********************************************************/
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
void group_init (WGroup * g, int y1, int x1, int lines, int cols, widget_cb_fn callback,
|
||||
widget_mouse_cb_fn mouse_callback);
|
||||
/* Default callback for groups */
|
||||
cb_ret_t group_default_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm,
|
||||
void *data);
|
||||
cb_ret_t group_default_set_state (Widget * w, widget_state_t state, gboolean enable);
|
||||
int group_handle_mouse_event (Widget * w, Gpm_Event * event);
|
||||
|
||||
unsigned long group_add_widget_autopos (WGroup * g, void *w, widget_pos_flags_t pos_flags,
|
||||
const void *before);
|
||||
void group_remove_widget (void *w);
|
||||
|
||||
void group_set_current_widget_next (WGroup * g);
|
||||
void group_set_current_widget_prev (WGroup * g);
|
||||
|
||||
GList *group_get_widget_next_of (GList * w);
|
||||
GList *group_get_widget_prev_of (GList * w);
|
||||
|
||||
void group_select_next_widget (WGroup * g);
|
||||
void group_select_prev_widget (WGroup * g);
|
||||
|
||||
void group_select_widget_by_id (const WGroup * g, unsigned long id);
|
||||
|
||||
void group_send_broadcast_msg (WGroup * g, widget_msg_t message);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** inline functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Add widget to group before current widget.
|
||||
*
|
||||
* @param g WGroup object
|
||||
* @param w widget to be added
|
||||
*
|
||||
* @return widget ID
|
||||
*/
|
||||
|
||||
static inline unsigned long
|
||||
group_add_widget (WGroup * g, void *w)
|
||||
{
|
||||
return group_add_widget_autopos (g, w, WPOS_KEEP_DEFAULT,
|
||||
g->current != NULL ? g->current->data : NULL);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Add widget to group before specified widget.
|
||||
*
|
||||
* @param g WGroup object
|
||||
* @param w widget to be added
|
||||
* @param before add @w before this widget
|
||||
*
|
||||
* @return widget ID
|
||||
*/
|
||||
|
||||
static inline unsigned long
|
||||
group_add_widget_before (WGroup * g, void *w, void *before)
|
||||
{
|
||||
return group_add_widget_autopos (g, w, WPOS_KEEP_DEFAULT, before);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Select current widget in the Dialog.
|
||||
*
|
||||
* @param h WDialog object
|
||||
*/
|
||||
|
||||
static inline void
|
||||
group_select_current_widget (WGroup * g)
|
||||
{
|
||||
if (g->current != NULL)
|
||||
widget_select (WIDGET (g->current->data));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static inline unsigned long
|
||||
group_get_current_widget_id (const WGroup * g)
|
||||
{
|
||||
return WIDGET (g->current->data)->id;
|
||||
}
|
||||
|
||||
#endif /* MC__GROUP_H */
|
@ -61,17 +61,18 @@ groupbox_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void
|
||||
{
|
||||
case MSG_DRAW:
|
||||
{
|
||||
WDialog *h = w->owner;
|
||||
|
||||
gboolean disabled;
|
||||
const int *colors;
|
||||
|
||||
colors = widget_get_colors (w);
|
||||
|
||||
disabled = widget_get_state (w, WST_DISABLED);
|
||||
tty_setcolor (disabled ? DISABLED_COLOR : h->color[DLG_COLOR_NORMAL]);
|
||||
tty_setcolor (disabled ? DISABLED_COLOR : colors[DLG_COLOR_NORMAL]);
|
||||
tty_draw_box (w->y, w->x, w->lines, w->cols, TRUE);
|
||||
|
||||
if (g->title != NULL)
|
||||
{
|
||||
tty_setcolor (disabled ? DISABLED_COLOR : h->color[DLG_COLOR_TITLE]);
|
||||
tty_setcolor (disabled ? DISABLED_COLOR : colors[DLG_COLOR_TITLE]);
|
||||
widget_gotoyx (w, 0, 1);
|
||||
tty_print_string (g->title);
|
||||
}
|
||||
|
@ -70,6 +70,7 @@ history_dlg_reposition (WDialog * dlg_head)
|
||||
{
|
||||
history_dlg_data *data;
|
||||
int x = 0, y, he, wi;
|
||||
WRect r;
|
||||
|
||||
/* guard checks */
|
||||
if ((dlg_head == NULL) || (dlg_head->data == NULL))
|
||||
@ -102,9 +103,9 @@ history_dlg_reposition (WDialog * dlg_head)
|
||||
x = COLS - wi;
|
||||
}
|
||||
|
||||
dlg_set_position (dlg_head, y, x, he, wi);
|
||||
rect_init (&r, y, x, he, wi);
|
||||
|
||||
return MSG_HANDLED;
|
||||
return dlg_default_callback (WIDGET (dlg_head), NULL, MSG_RESIZE, 0, &r);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -230,7 +231,7 @@ history_show (history_descriptor_t * hd)
|
||||
|
||||
/* this call makes list stick to all sides of dialog, effectively make
|
||||
it be resized with dialog */
|
||||
add_widget_autopos (query_dlg, hd->listbox, WPOS_KEEP_ALL, NULL);
|
||||
group_add_widget_autopos (GROUP (query_dlg), hd->listbox, WPOS_KEEP_ALL, NULL);
|
||||
|
||||
/* to avoid diplicating of (calculating sizes in two places)
|
||||
code, call history_dlg_callback function here, to set dialog and
|
||||
|
@ -51,40 +51,59 @@
|
||||
|
||||
/*** file scope variables ************************************************************************/
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** file scope functions ************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
hline_adjust_cols (WHLine * l)
|
||||
{
|
||||
if (l->auto_adjust_cols)
|
||||
{
|
||||
Widget *w = WIDGET (l);
|
||||
Widget *wo = WIDGET (w->owner);
|
||||
|
||||
if (DIALOG (wo)->compact)
|
||||
{
|
||||
w->x = wo->x;
|
||||
w->cols = wo->cols;
|
||||
}
|
||||
else
|
||||
{
|
||||
w->x = wo->x + 1;
|
||||
w->cols = wo->cols - 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static cb_ret_t
|
||||
hline_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
|
||||
{
|
||||
WHLine *l = HLINE (w);
|
||||
WDialog *h = w->owner;
|
||||
|
||||
switch (msg)
|
||||
{
|
||||
case MSG_INIT:
|
||||
case MSG_RESIZE:
|
||||
if (l->auto_adjust_cols)
|
||||
{
|
||||
Widget *wo = WIDGET (h);
|
||||
hline_adjust_cols (l);
|
||||
return MSG_HANDLED;
|
||||
|
||||
if (h->compact)
|
||||
{
|
||||
w->x = wo->x;
|
||||
w->cols = wo->cols;
|
||||
}
|
||||
else
|
||||
{
|
||||
w->x = wo->x + 1;
|
||||
w->cols = wo->cols - 2;
|
||||
}
|
||||
}
|
||||
case MSG_RESIZE:
|
||||
hline_adjust_cols (l);
|
||||
w->y = RECT (data)->y;
|
||||
return MSG_HANDLED;
|
||||
|
||||
case MSG_DRAW:
|
||||
if (l->transparent)
|
||||
tty_setcolor (DEFAULT_COLOR);
|
||||
else
|
||||
tty_setcolor (h->color[DLG_COLOR_NORMAL]);
|
||||
{
|
||||
const int *colors;
|
||||
|
||||
colors = widget_get_colors (w);
|
||||
tty_setcolor (colors[DLG_COLOR_NORMAL]);
|
||||
}
|
||||
|
||||
tty_draw_hline (w->y, w->x + 1, ACS_HLINE, w->cols - 2);
|
||||
|
||||
|
@ -46,7 +46,6 @@
|
||||
#include "lib/skin.h"
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/util.h"
|
||||
#include "lib/keybind.h" /* global_keymap_t */
|
||||
#include "lib/widget.h"
|
||||
#include "lib/event.h" /* mc_event_raise() */
|
||||
#include "lib/mcconfig.h" /* mc_config_history_*() */
|
||||
@ -874,7 +873,7 @@ input_save_history (const gchar * event_group_name, const gchar * event_name,
|
||||
(void) event_group_name;
|
||||
(void) event_name;
|
||||
|
||||
if (!in->is_password && (WIDGET (in)->owner->ret_value != B_CANCEL))
|
||||
if (!in->is_password && (DIALOG (WIDGET (in)->owner)->ret_value != B_CANCEL))
|
||||
{
|
||||
ev_history_load_save_t *ev = (ev_history_load_save_t *) data;
|
||||
|
||||
@ -998,6 +997,7 @@ input_new (int y, int x, const int *colors, int width, const char *def_text,
|
||||
w = WIDGET (in);
|
||||
widget_init (w, y, x, 1, width, input_callback, input_mouse_callback);
|
||||
w->options |= WOP_SELECTABLE | WOP_IS_INPUT | WOP_WANT_CURSOR;
|
||||
w->keymap = input_map;
|
||||
|
||||
in->color = colors;
|
||||
in->first = TRUE;
|
||||
@ -1042,15 +1042,16 @@ cb_ret_t
|
||||
input_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
|
||||
{
|
||||
WInput *in = INPUT (w);
|
||||
WDialog *h = DIALOG (w->owner);
|
||||
cb_ret_t v;
|
||||
|
||||
switch (msg)
|
||||
{
|
||||
case MSG_INIT:
|
||||
/* subscribe to "history_load" event */
|
||||
mc_event_add (w->owner->event_group, MCEVENT_HISTORY_LOAD, input_load_history, w, NULL);
|
||||
mc_event_add (h->event_group, MCEVENT_HISTORY_LOAD, input_load_history, w, NULL);
|
||||
/* subscribe to "history_save" event */
|
||||
mc_event_add (w->owner->event_group, MCEVENT_HISTORY_SAVE, input_save_history, w, NULL);
|
||||
mc_event_add (h->event_group, MCEVENT_HISTORY_SAVE, input_save_history, w, NULL);
|
||||
if (in->label != NULL)
|
||||
widget_set_state (WIDGET (in->label), WST_DISABLED, widget_get_state (w, WST_DISABLED));
|
||||
return MSG_HANDLED;
|
||||
@ -1099,9 +1100,9 @@ input_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d
|
||||
|
||||
case MSG_DESTROY:
|
||||
/* unsubscribe from "history_load" event */
|
||||
mc_event_del (w->owner->event_group, MCEVENT_HISTORY_LOAD, input_load_history, w);
|
||||
mc_event_del (h->event_group, MCEVENT_HISTORY_LOAD, input_load_history, w);
|
||||
/* unsubscribe from "history_save" event */
|
||||
mc_event_del (w->owner->event_group, MCEVENT_HISTORY_SAVE, input_save_history, w);
|
||||
mc_event_del (h->event_group, MCEVENT_HISTORY_SAVE, input_save_history, w);
|
||||
input_destroy (in);
|
||||
return MSG_HANDLED;
|
||||
|
||||
@ -1138,8 +1139,7 @@ input_handle_char (WInput * in, int key)
|
||||
return v;
|
||||
}
|
||||
|
||||
command = keybind_lookup_keymap_command (input_map, key);
|
||||
|
||||
command = widget_lookup_key (WIDGET (in), key);
|
||||
if (command == CK_IgnoreKey)
|
||||
{
|
||||
if (key > 255)
|
||||
@ -1173,9 +1173,7 @@ input_key_is_in_map (WInput * in, int key)
|
||||
{
|
||||
long command;
|
||||
|
||||
(void) in;
|
||||
|
||||
command = keybind_lookup_keymap_command (input_map, key);
|
||||
command = widget_lookup_key (WIDGET (in), key);
|
||||
if (command == CK_IgnoreKey)
|
||||
return 0;
|
||||
|
||||
|
@ -8,8 +8,6 @@
|
||||
|
||||
#include <limits.h> /* MB_LEN_MAX */
|
||||
|
||||
#include "lib/keybind.h" /* global_keymap_t */
|
||||
|
||||
/*** typedefs(not structures) and defined constants **********************************************/
|
||||
|
||||
#define INPUT(x) ((WInput *)(x))
|
||||
|
@ -1019,6 +1019,7 @@ query_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d
|
||||
{
|
||||
static int bl = 0;
|
||||
|
||||
WGroup *g = GROUP (w);
|
||||
WDialog *h = DIALOG (w);
|
||||
|
||||
switch (msg)
|
||||
@ -1057,17 +1058,17 @@ query_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d
|
||||
|
||||
new_end = str_get_prev_char (&input->buffer[end]) - input->buffer;
|
||||
|
||||
for (i = 0, e = listbox_get_first_link (LISTBOX (h->current->data));
|
||||
for (i = 0, e = listbox_get_first_link (LISTBOX (g->current->data));
|
||||
e != NULL; i++, e = g_list_next (e))
|
||||
{
|
||||
WLEntry *le = LENTRY (e->data);
|
||||
|
||||
if (strncmp (input->buffer + start, le->text, new_end - start) == 0)
|
||||
{
|
||||
listbox_select_entry (LISTBOX (h->current->data), i);
|
||||
listbox_select_entry (LISTBOX (g->current->data), i);
|
||||
end = new_end;
|
||||
input_handle_char (input, parm);
|
||||
widget_draw (WIDGET (h->current->data));
|
||||
widget_draw (WIDGET (g->current->data));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1111,7 +1112,7 @@ query_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d
|
||||
break;
|
||||
}
|
||||
|
||||
for (i = 0, e = listbox_get_first_link (LISTBOX (h->current->data));
|
||||
for (i = 0, e = listbox_get_first_link (LISTBOX (g->current->data));
|
||||
e != NULL; i++, e = g_list_next (e))
|
||||
{
|
||||
WLEntry *le = LENTRY (e->data);
|
||||
@ -1122,7 +1123,7 @@ query_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d
|
||||
if (need_redraw == 0)
|
||||
{
|
||||
need_redraw = 1;
|
||||
listbox_select_entry (LISTBOX (h->current->data), i);
|
||||
listbox_select_entry (LISTBOX (g->current->data), i);
|
||||
last_text = le->text;
|
||||
}
|
||||
else
|
||||
@ -1173,7 +1174,7 @@ query_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d
|
||||
if (need_redraw == 2)
|
||||
{
|
||||
insert_text (input, last_text, low);
|
||||
widget_draw (WIDGET (h->current->data));
|
||||
widget_draw (WIDGET (g->current->data));
|
||||
}
|
||||
else if (need_redraw == 1)
|
||||
{
|
||||
@ -1267,7 +1268,7 @@ complete_engine (WInput * in, int what_to_do)
|
||||
query_dlg = dlg_create (TRUE, y, x, query_height, query_width, WPOS_KEEP_DEFAULT, TRUE,
|
||||
dialog_colors, query_callback, NULL, "[Completion]", NULL);
|
||||
query_list = listbox_new (1, 1, h - 2, w - 2, FALSE, NULL);
|
||||
add_widget (query_dlg, query_list);
|
||||
group_add_widget (GROUP (query_dlg), query_list);
|
||||
|
||||
for (p = in->completions + 1; *p != NULL; p++)
|
||||
listbox_add_item (query_list, LISTBOX_APPEND_AT_END, 0, *p, NULL, FALSE);
|
||||
|
@ -60,7 +60,6 @@ static cb_ret_t
|
||||
label_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
|
||||
{
|
||||
WLabel *l = LABEL (w);
|
||||
WDialog *h = w->owner;
|
||||
|
||||
switch (msg)
|
||||
{
|
||||
@ -79,7 +78,12 @@ label_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d
|
||||
if (l->transparent)
|
||||
tty_setcolor (disabled ? DISABLED_COLOR : DEFAULT_COLOR);
|
||||
else
|
||||
tty_setcolor (disabled ? DISABLED_COLOR : h->color[DLG_COLOR_NORMAL]);
|
||||
{
|
||||
const int *colors;
|
||||
|
||||
colors = widget_get_colors (w);
|
||||
tty_setcolor (disabled ? DISABLED_COLOR : colors[DLG_COLOR_NORMAL]);
|
||||
}
|
||||
|
||||
align = (w->pos_flags & WPOS_CENTER_HORZ) != 0 ? J_CENTER_LEFT : J_LEFT;
|
||||
|
||||
|
@ -109,7 +109,7 @@ create_listbox_window_centered (int center_y, int center_x, int lines, int cols,
|
||||
NULL, NULL, help, title);
|
||||
|
||||
listbox->list = listbox_new (2, 2, lines, cols, FALSE, NULL);
|
||||
add_widget (listbox->dlg, listbox->list);
|
||||
group_add_widget (GROUP (listbox->dlg), listbox->list);
|
||||
|
||||
return listbox;
|
||||
}
|
||||
|
@ -42,7 +42,6 @@
|
||||
#include "lib/skin.h"
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/util.h" /* Q_() */
|
||||
#include "lib/keybind.h" /* global_keymap_t */
|
||||
#include "lib/widget.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
@ -131,7 +130,7 @@ static void
|
||||
listbox_draw (WListbox * l, gboolean focused)
|
||||
{
|
||||
Widget *w = WIDGET (l);
|
||||
const WDialog *h = w->owner;
|
||||
const int *colors;
|
||||
gboolean disabled;
|
||||
int normalc, selc;
|
||||
int length = 0;
|
||||
@ -140,15 +139,11 @@ listbox_draw (WListbox * l, gboolean focused)
|
||||
int i;
|
||||
int sel_line = -1;
|
||||
|
||||
colors = widget_get_colors (w);
|
||||
|
||||
disabled = widget_get_state (w, WST_DISABLED);
|
||||
normalc = disabled ? DISABLED_COLOR : h->color[DLG_COLOR_NORMAL];
|
||||
/* *INDENT-OFF* */
|
||||
selc = disabled
|
||||
? DISABLED_COLOR
|
||||
: focused
|
||||
? h->color[DLG_COLOR_HOT_FOCUS]
|
||||
: h->color[DLG_COLOR_FOCUS];
|
||||
/* *INDENT-ON* */
|
||||
normalc = disabled ? DISABLED_COLOR : colors[DLG_COLOR_NORMAL];
|
||||
selc = disabled ? DISABLED_COLOR : colors[focused ? DLG_COLOR_HOT_FOCUS : DLG_COLOR_FOCUS];
|
||||
|
||||
if (l->list != NULL)
|
||||
{
|
||||
@ -355,7 +350,7 @@ listbox_key (WListbox * l, int key)
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
|
||||
command = keybind_lookup_keymap_command (listbox_map, key);
|
||||
command = widget_lookup_key (WIDGET (l), key);
|
||||
if (command == CK_IgnoreKey)
|
||||
return MSG_NOT_HANDLED;
|
||||
return listbox_execute_cmd (l, command);
|
||||
@ -423,7 +418,7 @@ listbox_do_action (WListbox * l)
|
||||
|
||||
if (action == LISTBOX_DONE)
|
||||
{
|
||||
WDialog *h = WIDGET (l)->owner;
|
||||
WDialog *h = DIALOG (WIDGET (l)->owner);
|
||||
|
||||
h->ret_value = B_ENTER;
|
||||
dlg_stop (h);
|
||||
@ -492,9 +487,6 @@ listbox_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void
|
||||
listbox_destroy (l);
|
||||
return MSG_HANDLED;
|
||||
|
||||
case MSG_RESIZE:
|
||||
return MSG_HANDLED;
|
||||
|
||||
default:
|
||||
return widget_default_callback (w, sender, msg, parm, data);
|
||||
}
|
||||
@ -562,6 +554,7 @@ listbox_new (int y, int x, int height, int width, gboolean deletable, lcback_fn
|
||||
w = WIDGET (l);
|
||||
widget_init (w, y, x, height, width, listbox_callback, listbox_mouse_callback);
|
||||
w->options |= WOP_SELECTABLE | WOP_WANT_HOTKEY;
|
||||
w->keymap = listbox_map;
|
||||
|
||||
l->list = NULL;
|
||||
l->top = l->pos = 0;
|
||||
|
@ -6,8 +6,6 @@
|
||||
#ifndef MC__WIDGET_LISTBOX_H
|
||||
#define MC__WIDGET_LISTBOX_H
|
||||
|
||||
#include "lib/keybind.h" /* global_keymap_t */
|
||||
|
||||
/*** typedefs(not structures) and defined constants **********************************************/
|
||||
|
||||
#define LISTBOX(x) ((WListbox *)(x))
|
||||
|
@ -39,7 +39,6 @@
|
||||
#include "lib/tty/tty.h"
|
||||
#include "lib/skin.h"
|
||||
#include "lib/tty/key.h" /* key macros */
|
||||
#include "lib/keybind.h" /* global_keymap_t */
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/widget.h"
|
||||
#include "lib/event.h" /* mc_event_raise() */
|
||||
@ -257,7 +256,7 @@ menubar_draw (const WMenuBar * menubar)
|
||||
static void
|
||||
menubar_remove (WMenuBar * menubar)
|
||||
{
|
||||
WDialog *h;
|
||||
Widget *g;
|
||||
|
||||
if (!menubar->is_dropped)
|
||||
return;
|
||||
@ -266,15 +265,15 @@ menubar_remove (WMenuBar * menubar)
|
||||
of overlapped widgets. This is useful in multi-window editor.
|
||||
In general, menubar should be a special object, not an ordinary widget
|
||||
in the current dialog. */
|
||||
h = WIDGET (menubar)->owner;
|
||||
h->current = g_list_find (h->widgets, dlg_find_by_id (h, menubar->previous_widget));
|
||||
g = WIDGET (WIDGET (menubar)->owner);
|
||||
GROUP (g)->current = widget_find (g, widget_find_by_id (g, menubar->previous_widget));
|
||||
|
||||
menubar->is_dropped = FALSE;
|
||||
do_refresh ();
|
||||
menubar->is_dropped = TRUE;
|
||||
|
||||
/* restore current widget */
|
||||
h->current = g_list_find (h->widgets, menubar);
|
||||
GROUP (g)->current = widget_find (g, WIDGET (menubar));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -316,8 +315,11 @@ menubar_finish (WMenuBar * menubar)
|
||||
/* Move the menubar to the bottom so that widgets displayed on top of
|
||||
* an "invisible" menubar get the first chance to respond to mouse events. */
|
||||
widget_set_bottom (w);
|
||||
/* background must be bottom */
|
||||
if (DIALOG (w->owner)->bg != NULL)
|
||||
widget_set_bottom (WIDGET (DIALOG (w->owner)->bg));
|
||||
|
||||
dlg_select_by_id (w->owner, menubar->previous_widget);
|
||||
group_select_widget_by_id (w->owner, menubar->previous_widget);
|
||||
do_refresh ();
|
||||
}
|
||||
|
||||
@ -586,7 +588,7 @@ menubar_handle_key (WMenuBar * menubar, int key)
|
||||
unsigned long cmd;
|
||||
cb_ret_t ret = MSG_NOT_HANDLED;
|
||||
|
||||
cmd = keybind_lookup_keymap_command (menu_map, key);
|
||||
cmd = widget_lookup_key (WIDGET (menubar), key);
|
||||
|
||||
if (cmd != CK_IgnoreKey)
|
||||
ret = menubar_execute_cmd (menubar, cmd);
|
||||
@ -670,6 +672,7 @@ menubar_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void
|
||||
|
||||
case MSG_RESIZE:
|
||||
/* try show menu after screen resize */
|
||||
widget_default_callback (w, NULL, MSG_RESIZE, 0, data);
|
||||
menubar_refresh (menubar);
|
||||
return MSG_HANDLED;
|
||||
|
||||
@ -946,6 +949,7 @@ menubar_new (GList * menu, gboolean visible)
|
||||
/* initially, menubar is not selectable */
|
||||
widget_set_options (w, WOP_SELECTABLE, FALSE);
|
||||
w->options |= WOP_TOP_SELECT;
|
||||
w->keymap = menu_map;
|
||||
menubar->is_visible = visible;
|
||||
menubar_set_menu (menubar, menu);
|
||||
|
||||
@ -974,7 +978,7 @@ menubar_add_menu (WMenuBar * menubar, menu_t * menu)
|
||||
{
|
||||
if (menu != NULL)
|
||||
{
|
||||
menu_arrange (menu, WIDGET (menubar)->owner->get_shortcut);
|
||||
menu_arrange (menu, DIALOG (WIDGET (menubar)->owner)->get_shortcut);
|
||||
menubar->menu = g_list_append (menubar->menu, menu);
|
||||
}
|
||||
|
||||
@ -1039,7 +1043,7 @@ menubar_arrange (WMenuBar * menubar)
|
||||
WMenuBar *
|
||||
find_menubar (const WDialog * h)
|
||||
{
|
||||
return MENUBAR (find_widget_type (h, menubar_callback));
|
||||
return MENUBAR (widget_find_by_type (CONST_WIDGET (h), menubar_callback));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -1065,7 +1069,7 @@ menubar_activate (WMenuBar * menubar, gboolean dropped, int which)
|
||||
if (which >= 0)
|
||||
menubar->selected = (guint) which;
|
||||
|
||||
menubar->previous_widget = dlg_get_current_widget_id (w->owner);
|
||||
menubar->previous_widget = group_get_current_widget_id (w->owner);
|
||||
|
||||
/* Bring it to the top so it receives all mouse events before any other widget.
|
||||
* See also comment in menubar_finish(). */
|
||||
|
@ -69,8 +69,6 @@ init_mouse_event (mouse_event_t * event, mouse_msg_t msg, const Gpm_Event * glob
|
||||
event->result.repeat = FALSE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
@ -81,7 +79,7 @@ init_mouse_event (mouse_event_t * event, mouse_msg_t msg, const Gpm_Event * glob
|
||||
*
|
||||
* @return high level mouse event
|
||||
*/
|
||||
mouse_event_t
|
||||
static mouse_event_t
|
||||
mouse_translate_event (Widget * w, Gpm_Event * event)
|
||||
{
|
||||
gboolean in_widget;
|
||||
@ -172,7 +170,7 @@ mouse_translate_event (Widget * w, Gpm_Event * event)
|
||||
*
|
||||
* @return result of mouse event handling
|
||||
*/
|
||||
int
|
||||
static int
|
||||
mouse_process_event (Widget * w, mouse_event_t * event)
|
||||
{
|
||||
int ret = MOU_UNHANDLED;
|
||||
@ -201,4 +199,27 @@ mouse_process_event (Widget * w, mouse_event_t * event)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Translate GPM event to high-level event and process it
|
||||
*
|
||||
* @param w Widget object
|
||||
* @param event GPM event
|
||||
*
|
||||
* @return result of mouse event handling
|
||||
*/
|
||||
int
|
||||
mouse_handle_event (Widget * w, Gpm_Event * event)
|
||||
{
|
||||
mouse_event_t me;
|
||||
|
||||
me = mouse_translate_event (w, event);
|
||||
|
||||
return mouse_process_event (w, &me);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -57,10 +57,8 @@ typedef struct
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
/* Translate GPM event to high-level event */
|
||||
mouse_event_t mouse_translate_event (Widget * w, Gpm_Event * event);
|
||||
/* Process high-level mouse event */
|
||||
int mouse_process_event (Widget * w, mouse_event_t * event);
|
||||
/* Translate GPM event to high-level event and process it */
|
||||
int mouse_handle_event (Widget * w, Gpm_Event * event);
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
|
||||
|
@ -564,14 +564,19 @@ quick_dialog_skip (quick_dialog_t * quick_dlg, int nskip)
|
||||
/* add widget into dialog */
|
||||
item->widget->options |= item->quick_widget->options; /* FIXME: cannot reset flags, setup only */
|
||||
item->widget->state |= item->quick_widget->state; /* FIXME: cannot reset flags, setup only */
|
||||
id = add_widget_autopos (dd, item->widget, item->quick_widget->pos_flags, NULL);
|
||||
id = group_add_widget_autopos (GROUP (dd), item->widget, item->quick_widget->pos_flags,
|
||||
NULL);
|
||||
if (item->quick_widget->id != NULL)
|
||||
*item->quick_widget->id = id;
|
||||
}
|
||||
}
|
||||
|
||||
/* skip frame widget */
|
||||
if (dd->bg != NULL)
|
||||
nskip++;
|
||||
|
||||
while (nskip-- != 0)
|
||||
dlg_set_current_widget_next (dd);
|
||||
group_set_current_widget_next (GROUP (dd));
|
||||
|
||||
return_val = dlg_run (dd);
|
||||
|
||||
|
231
lib/widget/rect.c
Normal file
231
lib/widget/rect.c
Normal file
@ -0,0 +1,231 @@
|
||||
/* Rectangular class for Midnight Commander widgets
|
||||
|
||||
Copyright (C) 2020
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Andrew Borodin <aborodin@vmail.ru>, 2020
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander is free software: you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
The Midnight Commander is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file widget-common.c
|
||||
* \brief Source: shared stuff of widgets
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
|
||||
#include "rect.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
/*** file scope macro definitions ****************************************************************/
|
||||
|
||||
/*** file scope type declarations ****************************************************************/
|
||||
|
||||
/*** file scope variables ************************************************************************/
|
||||
|
||||
/*** file scope functions ************************************************************************/
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Create new WRect object.
|
||||
*
|
||||
* @param y y-coordinate of left-up corner
|
||||
* @param x x-coordinate of left-up corner
|
||||
* @param lines heigth
|
||||
* @param cols width
|
||||
*
|
||||
* @return newly allocated WRect object.
|
||||
*/
|
||||
|
||||
WRect *
|
||||
rect_new (int y, int x, int lines, int cols)
|
||||
{
|
||||
WRect *r;
|
||||
|
||||
r = g_try_new (WRect, 1);
|
||||
|
||||
if (r != NULL)
|
||||
rect_init (r, y, x, lines, cols);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Initialize WRect object.
|
||||
*
|
||||
* @param r WRect object
|
||||
* @param y y-coordinate of left-up corner
|
||||
* @param x x-coordinate of left-up corner
|
||||
* @param lines heigth
|
||||
* @param cols width
|
||||
*/
|
||||
|
||||
void
|
||||
rect_init (WRect * r, int y, int x, int lines, int cols)
|
||||
{
|
||||
r->y = y;
|
||||
r->x = x;
|
||||
r->lines = lines;
|
||||
r->cols = cols;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Change position of rectangle area.
|
||||
*
|
||||
* @param r WRect object
|
||||
* @param dy y-shift of left-up corner
|
||||
* @param dx x-shift of left-up corner
|
||||
*/
|
||||
|
||||
void
|
||||
rect_move (WRect * r, int dy, int dx)
|
||||
{
|
||||
r->y += dy;
|
||||
r->x += dx;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Change size of rectangle area.
|
||||
*
|
||||
* @param r WRect object
|
||||
* @param dl change size value of heigth
|
||||
* @param dc change size value of width
|
||||
*/
|
||||
|
||||
void
|
||||
rect_resize (WRect * r, int dl, int dc)
|
||||
{
|
||||
r->lines += dl;
|
||||
r->cols += dc;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Calculates the intersection of two rectangle areas.
|
||||
* The resulting rectangle is the largest rectangle which contains intersection of rectangle areas.
|
||||
*
|
||||
* @param r first WRect object
|
||||
* @param r1 second WRect object
|
||||
*
|
||||
* The resulting rectangle is stored in r.
|
||||
*/
|
||||
|
||||
void
|
||||
rect_intersect (WRect * r, const WRect * r1)
|
||||
{
|
||||
int y, x;
|
||||
int y1, x1;
|
||||
|
||||
/* right-down corners */
|
||||
y = r->y + r->lines;
|
||||
x = r->x + r->cols;
|
||||
y1 = r1->y + r1->lines;
|
||||
x1 = r1->x + r1->cols;
|
||||
|
||||
/* right-down corner of intersection */
|
||||
y = MIN (y, y1);
|
||||
x = MIN (x, x1);
|
||||
|
||||
/* left-up corner of intersection */
|
||||
r->y = MAX (r->y, r1->y);
|
||||
r->x = MAX (r->x, r1->x);
|
||||
|
||||
/* intersection sizes */
|
||||
r->lines = y - r->y;
|
||||
r->cols = x - r->x;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Calculates the union of two rectangle areas.
|
||||
* The resulting rectangle is the largest rectangle which contains both rectangle areas.
|
||||
*
|
||||
* @param r first WRect object
|
||||
* @param r1 second WRect object
|
||||
*
|
||||
* The resulting rectangle is stored in r.
|
||||
*/
|
||||
|
||||
void
|
||||
rect_union (WRect * r, const WRect * r1)
|
||||
{
|
||||
int x, y;
|
||||
int x1, y1;
|
||||
|
||||
/* right-down corners */
|
||||
y = r->y + r->lines;
|
||||
x = r->x + r->cols;
|
||||
y1 = r1->y + r1->lines;
|
||||
x1 = r1->x + r1->cols;
|
||||
|
||||
/* right-down corner of union */
|
||||
y = MAX (y, y1);
|
||||
x = MAX (x, x1);
|
||||
|
||||
/* left-up corner of union */
|
||||
r->y = MIN (r->y, r1->y);
|
||||
r->x = MIN (r->x, r1->x);
|
||||
|
||||
/* union sizes */
|
||||
r->lines = y - r->y;
|
||||
r->cols = x - r->x;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Check whether two rectangle areas are overlapped or not.
|
||||
*
|
||||
* @param r1 WRect object
|
||||
* @param r2 WRect object
|
||||
*
|
||||
* @return TRUE if rectangle areas are overlapped, FALSE otherwise.
|
||||
*/
|
||||
|
||||
gboolean
|
||||
rects_are_overlapped (const WRect * r1, const WRect * r2)
|
||||
{
|
||||
return !((r2->x >= r1->x + r1->cols) || (r1->x >= r2->x + r2->cols)
|
||||
|| (r2->y >= r1->y + r1->lines) || (r1->y >= r2->y + r2->lines));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Check whether two rectangle areas are equal or not.
|
||||
*
|
||||
* @param r1 WRect object
|
||||
* @param r2 WRect object
|
||||
*
|
||||
* @return TRUE if rectangle areas are equal, FALSE otherwise.
|
||||
*/
|
||||
|
||||
gboolean
|
||||
rects_are_equal (const WRect * r1, const WRect * r2)
|
||||
{
|
||||
return (r1->y == r2->y && r1->x == r2->x && r1->lines == r2->lines && r1->cols == r2->cols);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
44
lib/widget/rect.h
Normal file
44
lib/widget/rect.h
Normal file
@ -0,0 +1,44 @@
|
||||
|
||||
/** \file rect.h
|
||||
* \brief Header: rectangular class
|
||||
*/
|
||||
|
||||
#ifndef MC__WIDGET_RECT_H
|
||||
#define MC__WIDGET_RECT_H
|
||||
|
||||
/*** typedefs (not structures) and defined constants *********************************************/
|
||||
|
||||
#define RECT(x) ((WRect *)(x))
|
||||
#define CONST_RECT(x) ((const WRect *)(x))
|
||||
|
||||
/*** enums ***************************************************************************************/
|
||||
|
||||
/*** structures declarations (and typedefs of structures) ****************************************/
|
||||
|
||||
struct WRect;
|
||||
typedef struct WRect WRect;
|
||||
|
||||
struct WRect
|
||||
{
|
||||
int y;
|
||||
int x;
|
||||
int lines;
|
||||
int cols;
|
||||
};
|
||||
|
||||
/*** global variables defined in .c file *********************************************************/
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
WRect *rect_new (int y, int x, int lines, int cols);
|
||||
void rect_init (WRect * r, int y, int x, int lines, int cols);
|
||||
void rect_move (WRect * r, int dy, int dx);
|
||||
void rect_resize (WRect * r, int dl, int dc);
|
||||
void rect_intersect (WRect * r, const WRect * r1);
|
||||
void rect_union (WRect * r, const WRect * r1);
|
||||
gboolean rects_are_overlapped (const WRect * r1, const WRect * r2);
|
||||
gboolean rects_are_equal (const WRect * r1, const WRect * r2);
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
|
||||
#endif /* MC__WIDGET_RECT_H */
|
@ -53,10 +53,48 @@
|
||||
|
||||
/*** file scope variables ************************************************************************/
|
||||
|
||||
/* maximum value of used widget ID */
|
||||
static unsigned long widget_id = 0;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** file scope functions ************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Calc widget ID,
|
||||
* Widget ID is uniq for each widget created during MC session (like PID in OS).
|
||||
*
|
||||
* @return widget ID.
|
||||
*/
|
||||
static unsigned long
|
||||
widget_set_id (void)
|
||||
{
|
||||
unsigned long id;
|
||||
|
||||
id = widget_id++;
|
||||
/* TODO IF NEEDED: if id is already used, find next free id. */
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static cb_ret_t
|
||||
widget_default_resize (Widget * w, const WRect * r)
|
||||
{
|
||||
if (r == NULL)
|
||||
return MSG_NOT_HANDLED;
|
||||
|
||||
w->y = r->y;
|
||||
w->x = r->x;
|
||||
w->lines = r->lines;
|
||||
w->cols = r->cols;
|
||||
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
widget_do_focus (Widget * w, gboolean enable)
|
||||
{
|
||||
@ -74,19 +112,19 @@ widget_do_focus (Widget * w, gboolean enable)
|
||||
static void
|
||||
widget_focus (Widget * w)
|
||||
{
|
||||
WDialog *h = DIALOG (w->owner);
|
||||
WGroup *g = w->owner;
|
||||
|
||||
if (h == NULL)
|
||||
if (g == NULL)
|
||||
return;
|
||||
|
||||
if (WIDGET (h->current->data) != w)
|
||||
if (WIDGET (g->current->data) != w)
|
||||
{
|
||||
widget_do_focus (WIDGET (h->current->data), FALSE);
|
||||
widget_do_focus (WIDGET (g->current->data), FALSE);
|
||||
/* Test if focus lost was allowed and focus has really been loose */
|
||||
if (h->current == NULL || !widget_get_state (WIDGET (h->current->data), WST_FOCUSED))
|
||||
if (g->current == NULL || !widget_get_state (WIDGET (g->current->data), WST_FOCUSED))
|
||||
{
|
||||
widget_do_focus (w, TRUE);
|
||||
h->current = dlg_find (h, w);
|
||||
g->current = widget_find (WIDGET (g), w);
|
||||
}
|
||||
}
|
||||
else if (!widget_get_state (w, WST_FOCUSED))
|
||||
@ -101,13 +139,13 @@ widget_focus (Widget * w)
|
||||
static void
|
||||
widget_reorder (GList * l, gboolean set_top)
|
||||
{
|
||||
WDialog *h = WIDGET (l->data)->owner;
|
||||
WGroup *g = WIDGET (l->data)->owner;
|
||||
|
||||
h->widgets = g_list_remove_link (h->widgets, l);
|
||||
g->widgets = g_list_remove_link (g->widgets, l);
|
||||
if (set_top)
|
||||
h->widgets = g_list_concat (h->widgets, l);
|
||||
g->widgets = g_list_concat (g->widgets, l);
|
||||
else
|
||||
h->widgets = g_list_concat (l, h->widgets);
|
||||
g->widgets = g_list_concat (l, g->widgets);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -129,6 +167,16 @@ hotkey_cmp (const char *s1, const char *s2)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static const int *
|
||||
widget_default_get_colors (const Widget * w)
|
||||
{
|
||||
const Widget *owner = CONST_WIDGET (w->owner);
|
||||
|
||||
return (owner == NULL ? NULL : widget_get_colors (owner));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -252,21 +300,35 @@ void
|
||||
widget_init (Widget * w, int y, int x, int lines, int cols,
|
||||
widget_cb_fn callback, widget_mouse_cb_fn mouse_callback)
|
||||
{
|
||||
w->id = widget_set_id ();
|
||||
w->x = x;
|
||||
w->y = y;
|
||||
w->cols = cols;
|
||||
w->lines = lines;
|
||||
w->pos_flags = WPOS_KEEP_DEFAULT;
|
||||
w->callback = callback;
|
||||
|
||||
w->keymap = NULL;
|
||||
w->ext_keymap = NULL;
|
||||
w->ext_mode = FALSE;
|
||||
|
||||
w->mouse_callback = mouse_callback;
|
||||
w->owner = NULL;
|
||||
w->mouse_handler = mouse_handle_event;
|
||||
w->mouse.forced_capture = FALSE;
|
||||
w->mouse.capture = FALSE;
|
||||
w->mouse.last_msg = MSG_MOUSE_NONE;
|
||||
w->mouse.last_buttons_down = 0;
|
||||
|
||||
w->options = WOP_DEFAULT;
|
||||
w->state = WST_DEFAULT;
|
||||
w->state = WST_CONSTRUCT;
|
||||
|
||||
w->find = widget_default_find;
|
||||
w->find_by_type = widget_default_find_by_type;
|
||||
w->find_by_id = widget_default_find_by_id;
|
||||
|
||||
w->set_state = widget_default_set_state;
|
||||
w->get_colors = widget_default_get_colors;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -284,10 +346,8 @@ widget_destroy (Widget * w)
|
||||
cb_ret_t
|
||||
widget_default_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
|
||||
{
|
||||
(void) w;
|
||||
(void) sender;
|
||||
(void) parm;
|
||||
(void) data;
|
||||
|
||||
switch (msg)
|
||||
{
|
||||
@ -302,6 +362,9 @@ widget_default_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm
|
||||
case MSG_IDLE:
|
||||
return MSG_HANDLED;
|
||||
|
||||
case MSG_RESIZE:
|
||||
return widget_default_resize (w, CONST_RECT (data));
|
||||
|
||||
default:
|
||||
return MSG_NOT_HANDLED;
|
||||
}
|
||||
@ -327,73 +390,6 @@ widget_set_options (Widget * w, widget_options_t options, gboolean enable)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Modify state of widget.
|
||||
*
|
||||
* @param w widget
|
||||
* @param state widget state flag to modify
|
||||
* @param enable specifies whether to turn the flag on (TRUE) or off (FALSE).
|
||||
* Only one flag per call can be modified.
|
||||
* @return MSG_HANDLED if set was handled successfully, MSG_NOT_HANDLED otherwise.
|
||||
*/
|
||||
cb_ret_t
|
||||
widget_set_state (Widget * w, widget_state_t state, gboolean enable)
|
||||
{
|
||||
gboolean ret = MSG_HANDLED;
|
||||
|
||||
if (enable)
|
||||
w->state |= state;
|
||||
else
|
||||
w->state &= ~state;
|
||||
|
||||
if (enable)
|
||||
{
|
||||
/* exclusive bits */
|
||||
if ((state & WST_CONSTRUCT) != 0)
|
||||
w->state &= ~(WST_ACTIVE | WST_SUSPENDED | WST_CLOSED);
|
||||
else if ((state & WST_ACTIVE) != 0)
|
||||
w->state &= ~(WST_CONSTRUCT | WST_SUSPENDED | WST_CLOSED);
|
||||
else if ((state & WST_SUSPENDED) != 0)
|
||||
w->state &= ~(WST_CONSTRUCT | WST_ACTIVE | WST_CLOSED);
|
||||
else if ((state & WST_CLOSED) != 0)
|
||||
w->state &= ~(WST_CONSTRUCT | WST_ACTIVE | WST_SUSPENDED);
|
||||
}
|
||||
|
||||
if (w->owner == NULL)
|
||||
return MSG_NOT_HANDLED;
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case WST_DISABLED:
|
||||
ret = send_message (w, NULL, enable ? MSG_DISABLE : MSG_ENABLE, 0, NULL);
|
||||
if (ret == MSG_HANDLED && widget_get_state (WIDGET (w->owner), WST_ACTIVE))
|
||||
ret = send_message (w, NULL, MSG_DRAW, 0, NULL);
|
||||
break;
|
||||
|
||||
case WST_FOCUSED:
|
||||
{
|
||||
widget_msg_t msg;
|
||||
|
||||
msg = enable ? MSG_FOCUS : MSG_UNFOCUS;
|
||||
ret = send_message (w, NULL, msg, 0, NULL);
|
||||
if (ret == MSG_HANDLED && widget_get_state (WIDGET (w->owner), WST_ACTIVE))
|
||||
{
|
||||
send_message (w, NULL, MSG_DRAW, 0, NULL);
|
||||
/* Notify owner that focus was moved from one widget to another */
|
||||
send_message (w->owner, w, MSG_CHANGED_FOCUS, 0, NULL);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
widget_adjust_position (widget_pos_flags_t pos_flags, int *y, int *x, int *lines, int *cols)
|
||||
{
|
||||
@ -423,17 +419,25 @@ widget_adjust_position (widget_pos_flags_t pos_flags, int *y, int *x, int *lines
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Change widget position and size.
|
||||
*
|
||||
* @param w widget
|
||||
* @param y y coordinate of top-left corner
|
||||
* @param x x coordinate of top-left corner
|
||||
* @param lines width
|
||||
* @param cols height
|
||||
*/
|
||||
|
||||
void
|
||||
widget_set_size (Widget * widget, int y, int x, int lines, int cols)
|
||||
widget_set_size (Widget * w, int y, int x, int lines, int cols)
|
||||
{
|
||||
widget->x = x;
|
||||
widget->y = y;
|
||||
widget->cols = cols;
|
||||
widget->lines = lines;
|
||||
send_message (widget, NULL, MSG_RESIZE, 0, NULL);
|
||||
if (widget->owner != NULL && widget_get_state (WIDGET (widget->owner), WST_ACTIVE))
|
||||
send_message (widget, NULL, MSG_DRAW, 0, NULL);
|
||||
WRect r = { y, x, lines, cols };
|
||||
|
||||
send_message (w, NULL, MSG_RESIZE, 0, &r);
|
||||
|
||||
if (w->owner != NULL && widget_get_state (WIDGET (w->owner), WST_ACTIVE))
|
||||
widget_draw (w);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -441,25 +445,17 @@ widget_set_size (Widget * widget, int y, int x, int lines, int cols)
|
||||
void
|
||||
widget_selectcolor (Widget * w, gboolean focused, gboolean hotkey)
|
||||
{
|
||||
WDialog *h = w->owner;
|
||||
int color;
|
||||
const int *colors;
|
||||
|
||||
colors = widget_get_colors (w);
|
||||
|
||||
if (widget_get_state (w, WST_DISABLED))
|
||||
color = DISABLED_COLOR;
|
||||
else if (hotkey)
|
||||
{
|
||||
if (focused)
|
||||
color = h->color[DLG_COLOR_HOT_FOCUS];
|
||||
else
|
||||
color = h->color[DLG_COLOR_HOT_NORMAL];
|
||||
}
|
||||
color = colors[focused ? DLG_COLOR_HOT_FOCUS : DLG_COLOR_HOT_NORMAL];
|
||||
else
|
||||
{
|
||||
if (focused)
|
||||
color = h->color[DLG_COLOR_FOCUS];
|
||||
else
|
||||
color = h->color[DLG_COLOR_NORMAL];
|
||||
}
|
||||
color = colors[focused ? DLG_COLOR_FOCUS : DLG_COLOR_NORMAL];
|
||||
|
||||
tty_setcolor (color);
|
||||
}
|
||||
@ -476,6 +472,8 @@ widget_erase (Widget * w)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Check whether widget is active or not.
|
||||
* Widget is active if it's current in the its owner and each owner in the chain is current too.
|
||||
*
|
||||
* @param w the widget
|
||||
*
|
||||
* @return TRUE if the widget is active, FALSE otherwise
|
||||
@ -484,21 +482,40 @@ widget_erase (Widget * w)
|
||||
gboolean
|
||||
widget_is_active (const void *w)
|
||||
{
|
||||
return (w == CONST_WIDGET (w)->owner->current->data);
|
||||
const WGroup *owner;
|
||||
|
||||
/* Is group top? */
|
||||
if (w == top_dlg->data)
|
||||
return TRUE;
|
||||
|
||||
owner = CONST_WIDGET (w)->owner;
|
||||
|
||||
/* Is widget in any group? */
|
||||
if (owner == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (w != owner->current->data)
|
||||
return FALSE;
|
||||
|
||||
return widget_is_active (owner);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
cb_ret_t
|
||||
widget_draw (Widget * w)
|
||||
{
|
||||
cb_ret_t ret = MSG_NOT_HANDLED;
|
||||
|
||||
if (w != NULL)
|
||||
{
|
||||
WDialog *h = w->owner;
|
||||
WGroup *g = w->owner;
|
||||
|
||||
if (h != NULL && widget_get_state (WIDGET (h), WST_ACTIVE))
|
||||
w->callback (w, NULL, MSG_DRAW, 0, NULL);
|
||||
if (g != NULL && widget_get_state (WIDGET (g), WST_ACTIVE))
|
||||
ret = w->callback (w, NULL, MSG_DRAW, 0, NULL);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -512,21 +529,21 @@ widget_draw (Widget * w)
|
||||
void
|
||||
widget_replace (Widget * old_w, Widget * new_w)
|
||||
{
|
||||
WDialog *h = old_w->owner;
|
||||
WGroup *g = old_w->owner;
|
||||
gboolean should_focus = FALSE;
|
||||
GList *holder;
|
||||
|
||||
if (h->widgets == NULL)
|
||||
if (g->widgets == NULL)
|
||||
return;
|
||||
|
||||
if (h->current == NULL)
|
||||
h->current = h->widgets;
|
||||
if (g->current == NULL)
|
||||
g->current = g->widgets;
|
||||
|
||||
/* locate widget position in the list */
|
||||
if (old_w == h->current->data)
|
||||
holder = h->current;
|
||||
if (old_w == g->current->data)
|
||||
holder = g->current;
|
||||
else
|
||||
holder = g_list_find (h->widgets, old_w);
|
||||
holder = g_list_find (g->widgets, old_w);
|
||||
|
||||
/* if old widget is focused, we should focus the new one... */
|
||||
if (widget_get_state (old_w, WST_FOCUSED))
|
||||
@ -540,16 +557,17 @@ widget_replace (Widget * old_w, Widget * new_w)
|
||||
{
|
||||
GList *l;
|
||||
|
||||
for (l = dlg_get_widget_next_of (holder);
|
||||
for (l = group_get_widget_next_of (holder);
|
||||
!widget_get_options (WIDGET (l->data), WOP_SELECTABLE)
|
||||
&& !widget_get_state (WIDGET (l->data), WST_DISABLED); l = dlg_get_widget_next_of (l))
|
||||
&& !widget_get_state (WIDGET (l->data), WST_DISABLED);
|
||||
l = group_get_widget_next_of (l))
|
||||
;
|
||||
|
||||
widget_select (WIDGET (l->data));
|
||||
}
|
||||
|
||||
/* replace widget */
|
||||
new_w->owner = h;
|
||||
new_w->owner = g;
|
||||
new_w->id = old_w->id;
|
||||
holder->data = new_w;
|
||||
|
||||
@ -575,19 +593,19 @@ widget_replace (Widget * old_w, Widget * new_w)
|
||||
void
|
||||
widget_select (Widget * w)
|
||||
{
|
||||
WDialog *h;
|
||||
WGroup *g;
|
||||
|
||||
if (!widget_get_options (w, WOP_SELECTABLE))
|
||||
return;
|
||||
|
||||
h = w->owner;
|
||||
if (h != NULL)
|
||||
g = GROUP (w->owner);
|
||||
if (g != NULL)
|
||||
{
|
||||
if (widget_get_options (w, WOP_TOP_SELECT))
|
||||
{
|
||||
GList *l;
|
||||
|
||||
l = dlg_find (h, w);
|
||||
l = widget_find (WIDGET (g), w);
|
||||
widget_reorder (l, TRUE);
|
||||
}
|
||||
|
||||
@ -603,7 +621,7 @@ widget_select (Widget * w)
|
||||
void
|
||||
widget_set_bottom (Widget * w)
|
||||
{
|
||||
widget_reorder (dlg_find (w->owner, w), FALSE);
|
||||
widget_reorder (widget_find (WIDGET (w->owner), w), FALSE);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -622,6 +640,145 @@ widget_overlapped (const Widget * a, const Widget * b)
|
||||
|| (a->x >= b->x + b->cols) || (b->y >= a->y + a->lines) || (a->y >= b->y + b->lines));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Look up key event of widget and translate it to command ID.
|
||||
* @param w widget
|
||||
* @param key key event
|
||||
*
|
||||
* @return command ID binded with @key.
|
||||
*/
|
||||
|
||||
long
|
||||
widget_lookup_key (Widget * w, int key)
|
||||
{
|
||||
if (w->ext_mode)
|
||||
{
|
||||
w->ext_mode = FALSE;
|
||||
return keybind_lookup_keymap_command (w->ext_keymap, key);
|
||||
}
|
||||
|
||||
return keybind_lookup_keymap_command (w->keymap, key);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Default callback function to find widget.
|
||||
*
|
||||
* @param w widget
|
||||
* @param what widget to find
|
||||
*
|
||||
* @return holder of @what if widget is @what, NULL otherwise
|
||||
*/
|
||||
|
||||
GList *
|
||||
widget_default_find (const Widget * w, const Widget * what)
|
||||
{
|
||||
return (w != what
|
||||
|| w->owner == NULL) ? NULL : g_list_find (CONST_GROUP (w->owner)->widgets, what);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Default callback function to find widget by widget type using widget callback.
|
||||
*
|
||||
* @param w widget
|
||||
* @param cb widget callback
|
||||
*
|
||||
* @return @w if widget callback is @cb, NULL otherwise
|
||||
*/
|
||||
|
||||
Widget *
|
||||
widget_default_find_by_type (const Widget * w, widget_cb_fn cb)
|
||||
{
|
||||
return (w->callback == cb ? WIDGET (w) : NULL);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Default callback function to find widget by widget ID.
|
||||
*
|
||||
* @param w widget
|
||||
* @param id widget ID
|
||||
*
|
||||
* @return @w if widget id is equal to @id, NULL otherwise
|
||||
*/
|
||||
|
||||
Widget *
|
||||
widget_default_find_by_id (const Widget * w, unsigned long id)
|
||||
{
|
||||
return (w->id == id ? WIDGET (w) : NULL);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Default callback function to modify state of widget.
|
||||
*
|
||||
* @param w widget
|
||||
* @param state widget state flag to modify
|
||||
* @param enable specifies whether to turn the flag on (TRUE) or off (FALSE).
|
||||
* Only one flag per call can be modified.
|
||||
* @return MSG_HANDLED if set was handled successfully, MSG_NOT_HANDLED otherwise.
|
||||
*/
|
||||
|
||||
cb_ret_t
|
||||
widget_default_set_state (Widget * w, widget_state_t state, gboolean enable)
|
||||
{
|
||||
gboolean ret = MSG_HANDLED;
|
||||
|
||||
if (enable)
|
||||
w->state |= state;
|
||||
else
|
||||
w->state &= ~state;
|
||||
|
||||
if (enable)
|
||||
{
|
||||
/* exclusive bits */
|
||||
if ((state & WST_CONSTRUCT) != 0)
|
||||
w->state &= ~(WST_ACTIVE | WST_SUSPENDED | WST_CLOSED);
|
||||
else if ((state & WST_ACTIVE) != 0)
|
||||
w->state &= ~(WST_CONSTRUCT | WST_SUSPENDED | WST_CLOSED);
|
||||
else if ((state & WST_SUSPENDED) != 0)
|
||||
w->state &= ~(WST_CONSTRUCT | WST_ACTIVE | WST_CLOSED);
|
||||
else if ((state & WST_CLOSED) != 0)
|
||||
w->state &= ~(WST_CONSTRUCT | WST_ACTIVE | WST_SUSPENDED);
|
||||
}
|
||||
|
||||
if (w->owner == NULL)
|
||||
return MSG_NOT_HANDLED;
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case WST_DISABLED:
|
||||
ret = send_message (w, NULL, enable ? MSG_DISABLE : MSG_ENABLE, 0, NULL);
|
||||
if (ret == MSG_HANDLED && widget_get_state (WIDGET (w->owner), WST_ACTIVE))
|
||||
ret = widget_draw (w);
|
||||
break;
|
||||
|
||||
case WST_FOCUSED:
|
||||
{
|
||||
widget_msg_t msg;
|
||||
|
||||
msg = enable ? MSG_FOCUS : MSG_UNFOCUS;
|
||||
ret = send_message (w, NULL, msg, 0, NULL);
|
||||
if (ret == MSG_HANDLED && widget_get_state (WIDGET (w->owner), WST_ACTIVE))
|
||||
{
|
||||
widget_draw (w);
|
||||
/* Notify owner that focus was moved from one widget to another */
|
||||
send_message (w->owner, w, MSG_CHANGED_FOCUS, 0, NULL);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/* get mouse pointer location within widget */
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
#ifndef MC__WIDGET_INTERNAL_H
|
||||
#define MC__WIDGET_INTERNAL_H
|
||||
|
||||
#include "lib/keybind.h" /* global_keymap_t */
|
||||
#include "lib/tty/mouse.h"
|
||||
#include "lib/widget/mouse.h" /* mouse_msg_t, mouse_event_t */
|
||||
|
||||
@ -84,7 +85,7 @@ typedef enum
|
||||
WST_MODAL = (1 << 2), /* Widget (dialog) is modal */
|
||||
WST_FOCUSED = (1 << 3),
|
||||
|
||||
WST_CONSTRUCT = (1 << 15), /* Dialog has been constructed but not run yet */
|
||||
WST_CONSTRUCT = (1 << 15), /* Widget has been constructed but not run yet */
|
||||
WST_ACTIVE = (1 << 16), /* Dialog is visible and active */
|
||||
WST_SUSPENDED = (1 << 17), /* Dialog is suspended */
|
||||
WST_CLOSED = (1 << 18) /* Dialog is closed */
|
||||
@ -122,6 +123,8 @@ typedef cb_ret_t (*widget_cb_fn) (Widget * widget, Widget * sender, widget_msg_t
|
||||
void *data);
|
||||
/* Widget mouse callback */
|
||||
typedef void (*widget_mouse_cb_fn) (Widget * w, mouse_msg_t msg, mouse_event_t * event);
|
||||
/* translate mouse event and process it */
|
||||
typedef int (*widget_mouse_handle_fn) (Widget * w, Gpm_Event * event);
|
||||
|
||||
/* Every Widget must have this as its first element */
|
||||
struct Widget
|
||||
@ -131,11 +134,18 @@ struct Widget
|
||||
widget_pos_flags_t pos_flags; /* repositioning flags */
|
||||
widget_options_t options;
|
||||
widget_state_t state;
|
||||
unsigned int id; /* Number of the widget, starting with 0 */
|
||||
unsigned long id; /* uniq widget ID */
|
||||
widget_cb_fn callback;
|
||||
widget_mouse_cb_fn mouse_callback;
|
||||
WDialog *owner;
|
||||
WGroup *owner;
|
||||
|
||||
/* Key-related fields */
|
||||
const global_keymap_t *keymap; /* main keymap */
|
||||
const global_keymap_t *ext_keymap; /* extended keymap */
|
||||
gboolean ext_mode; /* use keymap or ext_keymap */
|
||||
|
||||
/* Mouse-related fields. */
|
||||
widget_mouse_handle_fn mouse_handler;
|
||||
struct
|
||||
{
|
||||
/* Public members: */
|
||||
@ -146,6 +156,16 @@ struct Widget
|
||||
mouse_msg_t last_msg; /* The previous event type processed. */
|
||||
int last_buttons_down;
|
||||
} mouse;
|
||||
|
||||
GList *(*find) (const Widget * w, const Widget * what);
|
||||
Widget *(*find_by_type) (const Widget * w, widget_cb_fn cb);
|
||||
Widget *(*find_by_id) (const Widget * w, unsigned long id);
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
cb_ret_t (*set_state) (Widget * w, widget_state_t state, gboolean enable);
|
||||
/* *INDENT-ON* */
|
||||
|
||||
const int *(*get_colors) (const Widget * w);
|
||||
};
|
||||
|
||||
/* structure for label (caption) with hotkey, if original text does not contain
|
||||
@ -184,12 +204,11 @@ void widget_destroy (Widget * w);
|
||||
cb_ret_t widget_default_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm,
|
||||
void *data);
|
||||
void widget_set_options (Widget * w, widget_options_t options, gboolean enable);
|
||||
cb_ret_t widget_set_state (Widget * w, widget_state_t state, gboolean enable);
|
||||
void widget_adjust_position (widget_pos_flags_t pos_flags, int *y, int *x, int *lines, int *cols);
|
||||
void widget_set_size (Widget * widget, int y, int x, int lines, int cols);
|
||||
void widget_set_size (Widget * w, int y, int x, int lines, int cols);
|
||||
/* select color for widget in dependance of state */
|
||||
void widget_selectcolor (Widget * w, gboolean focused, gboolean hotkey);
|
||||
void widget_draw (Widget * w);
|
||||
cb_ret_t widget_draw (Widget * w);
|
||||
void widget_erase (Widget * w);
|
||||
gboolean widget_is_active (const void *w);
|
||||
gboolean widget_overlapped (const Widget * a, const Widget * b);
|
||||
@ -197,6 +216,14 @@ void widget_replace (Widget * old, Widget * new);
|
||||
void widget_select (Widget * w);
|
||||
void widget_set_bottom (Widget * w);
|
||||
|
||||
long widget_lookup_key (Widget * w, int key);
|
||||
|
||||
GList *widget_default_find (const Widget * w, const Widget * what);
|
||||
Widget *widget_default_find_by_type (const Widget * w, widget_cb_fn cb);
|
||||
Widget *widget_default_find_by_id (const Widget * w, unsigned long id);
|
||||
|
||||
cb_ret_t widget_default_set_state (Widget * w, widget_state_t state, gboolean enable);
|
||||
|
||||
/* get mouse pointer location within widget */
|
||||
Gpm_Event mouse_get_local (const Gpm_Event * global, const Widget * w);
|
||||
gboolean mouse_global_in_widget (const Gpm_Event * event, const Widget * w);
|
||||
@ -251,4 +278,108 @@ widget_get_state (const Widget * w, widget_state_t state)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Find widget.
|
||||
*
|
||||
* @param w widget
|
||||
* @param what widget to find
|
||||
*
|
||||
* @return result of @w->find()
|
||||
*/
|
||||
|
||||
static inline GList *
|
||||
widget_find (const Widget * w, const Widget * what)
|
||||
{
|
||||
return w->find (w, what);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Find widget by widget type using widget callback.
|
||||
*
|
||||
* @param w widget
|
||||
* @param cb widget callback
|
||||
*
|
||||
* @return result of @w->find_by_type()
|
||||
*/
|
||||
|
||||
static inline Widget *
|
||||
widget_find_by_type (const Widget * w, widget_cb_fn cb)
|
||||
{
|
||||
return w->find_by_type (w, cb);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Find widget by widget ID.
|
||||
*
|
||||
* @param w widget
|
||||
* @param id widget ID
|
||||
*
|
||||
* @return result of @w->find_by_id()
|
||||
*/
|
||||
|
||||
static inline Widget *
|
||||
widget_find_by_id (const Widget * w, unsigned long id)
|
||||
{
|
||||
return w->find_by_id (w, id);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Modify state of widget.
|
||||
*
|
||||
* @param w widget
|
||||
* @param state widget state flag to modify
|
||||
* @param enable specifies whether to turn the flag on (TRUE) or off (FALSE).
|
||||
* Only one flag per call can be modified.
|
||||
* @return MSG_HANDLED if set was handled successfully, MSG_NOT_HANDLED otherwise.
|
||||
*/
|
||||
|
||||
static inline cb_ret_t
|
||||
widget_set_state (Widget * w, widget_state_t state, gboolean enable)
|
||||
{
|
||||
return w->set_state (w, state, enable);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Get color colors of widget.
|
||||
*
|
||||
* @param w widget
|
||||
* @return color colors
|
||||
*/
|
||||
static inline const int *
|
||||
widget_get_colors (const Widget * w)
|
||||
{
|
||||
return w->get_colors (w);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Update cursor position in the specified widget.
|
||||
*
|
||||
* @param w widget
|
||||
*
|
||||
* @return TRUE if cursor was updated successfully, FALSE otherwise
|
||||
*/
|
||||
|
||||
static inline gboolean
|
||||
widget_update_cursor (Widget * w)
|
||||
{
|
||||
return (send_message (w, NULL, MSG_CURSOR, 0, NULL) == MSG_HANDLED);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static inline void
|
||||
widget_set_size_rect (Widget * w, const WRect * r)
|
||||
{
|
||||
widget_set_size (w, r->y, r->x, r->lines, r->cols);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
#endif /* MC__WIDGET_INTERNAL_H */
|
||||
|
@ -74,6 +74,7 @@ query_default_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm,
|
||||
{
|
||||
WDialog *prev_dlg = NULL;
|
||||
int ypos, xpos;
|
||||
WRect r;
|
||||
|
||||
/* get dialog under h */
|
||||
if (top_dlg != NULL)
|
||||
@ -101,9 +102,9 @@ query_default_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm,
|
||||
xpos = COLS / 2 - w->cols / 2;
|
||||
|
||||
/* set position */
|
||||
dlg_set_position (h, ypos, xpos, w->lines, w->cols);
|
||||
rect_init (&r, ypos, xpos, w->lines, w->cols);
|
||||
|
||||
return MSG_HANDLED;
|
||||
return dlg_default_callback (w, NULL, MSG_RESIZE, 0, &r);
|
||||
}
|
||||
MC_FALLTHROUGH;
|
||||
|
||||
@ -273,6 +274,7 @@ query_dialog (const char *header, const char *text, int flags, int count, ...)
|
||||
{
|
||||
va_list ap;
|
||||
WDialog *query_dlg;
|
||||
WGroup *g;
|
||||
WButton *button;
|
||||
int win_len = 0;
|
||||
int i;
|
||||
@ -291,6 +293,7 @@ query_dialog (const char *header, const char *text, int flags, int count, ...)
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
char *cp = va_arg (ap, char *);
|
||||
|
||||
win_len += str_term_width1 (cp) + 6;
|
||||
if (strchr (cp, '&') != NULL)
|
||||
win_len--;
|
||||
@ -307,14 +310,15 @@ query_dialog (const char *header, const char *text, int flags, int count, ...)
|
||||
query_dlg =
|
||||
dlg_create (TRUE, 0, 0, lines, cols, pos_flags, FALSE, query_colors, query_default_callback,
|
||||
NULL, "[QueryBox]", header);
|
||||
g = GROUP (query_dlg);
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
WButton *defbutton = NULL;
|
||||
|
||||
add_widget_autopos (query_dlg, label_new (2, 3, text), WPOS_KEEP_TOP | WPOS_CENTER_HORZ,
|
||||
NULL);
|
||||
add_widget (query_dlg, hline_new (lines - 4, -1, -1));
|
||||
group_add_widget_autopos (g, label_new (2, 3, text), WPOS_KEEP_TOP | WPOS_CENTER_HORZ,
|
||||
NULL);
|
||||
group_add_widget (g, hline_new (lines - 4, -1, -1));
|
||||
|
||||
cols = (cols - win_len - 2) / 2 + 2;
|
||||
va_start (ap, count);
|
||||
@ -329,7 +333,7 @@ query_dialog (const char *header, const char *text, int flags, int count, ...)
|
||||
xpos--;
|
||||
|
||||
button = button_new (lines - 3, cols, B_USER + i, NORMAL_BUTTON, cur_name, NULL);
|
||||
add_widget (query_dlg, button);
|
||||
group_add_widget (g, button);
|
||||
cols += xpos;
|
||||
if (i == sel_pos)
|
||||
defbutton = button;
|
||||
@ -356,9 +360,9 @@ query_dialog (const char *header, const char *text, int flags, int count, ...)
|
||||
}
|
||||
else
|
||||
{
|
||||
add_widget_autopos (query_dlg, label_new (2, 3, text), WPOS_KEEP_TOP | WPOS_CENTER_HORZ,
|
||||
NULL);
|
||||
add_widget (query_dlg, button_new (0, 0, 0, HIDDEN_BUTTON, "-", NULL));
|
||||
group_add_widget_autopos (g, label_new (2, 3, text), WPOS_KEEP_TOP | WPOS_CENTER_HORZ,
|
||||
NULL);
|
||||
group_add_widget (g, button_new (0, 0, 0, HIDDEN_BUTTON, "-", NULL));
|
||||
last_query_dlg = query_dlg;
|
||||
}
|
||||
sel_pos = 0;
|
||||
@ -687,6 +691,7 @@ simple_status_msg_init_cb (status_msg_t * sm)
|
||||
{
|
||||
simple_status_msg_t *ssm = SIMPLE_STATUS_MSG (sm);
|
||||
Widget *wd = WIDGET (sm->dlg);
|
||||
WGroup *wg = GROUP (sm->dlg);
|
||||
|
||||
const char *b_name = N_("&Abort");
|
||||
int b_width;
|
||||
@ -702,10 +707,10 @@ simple_status_msg_init_cb (status_msg_t * sm)
|
||||
|
||||
y = 2;
|
||||
ssm->label = label_new (y++, 3, "");
|
||||
add_widget_autopos (sm->dlg, ssm->label, WPOS_KEEP_TOP | WPOS_CENTER_HORZ, NULL);
|
||||
add_widget (sm->dlg, hline_new (y++, -1, -1));
|
||||
group_add_widget_autopos (wg, ssm->label, WPOS_KEEP_TOP | WPOS_CENTER_HORZ, NULL);
|
||||
group_add_widget (wg, hline_new (y++, -1, -1));
|
||||
b = WIDGET (button_new (y++, 3, B_CANCEL, NORMAL_BUTTON, b_name, NULL));
|
||||
add_widget_autopos (sm->dlg, b, WPOS_KEEP_TOP | WPOS_CENTER_HORZ, NULL);
|
||||
group_add_widget_autopos (wg, b, WPOS_KEEP_TOP | WPOS_CENTER_HORZ, NULL);
|
||||
|
||||
widget_set_size (wd, wd->y, wd->x, y + 2, wd_width);
|
||||
}
|
||||
|
2
po/az.po
2
po/az.po
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 01:49+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: Azerbaijani (http://www.transifex.com/mc/mc/language/az/)\n"
|
||||
|
2
po/be.po
2
po/be.po
@ -12,7 +12,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 01:49+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: Belarusian (http://www.transifex.com/mc/mc/language/be/)\n"
|
||||
|
2
po/bg.po
2
po/bg.po
@ -11,7 +11,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 01:49+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: Bulgarian (http://www.transifex.com/mc/mc/language/bg/)\n"
|
||||
|
2
po/ca.po
2
po/ca.po
@ -16,7 +16,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-22 22:08+0000\n"
|
||||
"Last-Translator: Antoni Bella Pérez <antonibella5@yahoo.com>\n"
|
||||
"Language-Team: Catalan (http://www.transifex.com/mc/mc/language/ca/)\n"
|
||||
|
2
po/cs.po
2
po/cs.po
@ -13,7 +13,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 05:03+0000\n"
|
||||
"Last-Translator: Pavel Borecki <pavel.borecki@gmail.com>\n"
|
||||
"Language-Team: Czech (http://www.transifex.com/mc/mc/language/cs/)\n"
|
||||
|
2
po/da.po
2
po/da.po
@ -13,7 +13,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-17 03:41+0000\n"
|
||||
"Last-Translator: scootergrisen\n"
|
||||
"Language-Team: Danish (http://www.transifex.com/mc/mc/language/da/)\n"
|
||||
|
2
po/de.po
2
po/de.po
@ -19,7 +19,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2020-01-05 13:48+0000\n"
|
||||
"Last-Translator: Mr.Update\n"
|
||||
"Language-Team: German (http://www.transifex.com/mc/mc/language/de/)\n"
|
||||
|
@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2015-02-26 09:48+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: German (Switzerland) (http://www.transifex.com/projects/p/mc/"
|
||||
|
2
po/el.po
2
po/el.po
@ -12,7 +12,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 01:49+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: Greek (http://www.transifex.com/mc/mc/language/el/)\n"
|
||||
|
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 01:49+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: English (United Kingdom) (http://www.transifex.com/mc/mc/"
|
||||
|
2
po/eo.po
2
po/eo.po
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-25 01:49+0000\n"
|
||||
"Last-Translator: Keith Bowes <zooplah@gmail.com>\n"
|
||||
"Language-Team: Esperanto (http://www.transifex.com/mc/mc/language/eo/)\n"
|
||||
|
2
po/es.po
2
po/es.po
@ -13,7 +13,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 14:54+0000\n"
|
||||
"Last-Translator: David Martin <dhmartina@yahoo.es>\n"
|
||||
"Language-Team: Spanish (http://www.transifex.com/mc/mc/language/es/)\n"
|
||||
|
2
po/et.po
2
po/et.po
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 01:49+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: Estonian (http://www.transifex.com/mc/mc/language/et/)\n"
|
||||
|
2
po/eu.po
2
po/eu.po
@ -9,7 +9,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 01:49+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: Basque (http://www.transifex.com/mc/mc/language/eu/)\n"
|
||||
|
2
po/fa.po
2
po/fa.po
@ -12,7 +12,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 01:49+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: Persian (http://www.transifex.com/mc/mc/language/fa/)\n"
|
||||
|
2
po/fi.po
2
po/fi.po
@ -10,7 +10,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 01:49+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: Finnish (http://www.transifex.com/mc/mc/language/fi/)\n"
|
||||
|
2
po/fr.po
2
po/fr.po
@ -17,7 +17,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 01:49+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: French (http://www.transifex.com/mc/mc/language/fr/)\n"
|
||||
|
@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2015-02-26 09:48+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: French (Canada) (http://www.transifex.com/projects/p/mc/"
|
||||
|
2
po/gl.po
2
po/gl.po
@ -12,7 +12,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 01:49+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: Galician (http://www.transifex.com/mc/mc/language/gl/)\n"
|
||||
|
2
po/hr.po
2
po/hr.po
@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 01:49+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: Croatian (http://www.transifex.com/mc/mc/language/hr/)\n"
|
||||
|
2
po/hu.po
2
po/hu.po
@ -11,7 +11,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 01:49+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: Hungarian (http://www.transifex.com/mc/mc/language/hu/)\n"
|
||||
|
2
po/ia.po
2
po/ia.po
@ -10,7 +10,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 01:49+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: Interlingua (http://www.transifex.com/mc/mc/language/ia/)\n"
|
||||
|
2
po/id.po
2
po/id.po
@ -10,7 +10,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 01:49+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: Indonesian (http://www.transifex.com/mc/mc/language/id/)\n"
|
||||
|
2
po/it.po
2
po/it.po
@ -11,7 +11,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2020-01-06 12:54+0100\n"
|
||||
"Last-Translator: Marco Ciampa <ciampix@libero.it>\n"
|
||||
"Language-Team: Italian (http://www.transifex.com/projects/p/mc/language/"
|
||||
|
2
po/ja.po
2
po/ja.po
@ -11,7 +11,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 01:49+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: Japanese (http://www.transifex.com/mc/mc/language/ja/)\n"
|
||||
|
2
po/ka.po
2
po/ka.po
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 01:49+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: Georgian (http://www.transifex.com/mc/mc/language/ka/)\n"
|
||||
|
2
po/kk.po
2
po/kk.po
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 01:49+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: Kazakh (http://www.transifex.com/mc/mc/language/kk/)\n"
|
||||
|
2
po/ko.po
2
po/ko.po
@ -11,7 +11,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 01:49+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: Korean (http://www.transifex.com/mc/mc/language/ko/)\n"
|
||||
|
2
po/lt.po
2
po/lt.po
@ -13,7 +13,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-23 11:49+0000\n"
|
||||
"Last-Translator: Mindaugas <opensuse.lietuviu.kalba@gmail.com>\n"
|
||||
"Language-Team: Lithuanian (http://www.transifex.com/mc/mc/language/lt/)\n"
|
||||
|
2
po/lv.po
2
po/lv.po
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 01:49+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: Latvian (http://www.transifex.com/mc/mc/language/lv/)\n"
|
||||
|
2
po/mn.po
2
po/mn.po
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 01:49+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: Mongolian (http://www.transifex.com/mc/mc/language/mn/)\n"
|
||||
|
2
po/nb.po
2
po/nb.po
@ -9,7 +9,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-22 05:53+0000\n"
|
||||
"Last-Translator: Kjell Cato Heskjestad <cato@heskjestad.xyz>\n"
|
||||
"Language-Team: Norwegian Bokmål (http://www.transifex.com/mc/mc/language/"
|
||||
|
2
po/nl.po
2
po/nl.po
@ -14,7 +14,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 01:49+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: Dutch (http://www.transifex.com/mc/mc/language/nl/)\n"
|
||||
|
2
po/pl.po
2
po/pl.po
@ -9,7 +9,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 16:22+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: Polish (http://www.transifex.com/mc/mc/language/pl/)\n"
|
||||
|
2
po/pt.po
2
po/pt.po
@ -11,7 +11,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-17 23:30+0000\n"
|
||||
"Last-Translator: Gilberto Jorge <gmj125@gmail.com>\n"
|
||||
"Language-Team: Portuguese (http://www.transifex.com/mc/mc/language/pt/)\n"
|
||||
|
@ -13,7 +13,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 01:49+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: Portuguese (Brazil) (http://www.transifex.com/mc/mc/language/"
|
||||
|
2
po/ro.po
2
po/ro.po
@ -15,7 +15,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 01:49+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: Romanian (http://www.transifex.com/mc/mc/language/ro/)\n"
|
||||
|
62
po/ru.po
62
po/ru.po
@ -13,7 +13,7 @@
|
||||
# Ilia Maslakov <il.smind@gmail.com>, 2009
|
||||
# Slava Zanko <slavazanko@gmail.com>, 2009, 2011
|
||||
# NaiLi (aka jamesjames) Rootaerc <theism@mail.ru>, 2012
|
||||
# AlexL <loginov.alex.valer@gmail.com>, 2015-2019
|
||||
# AlexL <loginov.alex.valer@gmail.com>, 2015-2020
|
||||
# Dimitriy Ryazantcev <DJm00n@mail.ru>, 2015
|
||||
# Simple88, 2016
|
||||
# Piotr Drąg <piotrdrag@gmail.com>, 2018
|
||||
@ -21,9 +21,9 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"PO-Revision-Date: 2019-12-24 17:03+0000\n"
|
||||
"Last-Translator: aborodin <aborodin@vmail.ru>\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2020-03-01 23:25+0000\n"
|
||||
"Last-Translator: AlexL <loginov.alex.valer@gmail.com>\n"
|
||||
"Language-Team: Russian (http://www.transifex.com/mc/mc/language/ru/)\n"
|
||||
"Language: ru\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@ -169,7 +169,7 @@ msgid ""
|
||||
"Unable to load '%s' skin.\n"
|
||||
"Default skin has been loaded"
|
||||
msgstr ""
|
||||
"Невозможно загрузить скин %s.\n"
|
||||
"Не удалось загрузить скин %s.\n"
|
||||
"Используется скин по умолчанию"
|
||||
|
||||
#, c-format
|
||||
@ -177,7 +177,7 @@ msgid ""
|
||||
"Unable to parse '%s' skin.\n"
|
||||
"Default skin has been loaded"
|
||||
msgstr ""
|
||||
"Невозможно произвести синтаксический разбор файла %s.\n"
|
||||
"Не удалось произвести синтаксический разбор файла %s.\n"
|
||||
"Используется скин по умолчанию"
|
||||
|
||||
#, c-format
|
||||
@ -186,7 +186,7 @@ msgid ""
|
||||
"%s\n"
|
||||
"Default skin has been loaded"
|
||||
msgstr ""
|
||||
"Невозможно использовать скин %s, требующий True Color:\n"
|
||||
"Не удалось использовать скин %s, требующий True Color:\n"
|
||||
"%s\n"
|
||||
"Будет использован скин по умолчанию"
|
||||
|
||||
@ -501,19 +501,31 @@ msgid "The TERM environment variable is unset!\n"
|
||||
msgstr "Переменная среды TERM не определена!\n"
|
||||
|
||||
msgid "Cannot check SIGWINCH pipe"
|
||||
msgstr "Не удаётся проверить канал SIGWINCH"
|
||||
|
||||
#, c-format
|
||||
msgid ""
|
||||
"\n"
|
||||
"Cannot create pipe for SIGWINCH: %s (%d)\n"
|
||||
msgstr ""
|
||||
"\n"
|
||||
"Не удалось создать канал для SIGWINCH: %s (%d)\n"
|
||||
|
||||
#, c-format
|
||||
msgid "\nCannot create pipe for SIGWINCH: %s (%d)\n"
|
||||
msgstr "\nНе удалось создать канал для SIGWINCH: %s (%d)\n"
|
||||
msgid ""
|
||||
"\n"
|
||||
"Cannot configure write end of SIGWINCH pipe: %s (%d)\n"
|
||||
msgstr ""
|
||||
"\n"
|
||||
"Не удалось настроить конец записи канала SIGWINCH: %s (%d)\n"
|
||||
|
||||
#, c-format
|
||||
msgid "\nCannot configure write end of SIGWINCH pipe: %s (%d)\n"
|
||||
msgstr "\nНе удалось настроить конец записи канала SIGWINCH: %s (%d)\n"
|
||||
|
||||
#, c-format
|
||||
msgid "\nCannot configure read end of SIGWINCH pipe: %s (%d)\n"
|
||||
msgstr "\nНе удалось настроить конец чтения канала SIGWINCH: %s (%d)\n"
|
||||
msgid ""
|
||||
"\n"
|
||||
"Cannot configure read end of SIGWINCH pipe: %s (%d)\n"
|
||||
msgstr ""
|
||||
"\n"
|
||||
"Не удалось настроить конец чтения канала SIGWINCH: %s (%d)\n"
|
||||
|
||||
#, c-format
|
||||
msgid ""
|
||||
@ -1279,7 +1291,7 @@ msgid "Copy to clipboard"
|
||||
msgstr "Копировать в буфер"
|
||||
|
||||
msgid "Unable to save to file"
|
||||
msgstr "Невозможно сохранить в файл"
|
||||
msgstr "Не удалось сохранить в файл"
|
||||
|
||||
msgid "Cut to clipboard"
|
||||
msgstr "Вырезать в буфер"
|
||||
@ -2422,7 +2434,7 @@ msgstr "Правка ссылки"
|
||||
|
||||
#, c-format
|
||||
msgid "edit symlink, unable to remove %s: %s"
|
||||
msgstr "правка символической ссылки, невозможно удалить %s: %s"
|
||||
msgstr "правка символической ссылки, не удалось удалить %s: %s"
|
||||
|
||||
#, c-format
|
||||
msgid "edit symlink: %s"
|
||||
@ -2462,7 +2474,7 @@ msgstr "Параметры сохранены в %s"
|
||||
|
||||
#, c-format
|
||||
msgid "Unable to save setup to %s"
|
||||
msgstr "Невозможно сохранить параметры в %s"
|
||||
msgstr "Не удалось сохранить параметры в %s"
|
||||
|
||||
msgid "Cannot execute commands on non-local filesystems"
|
||||
msgstr "Не удалось выполнять команды на нелокальных файловых системах"
|
||||
@ -2758,7 +2770,7 @@ msgid ""
|
||||
"Cannot fstat source file \"%s\"\n"
|
||||
"%s"
|
||||
msgstr ""
|
||||
"Не удалосьо получить свойства исходного файла \"%s\"\n"
|
||||
"Не удалось получить свойства исходного файла \"%s\"\n"
|
||||
"%s"
|
||||
|
||||
#, c-format
|
||||
@ -3758,7 +3770,7 @@ msgid ""
|
||||
"Cannot write to the %s file:\n"
|
||||
"%s\n"
|
||||
msgstr ""
|
||||
"Не удалось писать в файл %s:\n"
|
||||
"Не удалось записать в файл %s:\n"
|
||||
"%s\n"
|
||||
|
||||
msgid "Help file format error\n"
|
||||
@ -4211,10 +4223,10 @@ msgstr "ftpfs: неверный адрес системы."
|
||||
|
||||
#, c-format
|
||||
msgid "ftpfs: could not create socket: %s"
|
||||
msgstr "Невозможно создать сокет: %s"
|
||||
msgstr "Не удалось создать сокет: %s"
|
||||
|
||||
msgid "ftpfs: could not setup passive mode"
|
||||
msgstr "ftpfs: невозможно установить пассивный режим"
|
||||
msgstr "ftpfs: не удалось установить пассивный режим"
|
||||
|
||||
msgid "ftpfs: aborting transfer."
|
||||
msgstr "ftpfs: прерывание передачи."
|
||||
@ -4227,10 +4239,10 @@ msgid "ftpfs: abort failed"
|
||||
msgstr "ftpfs: сбой прерывания"
|
||||
|
||||
msgid "ftpfs: CWD failed."
|
||||
msgstr "ftpfs: невозможно изменить текущий рабочий каталог."
|
||||
msgstr "ftpfs: не удалось изменить текущий рабочий каталог."
|
||||
|
||||
msgid "ftpfs: couldn't resolve symlink"
|
||||
msgstr "ftpfs: невозможно распознать символическую ссылку"
|
||||
msgstr "ftpfs: не удалось распознать символическую ссылку"
|
||||
|
||||
msgid "Resolving symlink..."
|
||||
msgstr "Распознается символическая ссылка..."
|
||||
@ -4283,7 +4295,7 @@ msgid "sftp: an error occurred while reading %s: %s"
|
||||
msgstr "sftp: произошла ошибка при чтении %s: %s"
|
||||
|
||||
msgid "sftp: Unable to get current user name."
|
||||
msgstr "sftp: невозможно получить имя пользователя."
|
||||
msgstr "sftp: не удалось получить имя пользователя."
|
||||
|
||||
msgid "sftp: Invalid host name."
|
||||
msgstr "sftp: неверное имя системы."
|
||||
|
2
po/sk.po
2
po/sk.po
@ -15,7 +15,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 01:49+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: Slovak (http://www.transifex.com/mc/mc/language/sk/)\n"
|
||||
|
2
po/sl.po
2
po/sl.po
@ -10,7 +10,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 01:49+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: Slovenian (http://www.transifex.com/mc/mc/language/sl/)\n"
|
||||
|
2
po/sr.po
2
po/sr.po
@ -9,7 +9,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 01:49+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: Serbian (http://www.transifex.com/mc/mc/language/sr/)\n"
|
||||
|
2
po/sv.po
2
po/sv.po
@ -15,7 +15,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 01:49+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: Swedish (http://www.transifex.com/mc/mc/language/sv/)\n"
|
||||
|
@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 01:49+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: Silesian (http://www.transifex.com/mc/mc/language/szl/)\n"
|
||||
|
2
po/ta.po
2
po/ta.po
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 01:49+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: Tamil (http://www.transifex.com/mc/mc/language/ta/)\n"
|
||||
|
2
po/te.po
2
po/te.po
@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 01:49+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: Telugu (http://www.transifex.com/mc/mc/language/te/)\n"
|
||||
|
2
po/tr.po
2
po/tr.po
@ -14,7 +14,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2020-01-18 12:57+0000\n"
|
||||
"Last-Translator: Serdar Sağlam <teknomobil@msn.com>\n"
|
||||
"Language-Team: Turkish (http://www.transifex.com/mc/mc/language/tr/)\n"
|
||||
|
2
po/uk.po
2
po/uk.po
@ -15,7 +15,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 01:49+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: Ukrainian (http://www.transifex.com/mc/mc/language/uk/)\n"
|
||||
|
2
po/vi.po
2
po/vi.po
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 01:49+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: Vietnamese (http://www.transifex.com/mc/mc/language/vi/)\n"
|
||||
|
2
po/wa.po
2
po/wa.po
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 01:49+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: Walloon (http://www.transifex.com/mc/mc/language/wa/)\n"
|
||||
|
@ -17,7 +17,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 01:49+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: Chinese (China) (http://www.transifex.com/mc/mc/language/"
|
||||
|
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Midnight Commander\n"
|
||||
"Report-Msgid-Bugs-To: http://www.midnight-commander.org/\n"
|
||||
"POT-Creation-Date: 2020-02-29 19:12+0300\n"
|
||||
"POT-Creation-Date: 2020-03-09 10:53+0300\n"
|
||||
"PO-Revision-Date: 2019-12-16 01:49+0000\n"
|
||||
"Last-Translator: Piotr Drąg <piotrdrag@gmail.com>\n"
|
||||
"Language-Team: Chinese (Taiwan) (http://www.transifex.com/mc/mc/language/"
|
||||
|
@ -2882,7 +2882,7 @@ dview_update (WDiff * dview)
|
||||
static void
|
||||
dview_edit (WDiff * dview, diff_place_t ord)
|
||||
{
|
||||
WDialog *h;
|
||||
Widget *h;
|
||||
gboolean h_modal;
|
||||
int linenum, lineofs;
|
||||
|
||||
@ -2892,13 +2892,13 @@ dview_edit (WDiff * dview, diff_place_t ord)
|
||||
return;
|
||||
}
|
||||
|
||||
h = WIDGET (dview)->owner;
|
||||
h_modal = widget_get_state (WIDGET (h), WST_MODAL);
|
||||
h = WIDGET (WIDGET (dview)->owner);
|
||||
h_modal = widget_get_state (h, WST_MODAL);
|
||||
|
||||
get_line_numbers (dview->a[ord], dview->skip_rows, &linenum, &lineofs);
|
||||
|
||||
/* disallow edit file in several editors */
|
||||
widget_set_state (WIDGET (h), WST_MODAL, TRUE);
|
||||
widget_set_state (h, WST_MODAL, TRUE);
|
||||
|
||||
{
|
||||
vfs_path_t *tmp_vpath;
|
||||
@ -2908,7 +2908,7 @@ dview_edit (WDiff * dview, diff_place_t ord)
|
||||
vfs_path_free (tmp_vpath);
|
||||
}
|
||||
|
||||
widget_set_state (WIDGET (h), WST_MODAL, h_modal);
|
||||
widget_set_state (h, WST_MODAL, h_modal);
|
||||
dview_redo (dview);
|
||||
dview_update (dview);
|
||||
}
|
||||
@ -2965,21 +2965,18 @@ dview_goto_cmd (WDiff * dview, diff_place_t ord)
|
||||
static void
|
||||
dview_labels (WDiff * dview)
|
||||
{
|
||||
Widget *d;
|
||||
WDialog *h;
|
||||
Widget *d = WIDGET (dview);
|
||||
WButtonBar *b;
|
||||
|
||||
d = WIDGET (dview);
|
||||
h = d->owner;
|
||||
b = find_buttonbar (h);
|
||||
b = find_buttonbar (DIALOG (d->owner));
|
||||
|
||||
buttonbar_set_label (b, 1, Q_ ("ButtonBar|Help"), diff_map, d);
|
||||
buttonbar_set_label (b, 2, Q_ ("ButtonBar|Save"), diff_map, d);
|
||||
buttonbar_set_label (b, 4, Q_ ("ButtonBar|Edit"), diff_map, d);
|
||||
buttonbar_set_label (b, 5, Q_ ("ButtonBar|Merge"), diff_map, d);
|
||||
buttonbar_set_label (b, 7, Q_ ("ButtonBar|Search"), diff_map, d);
|
||||
buttonbar_set_label (b, 9, Q_ ("ButtonBar|Options"), diff_map, d);
|
||||
buttonbar_set_label (b, 10, Q_ ("ButtonBar|Quit"), diff_map, d);
|
||||
buttonbar_set_label (b, 1, Q_ ("ButtonBar|Help"), d->keymap, d);
|
||||
buttonbar_set_label (b, 2, Q_ ("ButtonBar|Save"), d->keymap, d);
|
||||
buttonbar_set_label (b, 4, Q_ ("ButtonBar|Edit"), d->keymap, d);
|
||||
buttonbar_set_label (b, 5, Q_ ("ButtonBar|Merge"), d->keymap, d);
|
||||
buttonbar_set_label (b, 7, Q_ ("ButtonBar|Search"), d->keymap, d);
|
||||
buttonbar_set_label (b, 9, Q_ ("ButtonBar|Options"), d->keymap, d);
|
||||
buttonbar_set_label (b, 10, Q_ ("ButtonBar|Quit"), d->keymap, d);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -3292,7 +3289,7 @@ dview_handle_key (WDiff * dview, int key)
|
||||
key = convert_from_input_c (key);
|
||||
#endif
|
||||
|
||||
command = keybind_lookup_keymap_command (diff_map, key);
|
||||
command = widget_lookup_key (WIDGET (dview), key);
|
||||
if ((command != CK_IgnoreKey) && (dview_execute_cmd (dview, command) == MSG_HANDLED))
|
||||
return MSG_HANDLED;
|
||||
|
||||
@ -3306,7 +3303,7 @@ static cb_ret_t
|
||||
dview_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
|
||||
{
|
||||
WDiff *dview = (WDiff *) w;
|
||||
WDialog *h = w->owner;
|
||||
WDialog *h = DIALOG (w->owner);
|
||||
cb_ret_t i;
|
||||
|
||||
switch (msg)
|
||||
@ -3339,6 +3336,7 @@ dview_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d
|
||||
return i;
|
||||
|
||||
case MSG_RESIZE:
|
||||
widget_default_callback (w, NULL, MSG_RESIZE, 0, data);
|
||||
dview_compute_areas (dview);
|
||||
return MSG_HANDLED;
|
||||
|
||||
@ -3397,7 +3395,7 @@ dview_dialog_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm,
|
||||
return dview_execute_cmd (NULL, parm);
|
||||
|
||||
case MSG_VALIDATE:
|
||||
dview = (WDiff *) find_widget_type (h, dview_callback);
|
||||
dview = (WDiff *) widget_find_by_type (CONST_WIDGET (h), dview_callback);
|
||||
/* don't stop the dialog before final decision */
|
||||
widget_set_state (w, WST_ACTIVE, TRUE);
|
||||
if (dview_ok_to_exit (dview))
|
||||
@ -3420,7 +3418,7 @@ dview_get_title (const WDialog * h, size_t len)
|
||||
size_t len1;
|
||||
GString *title;
|
||||
|
||||
dview = (const WDiff *) find_widget_type (h, dview_callback);
|
||||
dview = (const WDiff *) widget_find_by_type (CONST_WIDGET (h), dview_callback);
|
||||
len1 = (len - str_term_width1 (_("Diff:")) - strlen (modified) - 3) / 2;
|
||||
|
||||
title = g_string_sized_new (len);
|
||||
@ -3444,6 +3442,7 @@ diff_view (const char *file1, const char *file2, const char *label1, const char
|
||||
Widget *w;
|
||||
WDialog *dview_dlg;
|
||||
Widget *dw;
|
||||
WGroup *g;
|
||||
|
||||
/* Create dialog and widgets, put them on the dialog */
|
||||
dview_dlg =
|
||||
@ -3452,14 +3451,17 @@ diff_view (const char *file1, const char *file2, const char *label1, const char
|
||||
dw = WIDGET (dview_dlg);
|
||||
widget_want_tab (dw, TRUE);
|
||||
|
||||
g = GROUP (dview_dlg);
|
||||
|
||||
dview = g_new0 (WDiff, 1);
|
||||
w = WIDGET (dview);
|
||||
widget_init (w, dw->y, dw->x, dw->lines - 1, dw->cols, dview_callback, dview_mouse_callback);
|
||||
w->options |= WOP_SELECTABLE;
|
||||
add_widget_autopos (dview_dlg, w, WPOS_KEEP_ALL, NULL);
|
||||
w->keymap = diff_map;
|
||||
group_add_widget_autopos (g, w, WPOS_KEEP_ALL, NULL);
|
||||
|
||||
w = WIDGET (buttonbar_new (TRUE));
|
||||
add_widget_autopos (dview_dlg, w, w->pos_flags, NULL);
|
||||
group_add_widget_autopos (g, w, w->pos_flags, NULL);
|
||||
|
||||
dview_dlg->get_title = dview_get_title;
|
||||
|
||||
|
@ -2084,21 +2084,18 @@ edit_init (WEdit * edit, int y, int x, int lines, int cols, const vfs_path_t * f
|
||||
|
||||
if (edit != NULL)
|
||||
{
|
||||
gboolean fullscreen;
|
||||
WRect loc_prev;
|
||||
|
||||
/* save some widget parameters */
|
||||
gboolean fullscreen = edit->fullscreen;
|
||||
int y_prev = edit->y_prev;
|
||||
int x_prev = edit->x_prev;
|
||||
int lines_prev = edit->lines_prev;
|
||||
int cols_prev = edit->cols_prev;
|
||||
fullscreen = edit->fullscreen;
|
||||
loc_prev = edit->loc_prev;
|
||||
|
||||
edit_purge_widget (edit);
|
||||
|
||||
/* restore saved parameters */
|
||||
edit->fullscreen = fullscreen;
|
||||
edit->y_prev = y_prev;
|
||||
edit->x_prev = x_prev;
|
||||
edit->lines_prev = lines_prev;
|
||||
edit->cols_prev = cols_prev;
|
||||
edit->loc_prev = loc_prev;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2109,6 +2106,8 @@ edit_init (WEdit * edit, int y, int x, int lines, int cols, const vfs_path_t * f
|
||||
w = WIDGET (edit);
|
||||
widget_init (w, y, x, lines, cols, NULL, NULL);
|
||||
w->options |= WOP_SELECTABLE | WOP_TOP_SELECT | WOP_WANT_CURSOR;
|
||||
w->keymap = editor_map;
|
||||
w->ext_keymap = editor_x_map;
|
||||
edit->fullscreen = TRUE;
|
||||
edit_save_size (edit);
|
||||
}
|
||||
@ -2237,10 +2236,7 @@ edit_reload_line (WEdit * edit, const vfs_path_t * filename_vpath, long line)
|
||||
*WIDGET (e) = *w;
|
||||
/* save some widget parameters */
|
||||
e->fullscreen = edit->fullscreen;
|
||||
e->y_prev = edit->y_prev;
|
||||
e->x_prev = edit->x_prev;
|
||||
e->lines_prev = edit->lines_prev;
|
||||
e->cols_prev = edit->cols_prev;
|
||||
e->loc_prev = edit->loc_prev;
|
||||
|
||||
if (edit_init (e, w->y, w->x, w->lines, w->cols, filename_vpath, line) == NULL)
|
||||
{
|
||||
@ -3932,7 +3928,7 @@ edit_execute_cmd (WEdit * edit, long command, int char_for_insertion)
|
||||
edit_begin_end_repeat_cmd (edit);
|
||||
break;
|
||||
case CK_ExtendedKeyMap:
|
||||
edit->extmod = TRUE;
|
||||
w->ext_mode = TRUE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -156,7 +156,7 @@ edit_save_mode_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm
|
||||
{
|
||||
Widget *ww;
|
||||
|
||||
ww = dlg_find_by_id (DIALOG (w), edit_save_mode_input_id);
|
||||
ww = widget_find_by_id (w, edit_save_mode_input_id);
|
||||
widget_disable (ww, RADIO (sender)->sel != 2);
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
@ -1492,24 +1492,6 @@ edit_syntax_onoff_cb (void *data, void *user_data)
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Callback for the iteration of objects in the 'editors' array.
|
||||
* Redraw editor object.
|
||||
*
|
||||
* @param data probably WEdit object
|
||||
* @param user_data unused
|
||||
*/
|
||||
|
||||
static void
|
||||
edit_redraw_page_cb (void *data, void *user_data)
|
||||
{
|
||||
(void) user_data;
|
||||
|
||||
if (edit_widget_is_editor (CONST_WIDGET (data)))
|
||||
((WEdit *) data)->force |= REDRAW_PAGE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Insert autocompleted word into editor.
|
||||
@ -1559,8 +1541,8 @@ void
|
||||
edit_syntax_onoff_cmd (WDialog * h)
|
||||
{
|
||||
option_syntax_highlighting = !option_syntax_highlighting;
|
||||
g_list_foreach (h->widgets, edit_syntax_onoff_cb, NULL);
|
||||
dlg_draw (h);
|
||||
g_list_foreach (GROUP (h)->widgets, edit_syntax_onoff_cb, NULL);
|
||||
widget_draw (WIDGET (h));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -1574,8 +1556,7 @@ void
|
||||
edit_show_tabs_tws_cmd (WDialog * h)
|
||||
{
|
||||
enable_show_tabs_tws = !enable_show_tabs_tws;
|
||||
g_list_foreach (h->widgets, edit_redraw_page_cb, NULL);
|
||||
dlg_draw (h);
|
||||
widget_draw (WIDGET (h));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -1589,8 +1570,7 @@ void
|
||||
edit_show_margin_cmd (WDialog * h)
|
||||
{
|
||||
show_right_margin = !show_right_margin;
|
||||
g_list_foreach (h->widgets, edit_redraw_page_cb, NULL);
|
||||
dlg_draw (h);
|
||||
widget_draw (WIDGET (h));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -1605,8 +1585,7 @@ edit_show_numbers_cmd (WDialog * h)
|
||||
{
|
||||
option_line_state = !option_line_state;
|
||||
option_line_state_width = option_line_state ? LINE_STATE_WIDTH : 0;
|
||||
g_list_foreach (h->widgets, edit_redraw_page_cb, NULL);
|
||||
dlg_draw (h);
|
||||
widget_draw (WIDGET (h));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -1860,7 +1839,7 @@ edit_store_macro_cmd (WEdit * edit)
|
||||
if (hotkey == ESC_CHAR)
|
||||
return FALSE;
|
||||
|
||||
tmp_act = keybind_lookup_keymap_command (editor_map, hotkey);
|
||||
tmp_act = keybind_lookup_keymap_command (WIDGET (edit)->keymap, hotkey);
|
||||
|
||||
/* return FALSE if try assign macro into restricted hotkeys */
|
||||
if (tmp_act == CK_MacroStartRecord
|
||||
@ -2262,16 +2241,17 @@ edit_close_cmd (WEdit * edit)
|
||||
|
||||
if (ret)
|
||||
{
|
||||
WDialog *h = WIDGET (edit)->owner;
|
||||
WGroup *g = WIDGET (edit)->owner;
|
||||
WDialog *h = DIALOG (g);
|
||||
|
||||
if (edit->locked != 0)
|
||||
unlock_file (edit->filename_vpath);
|
||||
|
||||
del_widget (edit);
|
||||
group_remove_widget (edit);
|
||||
widget_destroy (WIDGET (edit));
|
||||
|
||||
if (edit_widget_is_editor (CONST_WIDGET (h->current->data)))
|
||||
edit = (WEdit *) h->current->data;
|
||||
if (edit_widget_is_editor (CONST_WIDGET (g->current->data)))
|
||||
edit = (WEdit *) (g->current->data);
|
||||
else
|
||||
{
|
||||
edit = find_editor (h);
|
||||
|
@ -311,6 +311,7 @@ editcmd_dialog_raw_key_query (const char *heading, const char *query, gboolean c
|
||||
int w, wq;
|
||||
int y = 2;
|
||||
WDialog *raw_dlg;
|
||||
WGroup *g;
|
||||
|
||||
w = str_term_width1 (heading) + 6;
|
||||
wq = str_term_width1 (query);
|
||||
@ -319,17 +320,19 @@ editcmd_dialog_raw_key_query (const char *heading, const char *query, gboolean c
|
||||
raw_dlg =
|
||||
dlg_create (TRUE, 0, 0, cancel ? 7 : 5, w, WPOS_CENTER | WPOS_TRYUP, FALSE, dialog_colors,
|
||||
editcmd_dialog_raw_key_query_cb, NULL, NULL, heading);
|
||||
g = GROUP (raw_dlg);
|
||||
widget_want_tab (WIDGET (raw_dlg), TRUE);
|
||||
|
||||
add_widget (raw_dlg, label_new (y, 3, query));
|
||||
add_widget (raw_dlg, input_new (y++, 3 + wq + 1, input_colors,
|
||||
w - (6 + wq + 1), "", 0, INPUT_COMPLETE_NONE));
|
||||
group_add_widget (g, label_new (y, 3, query));
|
||||
group_add_widget (g,
|
||||
input_new (y++, 3 + wq + 1, input_colors, w - (6 + wq + 1), "", 0,
|
||||
INPUT_COMPLETE_NONE));
|
||||
if (cancel)
|
||||
{
|
||||
add_widget (raw_dlg, hline_new (y++, -1, -1));
|
||||
group_add_widget (g, hline_new (y++, -1, -1));
|
||||
/* Button w/o hotkey to allow use any key as raw or macro one */
|
||||
add_widget_autopos (raw_dlg, button_new (y, 1, B_CANCEL, NORMAL_BUTTON, _("Cancel"), NULL),
|
||||
WPOS_KEEP_TOP | WPOS_CENTER_HORZ, NULL);
|
||||
group_add_widget_autopos (g, button_new (y, 1, B_CANCEL, NORMAL_BUTTON, _("Cancel"), NULL),
|
||||
WPOS_KEEP_TOP | WPOS_CENTER_HORZ, NULL);
|
||||
}
|
||||
|
||||
w = dlg_run (raw_dlg);
|
||||
@ -384,7 +387,7 @@ editcmd_dialog_completion_show (const WEdit * edit, int max_len, GString ** comp
|
||||
compl_list = listbox_new (1, 1, compl_dlg_h - 2, compl_dlg_w - 2, FALSE, NULL);
|
||||
|
||||
/* add the dialog */
|
||||
add_widget (compl_dlg, compl_list);
|
||||
group_add_widget (GROUP (compl_dlg), compl_list);
|
||||
|
||||
/* fill the listbox with the completions */
|
||||
for (i = num_compl - 1; i >= 0; i--) /* reverse order */
|
||||
@ -443,7 +446,7 @@ editcmd_dialog_select_definition_show (WEdit * edit, char *match_expr, int max_l
|
||||
def_dlg = dlg_create (TRUE, start_y, start_x, def_dlg_h, def_dlg_w, WPOS_KEEP_DEFAULT, TRUE,
|
||||
dialog_colors, NULL, NULL, "[Definitions]", match_expr);
|
||||
def_list = listbox_new (1, 1, def_dlg_h - 2, def_dlg_w - 2, FALSE, NULL);
|
||||
add_widget (def_dlg, def_list);
|
||||
group_add_widget (GROUP (def_dlg), def_list);
|
||||
|
||||
/* fill the listbox with the completions */
|
||||
for (i = 0; i < num_lines; i++)
|
||||
|
@ -197,7 +197,7 @@ edit_options_dialog (WDialog * h)
|
||||
old_syntax_hl = option_syntax_highlighting;
|
||||
|
||||
if (!option_cursor_beyond_eol)
|
||||
g_list_foreach (h->widgets, edit_reset_over_col, NULL);
|
||||
g_list_foreach (GROUP (h)->widgets, edit_reset_over_col, NULL);
|
||||
|
||||
if (p != NULL)
|
||||
{
|
||||
@ -233,7 +233,7 @@ edit_options_dialog (WDialog * h)
|
||||
|
||||
/* Load or unload syntax rules if the option has changed */
|
||||
if (option_syntax_highlighting != old_syntax_hl)
|
||||
g_list_foreach (h->widgets, edit_reload_syntax, NULL);
|
||||
g_list_foreach (GROUP (h)->widgets, edit_reload_syntax, NULL);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -192,8 +192,8 @@ edit_restore_size (WEdit * edit)
|
||||
|
||||
edit->drag_state = MCEDIT_DRAG_NONE;
|
||||
w->mouse.forced_capture = FALSE;
|
||||
widget_set_size (w, edit->y_prev, edit->x_prev, edit->lines_prev, edit->cols_prev);
|
||||
dlg_draw (w->owner);
|
||||
widget_set_size_rect (w, &edit->loc_prev);
|
||||
widget_draw (WIDGET (w->owner));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -233,7 +233,7 @@ edit_window_move (WEdit * edit, long command)
|
||||
}
|
||||
|
||||
edit->force |= REDRAW_PAGE;
|
||||
dlg_draw (w->owner);
|
||||
widget_draw (WIDGET (w->owner));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -273,7 +273,7 @@ edit_window_resize (WEdit * edit, long command)
|
||||
}
|
||||
|
||||
edit->force |= REDRAW_COMPLETELY;
|
||||
dlg_draw (w->owner);
|
||||
widget_draw (WIDGET (w->owner));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -295,7 +295,9 @@ get_hotkey (int n)
|
||||
static void
|
||||
edit_window_list (const WDialog * h)
|
||||
{
|
||||
const size_t dlg_num = g_list_length (h->widgets) - 2; /* 2 = skip menu and buttonbar */
|
||||
const WGroup *g = CONST_GROUP (h);
|
||||
const size_t offset = 2; /* skip menu and buttonbar */
|
||||
const size_t dlg_num = g_list_length (g->widgets) - offset;
|
||||
int lines, cols;
|
||||
Listbox *listbox;
|
||||
GList *w;
|
||||
@ -307,7 +309,7 @@ edit_window_list (const WDialog * h)
|
||||
|
||||
listbox = create_listbox_window (lines, cols, _("Open files"), "[Open files]");
|
||||
|
||||
for (w = h->widgets; w != NULL; w = g_list_next (w))
|
||||
for (w = g->widgets; w != NULL; w = g_list_next (w))
|
||||
if (edit_widget_is_editor (CONST_WIDGET (w->data)))
|
||||
{
|
||||
WEdit *e = (WEdit *) w->data;
|
||||
@ -325,7 +327,7 @@ edit_window_list (const WDialog * h)
|
||||
g_free (fname);
|
||||
}
|
||||
|
||||
selected = run_listbox_with_data (listbox, h->current->data);
|
||||
selected = run_listbox_with_data (listbox, g->current->data);
|
||||
if (selected != NULL)
|
||||
widget_select (WIDGET (selected));
|
||||
}
|
||||
@ -379,6 +381,7 @@ edit_get_title (const WDialog * h, size_t len)
|
||||
static cb_ret_t
|
||||
edit_dialog_command_execute (WDialog * h, long command)
|
||||
{
|
||||
WGroup *g = GROUP (h);
|
||||
Widget *wh = WIDGET (h);
|
||||
cb_ret_t ret = MSG_HANDLED;
|
||||
|
||||
@ -401,8 +404,8 @@ edit_dialog_command_execute (WDialog * h, long command)
|
||||
break;
|
||||
case CK_Close:
|
||||
/* if there are no opened files anymore, close MC editor */
|
||||
if (edit_widget_is_editor (CONST_WIDGET (h->current->data)) &&
|
||||
edit_close_cmd ((WEdit *) h->current->data) && find_editor (h) == NULL)
|
||||
if (edit_widget_is_editor (CONST_WIDGET (g->current->data)) &&
|
||||
edit_close_cmd ((WEdit *) g->current->data) && find_editor (h) == NULL)
|
||||
dlg_stop (h);
|
||||
break;
|
||||
case CK_Help:
|
||||
@ -416,7 +419,7 @@ edit_dialog_command_execute (WDialog * h, long command)
|
||||
case CK_Cancel:
|
||||
/* don't close editor due to SIGINT, but stop move/resize window */
|
||||
{
|
||||
Widget *w = WIDGET (h->current->data);
|
||||
Widget *w = WIDGET (g->current->data);
|
||||
|
||||
if (edit_widget_is_editor (w) && ((WEdit *) w)->drag_state != MCEDIT_DRAG_NONE)
|
||||
edit_restore_size ((WEdit *) w);
|
||||
@ -450,17 +453,17 @@ edit_dialog_command_execute (WDialog * h, long command)
|
||||
break;
|
||||
case CK_WindowMove:
|
||||
case CK_WindowResize:
|
||||
if (edit_widget_is_editor (CONST_WIDGET (h->current->data)))
|
||||
edit_handle_move_resize ((WEdit *) h->current->data, command);
|
||||
if (edit_widget_is_editor (CONST_WIDGET (g->current->data)))
|
||||
edit_handle_move_resize ((WEdit *) g->current->data, command);
|
||||
break;
|
||||
case CK_WindowList:
|
||||
edit_window_list (h);
|
||||
break;
|
||||
case CK_WindowNext:
|
||||
dlg_select_next_widget (h);
|
||||
group_select_next_widget (g);
|
||||
break;
|
||||
case CK_WindowPrev:
|
||||
dlg_select_prev_widget (h);
|
||||
group_select_prev_widget (g);
|
||||
break;
|
||||
case CK_Options:
|
||||
edit_options_dialog (h);
|
||||
@ -488,11 +491,12 @@ edit_dialog_command_execute (WDialog * h, long command)
|
||||
static gboolean
|
||||
edit_translate_key (WEdit * edit, long x_key, int *cmd, int *ch)
|
||||
{
|
||||
Widget *w = WIDGET (edit);
|
||||
long command = CK_InsertChar;
|
||||
int char_for_insertion = -1;
|
||||
|
||||
/* an ordinary insertable character */
|
||||
if (!edit->extmod && x_key < 256)
|
||||
if (!w->ext_mode && x_key < 256)
|
||||
{
|
||||
#ifndef HAVE_CHARSET
|
||||
if (is_printable (x_key))
|
||||
@ -585,14 +589,7 @@ edit_translate_key (WEdit * edit, long x_key, int *cmd, int *ch)
|
||||
}
|
||||
|
||||
/* Commands specific to the key emulation */
|
||||
if (edit->extmod)
|
||||
{
|
||||
edit->extmod = FALSE;
|
||||
command = keybind_lookup_keymap_command (editor_x_map, x_key);
|
||||
}
|
||||
else
|
||||
command = keybind_lookup_keymap_command (editor_map, x_key);
|
||||
|
||||
command = widget_lookup_key (w, x_key);
|
||||
if (command == CK_IgnoreKey)
|
||||
command = CK_InsertChar;
|
||||
|
||||
@ -618,7 +615,7 @@ edit_quit (WDialog * h)
|
||||
widget_set_state (WIDGET (h), WST_ACTIVE, TRUE);
|
||||
|
||||
/* check window state and get modified files */
|
||||
for (l = h->widgets; l != NULL; l = g_list_next (l))
|
||||
for (l = GROUP (h)->widgets; l != NULL; l = g_list_next (l))
|
||||
if (edit_widget_is_editor (CONST_WIDGET (l->data)))
|
||||
{
|
||||
e = (WEdit *) l->data;
|
||||
@ -658,16 +655,18 @@ edit_quit (WDialog * h)
|
||||
static inline void
|
||||
edit_set_buttonbar (WEdit * edit, WButtonBar * bb)
|
||||
{
|
||||
buttonbar_set_label (bb, 1, Q_ ("ButtonBar|Help"), editor_map, NULL);
|
||||
buttonbar_set_label (bb, 2, Q_ ("ButtonBar|Save"), editor_map, WIDGET (edit));
|
||||
buttonbar_set_label (bb, 3, Q_ ("ButtonBar|Mark"), editor_map, WIDGET (edit));
|
||||
buttonbar_set_label (bb, 4, Q_ ("ButtonBar|Replac"), editor_map, WIDGET (edit));
|
||||
buttonbar_set_label (bb, 5, Q_ ("ButtonBar|Copy"), editor_map, WIDGET (edit));
|
||||
buttonbar_set_label (bb, 6, Q_ ("ButtonBar|Move"), editor_map, WIDGET (edit));
|
||||
buttonbar_set_label (bb, 7, Q_ ("ButtonBar|Search"), editor_map, WIDGET (edit));
|
||||
buttonbar_set_label (bb, 8, Q_ ("ButtonBar|Delete"), editor_map, WIDGET (edit));
|
||||
buttonbar_set_label (bb, 9, Q_ ("ButtonBar|PullDn"), editor_map, NULL);
|
||||
buttonbar_set_label (bb, 10, Q_ ("ButtonBar|Quit"), editor_map, NULL);
|
||||
Widget *w = WIDGET (edit);
|
||||
|
||||
buttonbar_set_label (bb, 1, Q_ ("ButtonBar|Help"), w->keymap, NULL);
|
||||
buttonbar_set_label (bb, 2, Q_ ("ButtonBar|Save"), w->keymap, w);
|
||||
buttonbar_set_label (bb, 3, Q_ ("ButtonBar|Mark"), w->keymap, w);
|
||||
buttonbar_set_label (bb, 4, Q_ ("ButtonBar|Replac"), w->keymap, w);
|
||||
buttonbar_set_label (bb, 5, Q_ ("ButtonBar|Copy"), w->keymap, w);
|
||||
buttonbar_set_label (bb, 6, Q_ ("ButtonBar|Move"), w->keymap, w);
|
||||
buttonbar_set_label (bb, 7, Q_ ("ButtonBar|Search"), w->keymap, w);
|
||||
buttonbar_set_label (bb, 8, Q_ ("ButtonBar|Delete"), w->keymap, w);
|
||||
buttonbar_set_label (bb, 9, Q_ ("ButtonBar|PullDn"), w->keymap, NULL);
|
||||
buttonbar_set_label (bb, 10, Q_ ("ButtonBar|Quit"), w->keymap, NULL);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -746,6 +745,7 @@ edit_update_cursor (WEdit * edit, const mouse_event_t * event)
|
||||
static cb_ret_t
|
||||
edit_dialog_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
|
||||
{
|
||||
WGroup *g = GROUP (w);
|
||||
WDialog *h = DIALOG (w);
|
||||
|
||||
switch (msg)
|
||||
@ -754,12 +754,6 @@ edit_dialog_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, v
|
||||
edit_dlg_init ();
|
||||
return MSG_HANDLED;
|
||||
|
||||
case MSG_DRAW:
|
||||
/* don't use dlg_default_repaint() -- we don't need a frame */
|
||||
tty_setcolor (EDITOR_BACKGROUND);
|
||||
dlg_erase (h);
|
||||
return MSG_HANDLED;
|
||||
|
||||
case MSG_RESIZE:
|
||||
dlg_default_callback (w, NULL, MSG_RESIZE, 0, NULL);
|
||||
menubar_arrange (find_menubar (h));
|
||||
@ -776,35 +770,35 @@ edit_dialog_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, v
|
||||
/* We forward any commands coming from the menu, and which haven't been
|
||||
handled by the dialog, to the focused WEdit window. */
|
||||
if (result == MSG_NOT_HANDLED && sender == WIDGET (find_menubar (h)))
|
||||
result = send_message (h->current->data, NULL, MSG_ACTION, parm, NULL);
|
||||
result = send_message (g->current->data, NULL, MSG_ACTION, parm, NULL);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
case MSG_KEY:
|
||||
{
|
||||
Widget *we = WIDGET (h->current->data);
|
||||
Widget *we = WIDGET (g->current->data);
|
||||
cb_ret_t ret = MSG_NOT_HANDLED;
|
||||
|
||||
if (edit_widget_is_editor (we))
|
||||
{
|
||||
WEdit *e = (WEdit *) we;
|
||||
gboolean ext_mode;
|
||||
long command;
|
||||
|
||||
if (!e->extmod)
|
||||
command = keybind_lookup_keymap_command (editor_map, parm);
|
||||
else
|
||||
command = keybind_lookup_keymap_command (editor_x_map, parm);
|
||||
/* keep and then extmod flag */
|
||||
ext_mode = we->ext_mode;
|
||||
command = widget_lookup_key (we, parm);
|
||||
we->ext_mode = ext_mode;
|
||||
|
||||
if (command == CK_IgnoreKey)
|
||||
e->extmod = FALSE;
|
||||
we->ext_mode = FALSE;
|
||||
else
|
||||
{
|
||||
ret = edit_dialog_command_execute (h, command);
|
||||
/* if command was not handled, keep the extended mode
|
||||
for the further key processing */
|
||||
if (ret == MSG_HANDLED)
|
||||
e->extmod = FALSE;
|
||||
we->ext_mode = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -834,7 +828,7 @@ edit_dialog_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, v
|
||||
|
||||
case MSG_IDLE:
|
||||
widget_idle (w, FALSE);
|
||||
return send_message (h->current->data, NULL, MSG_IDLE, 0, NULL);
|
||||
return send_message (g->current->data, NULL, MSG_IDLE, 0, NULL);
|
||||
|
||||
default:
|
||||
return dlg_default_callback (w, sender, msg, parm, data);
|
||||
@ -857,6 +851,7 @@ edit_dialog_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event)
|
||||
|
||||
if (msg == MSG_MOUSE_DOWN && event->y == 0)
|
||||
{
|
||||
WGroup *g = GROUP (w);
|
||||
WDialog *h = DIALOG (w);
|
||||
WMenuBar *b;
|
||||
|
||||
@ -871,7 +866,7 @@ edit_dialog_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event)
|
||||
int x;
|
||||
|
||||
/* Try find top fullscreen window */
|
||||
for (l = h->widgets; l != NULL; l = g_list_next (l))
|
||||
for (l = g->widgets; l != NULL; l = g_list_next (l))
|
||||
if (edit_widget_is_editor (CONST_WIDGET (l->data))
|
||||
&& ((WEdit *) l->data)->fullscreen)
|
||||
top = l;
|
||||
@ -883,7 +878,7 @@ edit_dialog_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event)
|
||||
{
|
||||
WEdit *e = (WEdit *) top->data;
|
||||
|
||||
if (top != h->current)
|
||||
if (top != g->current)
|
||||
{
|
||||
/* Window is not active. Activate it */
|
||||
widget_select (WIDGET (e));
|
||||
@ -909,6 +904,31 @@ edit_dialog_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static cb_ret_t
|
||||
edit_dialog_bg_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
|
||||
{
|
||||
switch (msg)
|
||||
{
|
||||
case MSG_INIT:
|
||||
{
|
||||
Widget *wo = WIDGET (w->owner);
|
||||
|
||||
w->y = wo->y + 1;
|
||||
w->x = wo->x;
|
||||
w->lines = wo->lines - 2;
|
||||
w->cols = wo->cols;
|
||||
w->pos_flags |= WPOS_KEEP_ALL;
|
||||
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
|
||||
default:
|
||||
return background_callback (w, sender, msg, parm, data);
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static cb_ret_t
|
||||
edit_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
|
||||
{
|
||||
@ -917,7 +937,7 @@ edit_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *da
|
||||
switch (msg)
|
||||
{
|
||||
case MSG_FOCUS:
|
||||
edit_set_buttonbar (e, find_buttonbar (w->owner));
|
||||
edit_set_buttonbar (e, find_buttonbar (DIALOG (w->owner)));
|
||||
return MSG_HANDLED;
|
||||
|
||||
case MSG_DRAW:
|
||||
@ -1029,7 +1049,7 @@ edit_mouse_handle_move_resize (Widget * w, mouse_msg_t msg, mouse_event_t * even
|
||||
edit->force |= REDRAW_COMPLETELY; /* Not really needed as WEdit's MSG_DRAW already does this. */
|
||||
|
||||
/* We draw the whole dialog because dragging/resizing exposes area beneath. */
|
||||
dlg_draw (w->owner);
|
||||
widget_draw (WIDGET (w->owner));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -1187,6 +1207,7 @@ edit_files (const GList * files)
|
||||
{
|
||||
static gboolean made_directory = FALSE;
|
||||
WDialog *edit_dlg;
|
||||
WGroup *g;
|
||||
WMenuBar *menubar;
|
||||
Widget *w, *wd;
|
||||
const GList *file;
|
||||
@ -1215,17 +1236,26 @@ edit_files (const GList * files)
|
||||
edit_dialog_mouse_callback, "[Internal File Editor]", NULL);
|
||||
wd = WIDGET (edit_dlg);
|
||||
widget_want_tab (wd, TRUE);
|
||||
wd->keymap = editor_map;
|
||||
wd->ext_keymap = editor_x_map;
|
||||
|
||||
edit_dlg->get_shortcut = edit_get_shortcut;
|
||||
edit_dlg->get_title = edit_get_title;
|
||||
|
||||
g = GROUP (edit_dlg);
|
||||
|
||||
edit_dlg->bg =
|
||||
WIDGET (background_new
|
||||
(1, 0, wd->lines - 2, wd->cols, EDITOR_BACKGROUND, ' ', edit_dialog_bg_callback));
|
||||
group_add_widget (g, edit_dlg->bg);
|
||||
|
||||
menubar = menubar_new (NULL, TRUE);
|
||||
w = WIDGET (menubar);
|
||||
add_widget_autopos (edit_dlg, w, w->pos_flags, NULL);
|
||||
group_add_widget_autopos (g, w, w->pos_flags, NULL);
|
||||
edit_init_menu (menubar);
|
||||
|
||||
w = WIDGET (buttonbar_new (TRUE));
|
||||
add_widget_autopos (edit_dlg, w, w->pos_flags, NULL);
|
||||
group_add_widget_autopos (g, w, w->pos_flags, NULL);
|
||||
|
||||
for (file = files; file != NULL; file = g_list_next (file))
|
||||
{
|
||||
@ -1260,9 +1290,11 @@ edit_get_file_name (const WEdit * edit)
|
||||
WEdit *
|
||||
find_editor (const WDialog * h)
|
||||
{
|
||||
if (edit_widget_is_editor (CONST_WIDGET (h->current->data)))
|
||||
return (WEdit *) h->current->data;
|
||||
return (WEdit *) find_widget_type (h, edit_callback);
|
||||
const WGroup *g = CONST_GROUP (h);
|
||||
|
||||
if (edit_widget_is_editor (CONST_WIDGET (g->current->data)))
|
||||
return (WEdit *) g->current->data;
|
||||
return (WEdit *) widget_find_by_type (CONST_WIDGET (h), edit_callback);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -1284,8 +1316,6 @@ edit_widget_is_editor (const Widget * w)
|
||||
void
|
||||
edit_update_screen (WEdit * e)
|
||||
{
|
||||
WDialog *h = WIDGET (e)->owner;
|
||||
|
||||
edit_scroll_screen_over_cursor (e);
|
||||
edit_update_curs_col (e);
|
||||
edit_status (e, widget_get_state (WIDGET (e), WST_FOCUSED));
|
||||
@ -1300,7 +1330,7 @@ edit_update_screen (WEdit * e)
|
||||
edit_render_keypress (e);
|
||||
}
|
||||
|
||||
widget_draw (WIDGET (find_buttonbar (h)));
|
||||
widget_draw (WIDGET (find_buttonbar (DIALOG (WIDGET (e)->owner))));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -1315,10 +1345,7 @@ edit_save_size (WEdit * edit)
|
||||
{
|
||||
Widget *w = WIDGET (edit);
|
||||
|
||||
edit->y_prev = w->y;
|
||||
edit->x_prev = w->x;
|
||||
edit->lines_prev = w->lines;
|
||||
edit->cols_prev = w->cols;
|
||||
rect_init (&edit->loc_prev, w->y, w->x, w->lines, w->cols);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -1350,9 +1377,9 @@ edit_add_window (WDialog * h, int y, int x, int lines, int cols, const vfs_path_
|
||||
w->callback = edit_callback;
|
||||
w->mouse_callback = edit_mouse_callback;
|
||||
|
||||
add_widget_autopos (h, w, WPOS_KEEP_ALL, NULL);
|
||||
group_add_widget_autopos (GROUP (h), w, WPOS_KEEP_ALL, NULL);
|
||||
edit_set_buttonbar (edit, find_buttonbar (h));
|
||||
dlg_draw (h);
|
||||
widget_draw (WIDGET (h));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -68,8 +68,7 @@ struct WEdit
|
||||
int drag_state_start; /* save cursor position before window moving */
|
||||
|
||||
/* save location before move/resize or toggle to fullscreen */
|
||||
int x_prev, y_prev;
|
||||
int cols_prev, lines_prev;
|
||||
WRect loc_prev;
|
||||
|
||||
vfs_path_t *filename_vpath; /* Name of the file */
|
||||
vfs_path_t *dir_vpath; /* NULL if filename is absolute */
|
||||
@ -162,7 +161,6 @@ struct WEdit
|
||||
|
||||
/* line break */
|
||||
LineBreaks lb;
|
||||
gboolean extmod;
|
||||
};
|
||||
|
||||
/*** global variables defined in .c file *********************************************************/
|
||||
|
@ -72,6 +72,7 @@ spell_dialog_spell_suggest_show (WEdit * edit, const char *word, char **new_word
|
||||
int res;
|
||||
char *curr = NULL;
|
||||
WDialog *sug_dlg;
|
||||
WGroup *g;
|
||||
WListbox *sug_list;
|
||||
int max_btn_len = 0;
|
||||
int replace_len;
|
||||
@ -111,22 +112,23 @@ spell_dialog_spell_suggest_show (WEdit * edit, const char *word, char **new_word
|
||||
|
||||
sug_dlg = dlg_create (TRUE, ypos, xpos, sug_dlg_h, sug_dlg_w, WPOS_KEEP_DEFAULT, TRUE,
|
||||
dialog_colors, NULL, NULL, "[ASpell]", _("Check word"));
|
||||
g = GROUP (sug_dlg);
|
||||
|
||||
add_widget (sug_dlg, label_new (1, 2, lang_label));
|
||||
add_widget (sug_dlg, label_new (3, 2, word_label));
|
||||
group_add_widget (g, label_new (1, 2, lang_label));
|
||||
group_add_widget (g, label_new (3, 2, word_label));
|
||||
|
||||
add_widget (sug_dlg, groupbox_new (4, 2, sug_dlg_h - 5, 25, _("Suggest")));
|
||||
group_add_widget (g, groupbox_new (4, 2, sug_dlg_h - 5, 25, _("Suggest")));
|
||||
|
||||
sug_list = listbox_new (5, 2, sug_dlg_h - 7, 24, FALSE, NULL);
|
||||
for (i = 0; i < suggest->len; i++)
|
||||
listbox_add_item (sug_list, LISTBOX_APPEND_AT_END, 0, g_array_index (suggest, char *, i),
|
||||
NULL, FALSE);
|
||||
add_widget (sug_dlg, sug_list);
|
||||
group_add_widget (g, sug_list);
|
||||
|
||||
add_widget (sug_dlg, add_btn);
|
||||
add_widget (sug_dlg, replace_btn);
|
||||
add_widget (sug_dlg, skip_btn);
|
||||
add_widget (sug_dlg, cancel_button);
|
||||
group_add_widget (g, add_btn);
|
||||
group_add_widget (g, replace_btn);
|
||||
group_add_widget (g, skip_btn);
|
||||
group_add_widget (g, cancel_button);
|
||||
|
||||
res = dlg_run (sug_dlg);
|
||||
if (res == B_ENTER)
|
||||
|
@ -554,13 +554,6 @@ toggle_subshell (void)
|
||||
do_load_prompt ();
|
||||
if (new_dir_vpath != NULL)
|
||||
do_possible_cd (new_dir_vpath);
|
||||
if (mc_global.tty.console_flag != '\0' && output_lines != 0)
|
||||
{
|
||||
unsigned char end_line;
|
||||
|
||||
end_line = LINES - (mc_global.keybar_visible ? 1 : 0) - 1;
|
||||
show_console_contents (output_start_y, end_line - output_lines, end_line);
|
||||
}
|
||||
}
|
||||
else if (new_dir_vpath != NULL && mc_chdir (new_dir_vpath) != -1)
|
||||
vfs_setup_cwd ();
|
||||
|
@ -281,8 +281,6 @@ print_flags (const WDialog * h)
|
||||
static void
|
||||
advanced_chown_refresh (WDialog * h)
|
||||
{
|
||||
dlg_default_repaint (h);
|
||||
|
||||
tty_setcolor (COLOR_NORMAL);
|
||||
|
||||
widget_gotoyx (h, BY - 1, advanced_chown_but[0].x + 5);
|
||||
@ -320,11 +318,11 @@ advanced_chown_info_update (void)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
update_mode (WDialog * h)
|
||||
update_mode (WGroup * g)
|
||||
{
|
||||
print_flags (h);
|
||||
print_flags (DIALOG (g));
|
||||
advanced_chown_info_update ();
|
||||
widget_set_state (WIDGET (h->current->data), WST_FOCUSED, TRUE);
|
||||
widget_set_state (WIDGET (g->current->data), WST_FOCUSED, TRUE);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -333,6 +331,7 @@ static cb_ret_t
|
||||
perm_button_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
|
||||
{
|
||||
WButton *b = BUTTON (w);
|
||||
WGroup *g = w->owner;
|
||||
int i = 0;
|
||||
int f_pos;
|
||||
|
||||
@ -365,10 +364,10 @@ perm_button_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, v
|
||||
case '+':
|
||||
flag_pos = f_pos * 3 + b->hotpos;
|
||||
ch_flags[flag_pos] = parm;
|
||||
update_mode (w->owner);
|
||||
update_mode (g);
|
||||
send_message (w, NULL, MSG_KEY, KEY_RIGHT, NULL);
|
||||
if (b->hotpos == 2)
|
||||
dlg_select_next_widget (w->owner);
|
||||
group_select_next_widget (g);
|
||||
break;
|
||||
|
||||
case XCTRL ('f'):
|
||||
@ -426,7 +425,7 @@ perm_button_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, v
|
||||
b->hotpos = i;
|
||||
flag_pos = f_pos * 3 + i;
|
||||
ch_flags[flag_pos] = '=';
|
||||
update_mode (w->owner);
|
||||
update_mode (g);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -528,7 +527,8 @@ user_group_button_cb (WButton * button, int action)
|
||||
|
||||
do
|
||||
{
|
||||
WDialog *h = w->owner;
|
||||
WGroup *g = w->owner;
|
||||
WDialog *h = DIALOG (h);
|
||||
Widget *wh = WIDGET (h);
|
||||
|
||||
gboolean is_owner = (f_pos == BUTTONS_PERM - 2);
|
||||
@ -587,7 +587,7 @@ user_group_button_cb (WButton * button, int action)
|
||||
listbox_select_entry (chl_list, fe);
|
||||
|
||||
b_pos = chl_list->pos;
|
||||
add_widget (chl_dlg, chl_list);
|
||||
group_add_widget (GROUP (chl_dlg), chl_list);
|
||||
|
||||
result = dlg_run (chl_dlg);
|
||||
|
||||
@ -619,12 +619,12 @@ user_group_button_cb (WButton * button, int action)
|
||||
}
|
||||
|
||||
if (!ok)
|
||||
dlg_select_current_widget (h);
|
||||
group_select_current_widget (g);
|
||||
else
|
||||
{
|
||||
ch_flags[f_pos + 6] = '+';
|
||||
update_ownership ();
|
||||
dlg_select_current_widget (h);
|
||||
group_select_current_widget (g);
|
||||
print_flags (h);
|
||||
}
|
||||
}
|
||||
@ -633,14 +633,14 @@ user_group_button_cb (WButton * button, int action)
|
||||
{
|
||||
if (!is_owner)
|
||||
chl_end = TRUE;
|
||||
dlg_select_prev_widget (h);
|
||||
group_select_prev_widget (g);
|
||||
f_pos--;
|
||||
}
|
||||
else if (result == KEY_RIGHT)
|
||||
{
|
||||
if (is_owner)
|
||||
chl_end = TRUE;
|
||||
dlg_select_next_widget (h);
|
||||
group_select_next_widget (g);
|
||||
f_pos++;
|
||||
}
|
||||
}
|
||||
@ -655,19 +655,32 @@ user_group_button_cb (WButton * button, int action)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static cb_ret_t
|
||||
advanced_chown_bg_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
|
||||
{
|
||||
switch (msg)
|
||||
{
|
||||
case MSG_DRAW:
|
||||
frame_callback (w, NULL, MSG_DRAW, 0, NULL);
|
||||
advanced_chown_refresh (DIALOG (w->owner));
|
||||
advanced_chown_info_update ();
|
||||
return MSG_HANDLED;
|
||||
|
||||
default:
|
||||
return frame_callback (w, sender, msg, parm, data);
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static cb_ret_t
|
||||
advanced_chown_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
|
||||
{
|
||||
WDialog *h = DIALOG (w);
|
||||
WGroup *g = GROUP (w);
|
||||
int i = 0;
|
||||
|
||||
switch (msg)
|
||||
{
|
||||
case MSG_DRAW:
|
||||
advanced_chown_refresh (h);
|
||||
advanced_chown_info_update ();
|
||||
return MSG_HANDLED;
|
||||
|
||||
case MSG_KEY:
|
||||
switch (parm)
|
||||
{
|
||||
@ -684,8 +697,8 @@ advanced_chown_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm
|
||||
for (i = 0; i < 3; i++)
|
||||
ch_flags[i * 3 + parm - 3] = (x_toggle & (1 << parm)) ? '-' : '+';
|
||||
x_toggle ^= (1 << parm);
|
||||
update_mode (h);
|
||||
dlg_broadcast_msg (h, MSG_DRAW);
|
||||
update_mode (g);
|
||||
widget_draw (w);
|
||||
break;
|
||||
|
||||
case XCTRL ('x'):
|
||||
@ -701,8 +714,8 @@ advanced_chown_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm
|
||||
for (i = 0; i < 3; i++)
|
||||
ch_flags[i * 3 + parm] = (x_toggle & (1 << parm)) ? '-' : '+';
|
||||
x_toggle ^= (1 << parm);
|
||||
update_mode (h);
|
||||
dlg_broadcast_msg (h, MSG_DRAW);
|
||||
update_mode (g);
|
||||
widget_draw (w);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -722,6 +735,7 @@ advanced_chown_init (void)
|
||||
{
|
||||
gboolean single_set;
|
||||
WDialog *ch_dlg;
|
||||
WGroup *ch_grp;
|
||||
int lines = 12;
|
||||
int cols = 74;
|
||||
int i;
|
||||
@ -738,67 +752,69 @@ advanced_chown_init (void)
|
||||
ch_dlg =
|
||||
dlg_create (TRUE, 0, 0, lines, cols, WPOS_CENTER, FALSE, dialog_colors,
|
||||
advanced_chown_callback, NULL, "[Advanced Chown]", _("Chown advanced command"));
|
||||
ch_grp = GROUP (ch_dlg);
|
||||
|
||||
/* draw background */
|
||||
ch_dlg->bg->callback = advanced_chown_bg_callback;
|
||||
|
||||
l_filename = label_new (2, 3, "");
|
||||
add_widget (ch_dlg, l_filename);
|
||||
group_add_widget (ch_grp, l_filename);
|
||||
|
||||
add_widget (ch_dlg, hline_new (3, -1, -1));
|
||||
group_add_widget (ch_grp, hline_new (3, -1, -1));
|
||||
|
||||
#define XTRACT(i,y,cb) y, BX+advanced_chown_but[i].x, \
|
||||
advanced_chown_but[i].ret_cmd, advanced_chown_but[i].flags, \
|
||||
(advanced_chown_but[i].text), cb
|
||||
b_att[0] = perm_button_new (XTRACT (0, BY, NULL));
|
||||
advanced_chown_but[0].id = add_widget (ch_dlg, b_att[0]);
|
||||
advanced_chown_but[0].id = group_add_widget (ch_grp, b_att[0]);
|
||||
b_att[1] = perm_button_new (XTRACT (1, BY, NULL));
|
||||
advanced_chown_but[1].id = add_widget (ch_dlg, b_att[1]);
|
||||
advanced_chown_but[1].id = group_add_widget (ch_grp, b_att[1]);
|
||||
b_att[2] = perm_button_new (XTRACT (2, BY, NULL));
|
||||
advanced_chown_but[2].id = add_widget (ch_dlg, b_att[2]);
|
||||
advanced_chown_but[2].id = group_add_widget (ch_grp, b_att[2]);
|
||||
b_user = button_new (XTRACT (3, BY, user_group_button_cb));
|
||||
advanced_chown_but[3].id = add_widget (ch_dlg, b_user);
|
||||
advanced_chown_but[3].id = group_add_widget (ch_grp, b_user);
|
||||
b_group = button_new (XTRACT (4, BY, user_group_button_cb));
|
||||
advanced_chown_but[4].id = add_widget (ch_dlg, b_group);
|
||||
#undef XTRACT
|
||||
advanced_chown_but[4].id = group_add_widget (ch_grp, b_group);
|
||||
|
||||
l_mode = label_new (BY + 2, 3, "");
|
||||
add_widget (ch_dlg, l_mode);
|
||||
group_add_widget (ch_grp, l_mode);
|
||||
|
||||
y = BY + 3;
|
||||
if (!single_set)
|
||||
{
|
||||
i = BUTTONS_PERM;
|
||||
add_widget (ch_dlg, hline_new (y++, -1, -1));
|
||||
advanced_chown_but[i].id = add_widget (ch_dlg,
|
||||
button_new (y,
|
||||
WIDGET (ch_dlg)->cols / 2 -
|
||||
advanced_chown_but[i].len,
|
||||
advanced_chown_but[i].ret_cmd,
|
||||
advanced_chown_but[i].flags,
|
||||
advanced_chown_but[i].text, NULL));
|
||||
group_add_widget (ch_grp, hline_new (y++, -1, -1));
|
||||
advanced_chown_but[i].id = group_add_widget (ch_grp,
|
||||
button_new (y,
|
||||
WIDGET (ch_dlg)->cols / 2 -
|
||||
advanced_chown_but[i].len,
|
||||
advanced_chown_but[i].ret_cmd,
|
||||
advanced_chown_but[i].flags,
|
||||
advanced_chown_but[i].text, NULL));
|
||||
i++;
|
||||
advanced_chown_but[i].id = add_widget (ch_dlg,
|
||||
button_new (y, WIDGET (ch_dlg)->cols / 2 + 1,
|
||||
advanced_chown_but[i].ret_cmd,
|
||||
advanced_chown_but[i].flags,
|
||||
advanced_chown_but[i].text, NULL));
|
||||
advanced_chown_but[i].id = group_add_widget (ch_grp,
|
||||
button_new (y, WIDGET (ch_dlg)->cols / 2 + 1,
|
||||
advanced_chown_but[i].ret_cmd,
|
||||
advanced_chown_but[i].flags,
|
||||
advanced_chown_but[i].text, NULL));
|
||||
y++;
|
||||
}
|
||||
|
||||
i = BUTTONS_PERM + 2;
|
||||
add_widget (ch_dlg, hline_new (y++, -1, -1));
|
||||
advanced_chown_but[i].id = add_widget (ch_dlg,
|
||||
button_new (y,
|
||||
WIDGET (ch_dlg)->cols / 2 -
|
||||
advanced_chown_but[i].len,
|
||||
advanced_chown_but[i].ret_cmd,
|
||||
advanced_chown_but[i].flags,
|
||||
advanced_chown_but[i].text, NULL));
|
||||
group_add_widget (ch_grp, hline_new (y++, -1, -1));
|
||||
advanced_chown_but[i].id = group_add_widget (ch_grp,
|
||||
button_new (y,
|
||||
WIDGET (ch_dlg)->cols / 2 -
|
||||
advanced_chown_but[i].len,
|
||||
advanced_chown_but[i].ret_cmd,
|
||||
advanced_chown_but[i].flags,
|
||||
advanced_chown_but[i].text, NULL));
|
||||
i++;
|
||||
advanced_chown_but[i].id = add_widget (ch_dlg,
|
||||
button_new (y, WIDGET (ch_dlg)->cols / 2 + 1,
|
||||
advanced_chown_but[i].ret_cmd,
|
||||
advanced_chown_but[i].flags,
|
||||
advanced_chown_but[i].text, NULL));
|
||||
advanced_chown_but[i].id = group_add_widget (ch_grp,
|
||||
button_new (y, WIDGET (ch_dlg)->cols / 2 + 1,
|
||||
advanced_chown_but[i].ret_cmd,
|
||||
advanced_chown_but[i].flags,
|
||||
advanced_chown_but[i].text, NULL));
|
||||
|
||||
widget_select (WIDGET (b_att[0]));
|
||||
|
||||
|
@ -136,7 +136,7 @@ configure_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, voi
|
||||
Widget *ww;
|
||||
|
||||
/* input line */
|
||||
ww = dlg_find_by_id (DIALOG (w), configure_time_out_id);
|
||||
ww = widget_find_by_id (w, configure_time_out_id);
|
||||
widget_disable (ww, not_single);
|
||||
|
||||
return MSG_HANDLED;
|
||||
@ -192,12 +192,13 @@ skin_dlg_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void
|
||||
WDialog *d = DIALOG (w);
|
||||
Widget *wd = WIDGET (d->data);
|
||||
int y, x;
|
||||
WRect r;
|
||||
|
||||
y = wd->y + (wd->lines - w->lines) / 2;
|
||||
x = wd->x + wd->cols / 2;
|
||||
dlg_set_position (d, y, x, w->lines, w->cols);
|
||||
rect_init (&r, y, x, w->lines, w->cols);
|
||||
|
||||
return MSG_HANDLED;
|
||||
return dlg_default_callback (w, NULL, MSG_RESIZE, 0, &r);
|
||||
}
|
||||
|
||||
default:
|
||||
@ -250,7 +251,7 @@ sel_skin_button (WButton * button, int action)
|
||||
}
|
||||
|
||||
/* make list stick to all sides of dialog, effectively make it be resized with dialog */
|
||||
add_widget_autopos (skin_dlg, skin_list, WPOS_KEEP_ALL, NULL);
|
||||
group_add_widget_autopos (GROUP (skin_dlg), skin_list, WPOS_KEEP_ALL, NULL);
|
||||
|
||||
result = dlg_run (skin_dlg);
|
||||
if (result == B_ENTER)
|
||||
@ -274,8 +275,6 @@ sel_skin_button (WButton * button, int action)
|
||||
static cb_ret_t
|
||||
panel_listing_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
|
||||
{
|
||||
WDialog *h = DIALOG (w);
|
||||
|
||||
switch (msg)
|
||||
{
|
||||
case MSG_NOTIFY:
|
||||
@ -284,10 +283,10 @@ panel_listing_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm,
|
||||
WCheck *ch;
|
||||
WInput *in1, *in2, *in3;
|
||||
|
||||
in1 = INPUT (dlg_find_by_id (h, panel_user_format_id));
|
||||
in2 = INPUT (dlg_find_by_id (h, panel_brief_cols_id));
|
||||
ch = CHECK (dlg_find_by_id (h, mini_user_status_id));
|
||||
in3 = INPUT (dlg_find_by_id (h, mini_user_format_id));
|
||||
in1 = INPUT (widget_find_by_id (w, panel_user_format_id));
|
||||
in2 = INPUT (widget_find_by_id (w, panel_brief_cols_id));
|
||||
ch = CHECK (widget_find_by_id (w, mini_user_status_id));
|
||||
in3 = INPUT (widget_find_by_id (w, mini_user_format_id));
|
||||
|
||||
if (!ch->state)
|
||||
input_assign_text (in3, status_format[RADIO (sender)->sel]);
|
||||
@ -303,7 +302,7 @@ panel_listing_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm,
|
||||
{
|
||||
WInput *in;
|
||||
|
||||
in = INPUT (dlg_find_by_id (h, mini_user_format_id));
|
||||
in = INPUT (widget_find_by_id (w, mini_user_format_id));
|
||||
|
||||
if (CHECK (sender)->state)
|
||||
{
|
||||
@ -314,7 +313,7 @@ panel_listing_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm,
|
||||
{
|
||||
WRadio *r;
|
||||
|
||||
r = RADIO (dlg_find_by_id (h, panel_list_formats_id));
|
||||
r = RADIO (widget_find_by_id (w, panel_list_formats_id));
|
||||
widget_disable (WIDGET (in), TRUE);
|
||||
input_assign_text (in, status_format[r->sel]);
|
||||
}
|
||||
@ -355,7 +354,7 @@ sel_charset_button (WButton * button, int action)
|
||||
cpname = _("7-bit ASCII"); /* FIXME */
|
||||
|
||||
button_set_text (button, cpname);
|
||||
dlg_draw (WIDGET (button)->owner);
|
||||
widget_draw (WIDGET (WIDGET (button)->owner));
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -373,10 +372,12 @@ tree_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *da
|
||||
{
|
||||
case MSG_RESIZE:
|
||||
{
|
||||
WRect r;
|
||||
Widget *bar;
|
||||
|
||||
/* simply call dlg_set_size() with new size */
|
||||
dlg_set_size (h, LINES - 9, COLS - 20);
|
||||
rect_init (&r, w->y, w->x, LINES - 9, COLS - 20);
|
||||
dlg_default_callback (w, NULL, MSG_RESIZE, 0, &r);
|
||||
|
||||
bar = WIDGET (find_buttonbar (h));
|
||||
bar->x = 0;
|
||||
bar->y = LINES - 1;
|
||||
@ -407,7 +408,7 @@ confvfs_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void
|
||||
Widget *wi;
|
||||
|
||||
/* input */
|
||||
wi = dlg_find_by_id (DIALOG (w), ftpfs_proxy_host_id);
|
||||
wi = widget_find_by_id (w, ftpfs_proxy_host_id);
|
||||
widget_disable (wi, not_use);
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
@ -484,7 +485,7 @@ task_cb (WButton * button, int action)
|
||||
jobs_fill_listbox (bg_list);
|
||||
|
||||
/* This can be optimized to just redraw this widget :-) */
|
||||
dlg_draw (WIDGET (button)->owner);
|
||||
widget_draw (WIDGET (WIDGET (button)->owner));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1024,6 +1025,7 @@ tree_box (const char *current_dir)
|
||||
{
|
||||
WTree *mytree;
|
||||
WDialog *dlg;
|
||||
WGroup *g;
|
||||
Widget *wd;
|
||||
char *val = NULL;
|
||||
WButtonBar *bar;
|
||||
@ -1033,13 +1035,14 @@ tree_box (const char *current_dir)
|
||||
/* Create the components */
|
||||
dlg = dlg_create (TRUE, 0, 0, LINES - 9, COLS - 20, WPOS_CENTER, FALSE, dialog_colors,
|
||||
tree_callback, NULL, "[Directory Tree]", _("Directory tree"));
|
||||
g = GROUP (dlg);
|
||||
wd = WIDGET (dlg);
|
||||
|
||||
mytree = tree_new (2, 2, wd->lines - 6, wd->cols - 5, FALSE);
|
||||
add_widget_autopos (dlg, mytree, WPOS_KEEP_ALL, NULL);
|
||||
add_widget_autopos (dlg, hline_new (wd->lines - 4, 1, -1), WPOS_KEEP_BOTTOM, NULL);
|
||||
group_add_widget_autopos (g, mytree, WPOS_KEEP_ALL, NULL);
|
||||
group_add_widget_autopos (g, hline_new (wd->lines - 4, 1, -1), WPOS_KEEP_BOTTOM, NULL);
|
||||
bar = buttonbar_new (TRUE);
|
||||
add_widget (dlg, bar);
|
||||
group_add_widget (g, bar);
|
||||
/* restore ButtonBar coordinates after add_widget() */
|
||||
WIDGET (bar)->x = 0;
|
||||
WIDGET (bar)->y = LINES - 1;
|
||||
@ -1232,6 +1235,7 @@ jobs_box (void)
|
||||
const size_t n_but = G_N_ELEMENTS (job_but);
|
||||
|
||||
WDialog *jobs_dlg;
|
||||
WGroup *g;
|
||||
int cols = 60;
|
||||
int lines = 15;
|
||||
int x = 0;
|
||||
@ -1253,19 +1257,19 @@ jobs_box (void)
|
||||
|
||||
jobs_dlg = dlg_create (TRUE, 0, 0, lines, cols, WPOS_CENTER, FALSE, dialog_colors, NULL, NULL,
|
||||
"[Background jobs]", _("Background jobs"));
|
||||
g = GROUP (jobs_dlg);
|
||||
|
||||
bg_list = listbox_new (2, 2, lines - 6, cols - 6, FALSE, NULL);
|
||||
jobs_fill_listbox (bg_list);
|
||||
add_widget (jobs_dlg, bg_list);
|
||||
group_add_widget (g, bg_list);
|
||||
|
||||
add_widget (jobs_dlg, hline_new (lines - 4, -1, -1));
|
||||
group_add_widget (g, hline_new (lines - 4, -1, -1));
|
||||
|
||||
x = (cols - x) / 2;
|
||||
for (i = 0; i < n_but; i++)
|
||||
{
|
||||
add_widget (jobs_dlg,
|
||||
button_new (lines - 3, x, job_but[i].value, job_but[i].flags, job_but[i].name,
|
||||
job_but[i].callback));
|
||||
group_add_widget (g, button_new (lines - 3, x, job_but[i].value, job_but[i].flags,
|
||||
job_but[i].name, job_but[i].callback));
|
||||
x += job_but[i].len + 1;
|
||||
}
|
||||
|
||||
|
@ -191,13 +191,11 @@ chmod_toggle_select (WDialog * h, int Id)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
chmod_refresh (WDialog * h)
|
||||
chmod_refresh (void)
|
||||
{
|
||||
int y = WIDGET (file_gb)->y + 1;
|
||||
int x = WIDGET (file_gb)->x + 2;
|
||||
|
||||
dlg_default_repaint (h);
|
||||
|
||||
tty_setcolor (COLOR_NORMAL);
|
||||
|
||||
tty_gotoyx (y, x);
|
||||
@ -212,17 +210,31 @@ chmod_refresh (WDialog * h)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static cb_ret_t
|
||||
chmod_bg_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
|
||||
{
|
||||
switch (msg)
|
||||
{
|
||||
case MSG_DRAW:
|
||||
frame_callback (w, NULL, MSG_DRAW, 0, NULL);
|
||||
chmod_refresh ();
|
||||
return MSG_HANDLED;
|
||||
|
||||
default:
|
||||
return frame_callback (w, sender, msg, parm, data);
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static cb_ret_t
|
||||
chmod_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
|
||||
{
|
||||
WGroup *g = GROUP (w);
|
||||
WDialog *h = DIALOG (w);
|
||||
|
||||
switch (msg)
|
||||
{
|
||||
case MSG_DRAW:
|
||||
chmod_refresh (h);
|
||||
return MSG_HANDLED;
|
||||
|
||||
case MSG_NOTIFY:
|
||||
{
|
||||
/* handle checkboxes */
|
||||
@ -254,7 +266,7 @@ chmod_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d
|
||||
int i;
|
||||
unsigned long id;
|
||||
|
||||
id = dlg_get_current_widget_id (h);
|
||||
id = group_get_current_widget_id (g);
|
||||
for (i = 0; i < BUTTONS_PERM; i++)
|
||||
if (id == WIDGET (check_perm[i].check)->id)
|
||||
break;
|
||||
@ -263,7 +275,7 @@ chmod_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d
|
||||
{
|
||||
chmod_toggle_select (h, i);
|
||||
if (parm == KEY_IC)
|
||||
dlg_select_next_widget (h);
|
||||
group_select_next_widget (g);
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
}
|
||||
@ -281,6 +293,7 @@ chmod_init (const char *fname, const struct stat *sf_stat)
|
||||
{
|
||||
gboolean single_set;
|
||||
WDialog *ch_dlg;
|
||||
WGroup *g;
|
||||
int lines, cols;
|
||||
int i, y;
|
||||
int perm_gb_len;
|
||||
@ -309,61 +322,64 @@ chmod_init (const char *fname, const struct stat *sf_stat)
|
||||
ch_dlg =
|
||||
dlg_create (TRUE, 0, 0, lines, cols, WPOS_CENTER, FALSE, dialog_colors,
|
||||
chmod_callback, NULL, "[Chmod]", _("Chmod command"));
|
||||
g = GROUP (ch_dlg);
|
||||
|
||||
add_widget (ch_dlg, groupbox_new (PY, PX, BUTTONS_PERM + 2, perm_gb_len, _("Permission")));
|
||||
/* draw background */
|
||||
ch_dlg->bg->callback = chmod_bg_callback;
|
||||
|
||||
group_add_widget (g, groupbox_new (PY, PX, BUTTONS_PERM + 2, perm_gb_len, _("Permission")));
|
||||
|
||||
for (i = 0; i < BUTTONS_PERM; i++)
|
||||
{
|
||||
check_perm[i].check = check_new (PY + i + 1, PX + 2, (ch_mode & check_perm[i].mode) != 0,
|
||||
check_perm[i].text);
|
||||
add_widget (ch_dlg, check_perm[i].check);
|
||||
group_add_widget (g, check_perm[i].check);
|
||||
}
|
||||
|
||||
file_gb = groupbox_new (PY, PX + perm_gb_len + 1, BUTTONS_PERM + 2, file_gb_len, _("File"));
|
||||
add_widget (ch_dlg, file_gb);
|
||||
group_add_widget (g, file_gb);
|
||||
|
||||
/* Set the labels */
|
||||
y = PY + 2;
|
||||
cols = PX + perm_gb_len + 3;
|
||||
c_fname = str_trunc (fname, file_gb_len - 3);
|
||||
add_widget (ch_dlg, label_new (y, cols, c_fname));
|
||||
group_add_widget (g, label_new (y, cols, c_fname));
|
||||
g_snprintf (buffer, sizeof (buffer), "%o", (unsigned int) ch_mode);
|
||||
statl = label_new (y + 2, cols, buffer);
|
||||
add_widget (ch_dlg, statl);
|
||||
group_add_widget (g, statl);
|
||||
c_fown = str_trunc (get_owner (sf_stat->st_uid), file_gb_len - 3);
|
||||
add_widget (ch_dlg, label_new (y + 4, cols, c_fown));
|
||||
group_add_widget (g, label_new (y + 4, cols, c_fown));
|
||||
c_fgrp = str_trunc (get_group (sf_stat->st_gid), file_gb_len - 3);
|
||||
add_widget (ch_dlg, label_new (y + 6, cols, c_fgrp));
|
||||
group_add_widget (g, label_new (y + 6, cols, c_fgrp));
|
||||
|
||||
if (!single_set)
|
||||
{
|
||||
i = 0;
|
||||
add_widget (ch_dlg, hline_new (lines - chmod_but[i].y - 1, -1, -1));
|
||||
|
||||
group_add_widget (g, hline_new (lines - chmod_but[i].y - 1, -1, -1));
|
||||
|
||||
for (; i < BUTTONS - 2; i++)
|
||||
{
|
||||
y = lines - chmod_but[i].y;
|
||||
add_widget (ch_dlg,
|
||||
button_new (y, WIDGET (ch_dlg)->cols / 2 - chmod_but[i].len,
|
||||
chmod_but[i].ret_cmd, chmod_but[i].flags, chmod_but[i].text,
|
||||
NULL));
|
||||
group_add_widget (g, button_new (y, WIDGET (ch_dlg)->cols / 2 - chmod_but[i].len,
|
||||
chmod_but[i].ret_cmd, chmod_but[i].flags,
|
||||
chmod_but[i].text, NULL));
|
||||
i++;
|
||||
add_widget (ch_dlg,
|
||||
button_new (y, WIDGET (ch_dlg)->cols / 2 + 1,
|
||||
chmod_but[i].ret_cmd, chmod_but[i].flags, chmod_but[i].text,
|
||||
NULL));
|
||||
group_add_widget (g, button_new (y, WIDGET (ch_dlg)->cols / 2 + 1,
|
||||
chmod_but[i].ret_cmd, chmod_but[i].flags,
|
||||
chmod_but[i].text, NULL));
|
||||
}
|
||||
}
|
||||
|
||||
i = BUTTONS - 2;
|
||||
y = lines - chmod_but[i].y;
|
||||
add_widget (ch_dlg, hline_new (y - 1, -1, -1));
|
||||
add_widget (ch_dlg,
|
||||
button_new (y, WIDGET (ch_dlg)->cols / 2 - chmod_but[i].len, chmod_but[i].ret_cmd,
|
||||
chmod_but[i].flags, chmod_but[i].text, NULL));
|
||||
group_add_widget (g, hline_new (y - 1, -1, -1));
|
||||
group_add_widget (g, button_new (y, WIDGET (ch_dlg)->cols / 2 - chmod_but[i].len,
|
||||
chmod_but[i].ret_cmd, chmod_but[i].flags, chmod_but[i].text,
|
||||
NULL));
|
||||
i++;
|
||||
add_widget (ch_dlg,
|
||||
button_new (y, WIDGET (ch_dlg)->cols / 2 + 1, chmod_but[i].ret_cmd,
|
||||
chmod_but[i].flags, chmod_but[i].text, NULL));
|
||||
group_add_widget (g, button_new (y, WIDGET (ch_dlg)->cols / 2 + 1, chmod_but[i].ret_cmd,
|
||||
chmod_but[i].flags, chmod_but[i].text, NULL));
|
||||
|
||||
/* select first checkbox */
|
||||
widget_select (WIDGET (check_perm[0].check));
|
||||
|
@ -148,13 +148,11 @@ chown_i18n (void)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
chown_refresh (WDialog * h)
|
||||
chown_refresh (const Widget * h)
|
||||
{
|
||||
int y = 3;
|
||||
int x = 7 + GW * 2;
|
||||
|
||||
dlg_default_repaint (h);
|
||||
|
||||
tty_setcolor (COLOR_NORMAL);
|
||||
|
||||
widget_gotoyx (h, y + 0, x);
|
||||
@ -172,16 +170,17 @@ chown_refresh (WDialog * h)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static cb_ret_t
|
||||
chown_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
|
||||
chown_bg_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
|
||||
{
|
||||
switch (msg)
|
||||
{
|
||||
case MSG_DRAW:
|
||||
chown_refresh (DIALOG (w));
|
||||
frame_callback (w, NULL, MSG_DRAW, 0, NULL);
|
||||
chown_refresh (WIDGET (w->owner));
|
||||
return MSG_HANDLED;
|
||||
|
||||
default:
|
||||
return dlg_default_callback (w, sender, msg, parm, data);
|
||||
return frame_callback (w, sender, msg, parm, data);
|
||||
}
|
||||
}
|
||||
|
||||
@ -192,6 +191,7 @@ chown_init (void)
|
||||
{
|
||||
int single_set;
|
||||
WDialog *ch_dlg;
|
||||
WGroup *g;
|
||||
int lines, cols;
|
||||
int i, y;
|
||||
struct passwd *l_pass;
|
||||
@ -202,12 +202,16 @@ chown_init (void)
|
||||
cols = GW * 3 + 2 + 6;
|
||||
|
||||
ch_dlg =
|
||||
dlg_create (TRUE, 0, 0, lines, cols, WPOS_CENTER, FALSE, dialog_colors, chown_callback,
|
||||
NULL, "[Chown]", _("Chown command"));
|
||||
dlg_create (TRUE, 0, 0, lines, cols, WPOS_CENTER, FALSE, dialog_colors, NULL, NULL,
|
||||
"[Chown]", _("Chown command"));
|
||||
g = GROUP (ch_dlg);
|
||||
|
||||
add_widget (ch_dlg, groupbox_new (2, 3, GH, GW, _("User name")));
|
||||
/* draw background */
|
||||
ch_dlg->bg->callback = chown_bg_callback;
|
||||
|
||||
group_add_widget (g, groupbox_new (2, 3, GH, GW, _("User name")));
|
||||
l_user = listbox_new (3, 4, GH - 2, GW - 2, FALSE, NULL);
|
||||
add_widget (ch_dlg, l_user);
|
||||
group_add_widget (g, l_user);
|
||||
/* add field for unknown names (numbers) */
|
||||
listbox_add_item (l_user, LISTBOX_APPEND_AT_END, 0, _("<Unknown user>"), NULL, FALSE);
|
||||
/* get and put user names in the listbox */
|
||||
@ -216,9 +220,9 @@ chown_init (void)
|
||||
listbox_add_item (l_user, LISTBOX_APPEND_SORTED, 0, l_pass->pw_name, NULL, FALSE);
|
||||
endpwent ();
|
||||
|
||||
add_widget (ch_dlg, groupbox_new (2, 4 + GW, GH, GW, _("Group name")));
|
||||
group_add_widget (g, groupbox_new (2, 4 + GW, GH, GW, _("Group name")));
|
||||
l_group = listbox_new (3, 5 + GW, GH - 2, GW - 2, FALSE, NULL);
|
||||
add_widget (ch_dlg, l_group);
|
||||
group_add_widget (g, l_group);
|
||||
/* add field for unknown names (numbers) */
|
||||
listbox_add_item (l_group, LISTBOX_APPEND_AT_END, 0, _("<Unknown group>"), NULL, FALSE);
|
||||
/* get and put group names in the listbox */
|
||||
@ -227,42 +231,40 @@ chown_init (void)
|
||||
listbox_add_item (l_group, LISTBOX_APPEND_SORTED, 0, l_grp->gr_name, NULL, FALSE);
|
||||
endgrent ();
|
||||
|
||||
add_widget (ch_dlg, groupbox_new (2, 5 + GW * 2, GH, GW, _("File")));
|
||||
group_add_widget (g, groupbox_new (2, 5 + GW * 2, GH, GW, _("File")));
|
||||
/* add widgets for the file information */
|
||||
for (i = 0; i < LABELS; i++)
|
||||
{
|
||||
chown_label[i].l = label_new (chown_label[i].y, 7 + GW * 2, "");
|
||||
add_widget (ch_dlg, chown_label[i].l);
|
||||
group_add_widget (g, chown_label[i].l);
|
||||
}
|
||||
|
||||
if (single_set == 0)
|
||||
{
|
||||
int x;
|
||||
|
||||
add_widget (ch_dlg, hline_new (lines - chown_but[0].y - 1, -1, -1));
|
||||
group_add_widget (g, hline_new (lines - chown_but[0].y - 1, -1, -1));
|
||||
|
||||
y = lines - chown_but[0].y;
|
||||
x = (cols - blen) / 2;
|
||||
|
||||
for (i = 0; i < BUTTONS - 2; i++)
|
||||
{
|
||||
add_widget (ch_dlg,
|
||||
button_new (y, x, chown_but[i].ret_cmd, chown_but[i].flags,
|
||||
chown_but[i].text, NULL));
|
||||
group_add_widget (g, button_new (y, x, chown_but[i].ret_cmd, chown_but[i].flags,
|
||||
chown_but[i].text, NULL));
|
||||
x += chown_but[i].len + 1;
|
||||
}
|
||||
}
|
||||
|
||||
i = BUTTONS - 2;
|
||||
y = lines - chown_but[i].y;
|
||||
add_widget (ch_dlg, hline_new (y - 1, -1, -1));
|
||||
add_widget (ch_dlg,
|
||||
button_new (y, WIDGET (ch_dlg)->cols / 2 - chown_but[i].len, chown_but[i].ret_cmd,
|
||||
chown_but[i].flags, chown_but[i].text, NULL));
|
||||
group_add_widget (g, hline_new (y - 1, -1, -1));
|
||||
group_add_widget (g, button_new (y, WIDGET (ch_dlg)->cols / 2 - chown_but[i].len,
|
||||
chown_but[i].ret_cmd, chown_but[i].flags, chown_but[i].text,
|
||||
NULL));
|
||||
i++;
|
||||
add_widget (ch_dlg,
|
||||
button_new (y, WIDGET (ch_dlg)->cols / 2 + 1, chown_but[i].ret_cmd,
|
||||
chown_but[i].flags, chown_but[i].text, NULL));
|
||||
group_add_widget (g, button_new (y, WIDGET (ch_dlg)->cols / 2 + 1, chown_but[i].ret_cmd,
|
||||
chown_but[i].flags, chown_but[i].text, NULL));
|
||||
|
||||
/* select first listbox */
|
||||
widget_select (WIDGET (l_user));
|
||||
|
@ -3102,6 +3102,7 @@ void
|
||||
dirsize_status_init_cb (status_msg_t * sm)
|
||||
{
|
||||
dirsize_status_msg_t *dsm = (dirsize_status_msg_t *) sm;
|
||||
WGroup *gd = GROUP (sm->dlg);
|
||||
Widget *wd = WIDGET (sm->dlg);
|
||||
|
||||
const char *b1_name = N_("&Abort");
|
||||
@ -3119,17 +3120,17 @@ dirsize_status_init_cb (status_msg_t * sm)
|
||||
|
||||
ui_width = MAX (COLS / 2, b_width + 6);
|
||||
dsm->dirname = label_new (2, 3, "");
|
||||
add_widget (sm->dlg, dsm->dirname);
|
||||
group_add_widget (gd, dsm->dirname);
|
||||
dsm->count_size = label_new (3, 3, "");
|
||||
add_widget (sm->dlg, dsm->count_size);
|
||||
add_widget (sm->dlg, hline_new (4, -1, -1));
|
||||
group_add_widget (gd, dsm->count_size);
|
||||
group_add_widget (gd, hline_new (4, -1, -1));
|
||||
|
||||
dsm->abort_button = WIDGET (button_new (5, 3, FILE_ABORT, NORMAL_BUTTON, b1_name, NULL));
|
||||
add_widget (sm->dlg, dsm->abort_button);
|
||||
group_add_widget (gd, dsm->abort_button);
|
||||
if (dsm->allow_skip)
|
||||
{
|
||||
dsm->skip_button = WIDGET (button_new (5, 3, FILE_SKIP, NORMAL_BUTTON, b2_name, NULL));
|
||||
add_widget (sm->dlg, dsm->skip_button);
|
||||
group_add_widget (gd, dsm->skip_button);
|
||||
widget_select (dsm->skip_button);
|
||||
}
|
||||
|
||||
@ -3152,9 +3153,10 @@ dirsize_status_update_cb (status_msg_t * sm)
|
||||
/* enlarge dialog if required */
|
||||
if (WIDGET (dsm->count_size)->cols + 6 > wd->cols)
|
||||
{
|
||||
dlg_set_size (sm->dlg, wd->lines, WIDGET (dsm->count_size)->cols + 6);
|
||||
widget_set_size (wd, wd->y, wd->x, wd->lines, WIDGET (dsm->count_size)->cols + 6);
|
||||
dirsize_status_locate_buttons (dsm);
|
||||
dlg_draw (sm->dlg);
|
||||
widget_draw (wd);
|
||||
/* TODO: ret rid of double redraw */
|
||||
}
|
||||
|
||||
/* adjust first label */
|
||||
|
@ -410,16 +410,15 @@ overwrite_query_dialog (file_op_context_t * ctx, enum OperationMode mode)
|
||||
W(i) = WIDGET (label_new (dlg_widgets[i].y, dlg_widgets[i].x, text))
|
||||
|
||||
#define ADD_LABEL(i) \
|
||||
add_widget_autopos (ui->replace_dlg, W(i), dlg_widgets[i].pos_flags, \
|
||||
ui->replace_dlg->current != NULL ? ui->replace_dlg->current->data : NULL)
|
||||
group_add_widget_autopos (g, W(i), dlg_widgets[i].pos_flags, \
|
||||
g->current != NULL ? g->current->data : NULL)
|
||||
|
||||
#define NEW_BUTTON(i) \
|
||||
W(i) = WIDGET (button_new (dlg_widgets[i].y, dlg_widgets[i].x, \
|
||||
dlg_widgets[i].value, NORMAL_BUTTON, dlg_widgets[i].text, NULL))
|
||||
|
||||
#define ADD_BUTTON(i) \
|
||||
add_widget_autopos (ui->replace_dlg, W(i), dlg_widgets[i].pos_flags, \
|
||||
ui->replace_dlg->current->data)
|
||||
group_add_widget_autopos (g, W(i), dlg_widgets[i].pos_flags, g->current->data)
|
||||
|
||||
/* dialog sizes */
|
||||
const int dlg_height = 17;
|
||||
@ -488,6 +487,7 @@ overwrite_query_dialog (file_op_context_t * ctx, enum OperationMode mode)
|
||||
|
||||
file_op_context_ui_t *ui = ctx->ui;
|
||||
Widget *wd;
|
||||
WGroup *g;
|
||||
const char *title;
|
||||
|
||||
vfs_path_t *p;
|
||||
@ -637,11 +637,12 @@ overwrite_query_dialog (file_op_context_t * ctx, enum OperationMode mode)
|
||||
dlg_create (TRUE, 0, 0, dlg_height, dlg_width, WPOS_CENTER, FALSE, alarm_colors, NULL, NULL,
|
||||
"[Replace]", title);
|
||||
wd = WIDGET (ui->replace_dlg);
|
||||
g = GROUP (ui->replace_dlg);
|
||||
|
||||
/* file info */
|
||||
for (i = 0; i <= 7; i++)
|
||||
ADD_LABEL (i);
|
||||
add_widget (ui->replace_dlg, hline_new (W (7)->y - wd->y + 1, -1, -1));
|
||||
group_add_widget (g, hline_new (W (7)->y - wd->y + 1, -1, -1));
|
||||
|
||||
/* label & buttons */
|
||||
ADD_LABEL (8); /* Overwrite this file? */
|
||||
@ -651,18 +652,18 @@ overwrite_query_dialog (file_op_context_t * ctx, enum OperationMode mode)
|
||||
ADD_BUTTON (11); /* Append */
|
||||
if (do_reget)
|
||||
ADD_BUTTON (12); /* Reget */
|
||||
add_widget (ui->replace_dlg, hline_new (W (10)->y - wd->y + 1, -1, -1));
|
||||
group_add_widget (g, hline_new (W (10)->y - wd->y + 1, -1, -1));
|
||||
|
||||
/* label & buttons */
|
||||
ADD_LABEL (13); /* Overwrite all files? */
|
||||
add_widget (ui->replace_dlg, dlg_widgets[14].widget);
|
||||
group_add_widget (g, dlg_widgets[14].widget);
|
||||
for (i = 15; i <= 19; i++)
|
||||
ADD_BUTTON (i);
|
||||
add_widget (ui->replace_dlg, hline_new (W (19)->y - wd->y + 1, -1, -1));
|
||||
group_add_widget (g, hline_new (W (19)->y - wd->y + 1, -1, -1));
|
||||
|
||||
ADD_BUTTON (20); /* Abort */
|
||||
|
||||
dlg_select_by_id (ui->replace_dlg, safe_overwrite ? no_id : yes_id);
|
||||
group_select_widget_by_id (g, safe_overwrite ? no_id : yes_id);
|
||||
|
||||
result = dlg_run (ui->replace_dlg);
|
||||
|
||||
@ -770,7 +771,7 @@ check_progress_buttons (file_op_context_t * ctx)
|
||||
{
|
||||
/* redraw dialog in case of Skip after Suspend */
|
||||
place_progress_buttons (ui->op_dlg, FALSE);
|
||||
dlg_draw (ui->op_dlg);
|
||||
widget_draw (WIDGET (ui->op_dlg));
|
||||
}
|
||||
ctx->suspended = FALSE;
|
||||
return FILE_SKIP;
|
||||
@ -781,7 +782,7 @@ check_progress_buttons (file_op_context_t * ctx)
|
||||
case FILE_SUSPEND:
|
||||
ctx->suspended = !ctx->suspended;
|
||||
place_progress_buttons (ui->op_dlg, ctx->suspended);
|
||||
dlg_draw (ui->op_dlg);
|
||||
widget_draw (WIDGET (ui->op_dlg));
|
||||
MC_FALLTHROUGH;
|
||||
default:
|
||||
if (ctx->suspended)
|
||||
@ -798,6 +799,8 @@ file_op_context_create_ui (file_op_context_t * ctx, gboolean with_eta,
|
||||
filegui_dialog_type_t dialog_type)
|
||||
{
|
||||
file_op_context_ui_t *ui;
|
||||
Widget *w;
|
||||
WGroup *g;
|
||||
int buttons_width;
|
||||
int dlg_width = 58, dlg_height = 17;
|
||||
int y = 2, x = 3;
|
||||
@ -825,6 +828,8 @@ file_op_context_create_ui (file_op_context_t * ctx, gboolean with_eta,
|
||||
ui->op_dlg =
|
||||
dlg_create (TRUE, 0, 0, dlg_height, dlg_width, WPOS_CENTER, FALSE, dialog_colors, NULL,
|
||||
NULL, NULL, op_names[ctx->operation]);
|
||||
w = WIDGET (ui->op_dlg);
|
||||
g = GROUP (ui->op_dlg);
|
||||
|
||||
if (dialog_type != FILEGUI_DIALOG_DELETE_ITEM)
|
||||
{
|
||||
@ -832,30 +837,29 @@ file_op_context_create_ui (file_op_context_t * ctx, gboolean with_eta,
|
||||
ui->showing_bps = with_eta;
|
||||
|
||||
ui->src_file_label = label_new (y++, x, "");
|
||||
add_widget (ui->op_dlg, ui->src_file_label);
|
||||
group_add_widget (g, ui->src_file_label);
|
||||
|
||||
ui->src_file = label_new (y++, x, "");
|
||||
add_widget (ui->op_dlg, ui->src_file);
|
||||
group_add_widget (g, ui->src_file);
|
||||
|
||||
ui->tgt_file_label = label_new (y++, x, "");
|
||||
add_widget (ui->op_dlg, ui->tgt_file_label);
|
||||
group_add_widget (g, ui->tgt_file_label);
|
||||
|
||||
ui->tgt_file = label_new (y++, x, "");
|
||||
add_widget (ui->op_dlg, ui->tgt_file);
|
||||
group_add_widget (g, ui->tgt_file);
|
||||
|
||||
ui->progress_file_gauge = gauge_new (y++, x + 3, dlg_width - (x + 3) * 2, FALSE, 100, 0);
|
||||
if (!classic_progressbar && (current_panel == right_panel))
|
||||
ui->progress_file_gauge->from_left_to_right = FALSE;
|
||||
add_widget_autopos (ui->op_dlg, ui->progress_file_gauge, WPOS_KEEP_TOP | WPOS_KEEP_HORZ,
|
||||
NULL);
|
||||
group_add_widget_autopos (g, ui->progress_file_gauge, WPOS_KEEP_TOP | WPOS_KEEP_HORZ, NULL);
|
||||
|
||||
ui->progress_file_label = label_new (y++, x, "");
|
||||
add_widget (ui->op_dlg, ui->progress_file_label);
|
||||
group_add_widget (g, ui->progress_file_label);
|
||||
|
||||
if (verbose && dialog_type == FILEGUI_DIALOG_MULTI_ITEM)
|
||||
{
|
||||
ui->total_bytes_label = hline_new (y++, -1, -1);
|
||||
add_widget (ui->op_dlg, ui->total_bytes_label);
|
||||
group_add_widget (g, ui->total_bytes_label);
|
||||
|
||||
if (ctx->progress_totals_computed)
|
||||
{
|
||||
@ -863,27 +867,27 @@ file_op_context_create_ui (file_op_context_t * ctx, gboolean with_eta,
|
||||
gauge_new (y++, x + 3, dlg_width - (x + 3) * 2, FALSE, 100, 0);
|
||||
if (!classic_progressbar && (current_panel == right_panel))
|
||||
ui->progress_total_gauge->from_left_to_right = FALSE;
|
||||
add_widget_autopos (ui->op_dlg, ui->progress_total_gauge,
|
||||
WPOS_KEEP_TOP | WPOS_KEEP_HORZ, NULL);
|
||||
group_add_widget_autopos (g, ui->progress_total_gauge,
|
||||
WPOS_KEEP_TOP | WPOS_KEEP_HORZ, NULL);
|
||||
}
|
||||
|
||||
ui->total_files_processed_label = label_new (y++, x, "");
|
||||
add_widget (ui->op_dlg, ui->total_files_processed_label);
|
||||
group_add_widget (g, ui->total_files_processed_label);
|
||||
|
||||
ui->time_label = label_new (y++, x, "");
|
||||
add_widget (ui->op_dlg, ui->time_label);
|
||||
group_add_widget (g, ui->time_label);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->src_file = label_new (y++, x, "");
|
||||
add_widget (ui->op_dlg, ui->src_file);
|
||||
group_add_widget (g, ui->src_file);
|
||||
|
||||
ui->total_files_processed_label = label_new (y++, x, "");
|
||||
add_widget (ui->op_dlg, ui->total_files_processed_label);
|
||||
group_add_widget (g, ui->total_files_processed_label);
|
||||
}
|
||||
|
||||
add_widget (ui->op_dlg, hline_new (y++, -1, -1));
|
||||
group_add_widget (g, hline_new (y++, -1, -1));
|
||||
|
||||
progress_buttons[0].w = WIDGET (button_new (y, 0, progress_buttons[0].action,
|
||||
progress_buttons[0].flags, progress_buttons[0].text,
|
||||
@ -915,16 +919,16 @@ file_op_context_create_ui (file_op_context_t * ctx, gboolean with_eta,
|
||||
if (progress_buttons[3].len == -1)
|
||||
progress_buttons[3].len = button_get_len (BUTTON (progress_buttons[3].w));
|
||||
|
||||
add_widget (ui->op_dlg, progress_buttons[0].w);
|
||||
add_widget (ui->op_dlg, progress_buttons[1].w);
|
||||
add_widget (ui->op_dlg, progress_buttons[3].w);
|
||||
group_add_widget (g, progress_buttons[0].w);
|
||||
group_add_widget (g, progress_buttons[1].w);
|
||||
group_add_widget (g, progress_buttons[3].w);
|
||||
|
||||
buttons_width = 2 +
|
||||
progress_buttons[0].len + MAX (progress_buttons[1].len, progress_buttons[2].len) +
|
||||
progress_buttons[3].len;
|
||||
|
||||
/* adjust dialog sizes */
|
||||
dlg_set_size (ui->op_dlg, y + 3, MAX (COLS * 2 / 3, buttons_width + 6));
|
||||
widget_set_size (w, w->y, w->x, y + 3, MAX (COLS * 2 / 3, buttons_width + 6));
|
||||
|
||||
place_progress_buttons (ui->op_dlg, FALSE);
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user