Merge branch '1414-scalable-ui'
* 1414-scalable-ui: Ticket #1414: implemented scalable TUI. Ticket #1414: small refactoring before major modifications.
Этот коммит содержится в:
Коммит
ae494fd168
@ -47,7 +47,7 @@
|
|||||||
|
|
||||||
#include "../src/global.h"
|
#include "../src/global.h"
|
||||||
|
|
||||||
#include "../src/tty/tty.h" /* COLS */
|
#include "../src/tty/tty.h"
|
||||||
#include "../src/tty/key.h" /* XCTRL */
|
#include "../src/tty/key.h" /* XCTRL */
|
||||||
|
|
||||||
#include "../src/history.h"
|
#include "../src/history.h"
|
||||||
@ -123,17 +123,17 @@ void edit_help_cmd (WEdit * edit)
|
|||||||
edit->force |= REDRAW_COMPLETELY;
|
edit->force |= REDRAW_COMPLETELY;
|
||||||
}
|
}
|
||||||
|
|
||||||
void edit_refresh_cmd (WEdit * edit)
|
void
|
||||||
|
edit_refresh_cmd (WEdit * edit)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SLANG
|
#ifdef HAVE_SLANG
|
||||||
{
|
int color;
|
||||||
int color;
|
|
||||||
edit_get_syntax_color (edit, -1, &color);
|
edit_get_syntax_color (edit, -1, &color);
|
||||||
}
|
|
||||||
tty_touch_screen ();
|
tty_touch_screen ();
|
||||||
tty_refresh ();
|
mc_refresh ();
|
||||||
#else
|
#else
|
||||||
clr_scr();
|
clr_scr ();
|
||||||
repaint_screen ();
|
repaint_screen ();
|
||||||
#endif /* !HAVE_SLANG */
|
#endif /* !HAVE_SLANG */
|
||||||
tty_keypad (TRUE);
|
tty_keypad (TRUE);
|
||||||
|
162
src/dialog.c
162
src/dialog.c
@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
#include "help.h" /* interactive_display() */
|
#include "help.h" /* interactive_display() */
|
||||||
#include "dialog.h"
|
#include "dialog.h"
|
||||||
#include "layout.h" /* winch_flag, change_screen_size() */
|
#include "layout.h"
|
||||||
#include "execute.h" /* suspend_cmd() */
|
#include "execute.h" /* suspend_cmd() */
|
||||||
#include "main.h" /* fast_refresh */
|
#include "main.h" /* fast_refresh */
|
||||||
#include "strutil.h"
|
#include "strutil.h"
|
||||||
@ -97,27 +97,6 @@ init_widget (Widget *w, int y, int x, int lines, int cols,
|
|||||||
w->options = W_WANT_CURSOR;
|
w->options = W_WANT_CURSOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Default callback for widgets */
|
|
||||||
cb_ret_t
|
|
||||||
default_proc (widget_msg_t msg, int parm)
|
|
||||||
{
|
|
||||||
(void) parm;
|
|
||||||
|
|
||||||
switch (msg) {
|
|
||||||
case WIDGET_INIT:
|
|
||||||
case WIDGET_FOCUS:
|
|
||||||
case WIDGET_UNFOCUS:
|
|
||||||
case WIDGET_DRAW:
|
|
||||||
case WIDGET_DESTROY:
|
|
||||||
case WIDGET_CURSOR:
|
|
||||||
case WIDGET_IDLE:
|
|
||||||
return MSG_HANDLED;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return MSG_NOT_HANDLED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Clean the dialog area, draw the frame and the title */
|
/* Clean the dialog area, draw the frame and the title */
|
||||||
void
|
void
|
||||||
common_dialog_repaint (struct Dlg_head *h)
|
common_dialog_repaint (struct Dlg_head *h)
|
||||||
@ -137,19 +116,123 @@ common_dialog_repaint (struct Dlg_head *h)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* this function allows to set dialog position */
|
||||||
|
void
|
||||||
|
dlg_set_position (Dlg_head *h, int y1, int x1, int y2, int x2)
|
||||||
|
{
|
||||||
|
/* save old positions, will be used to reposition childs */
|
||||||
|
int ox, oy, oc, ol;
|
||||||
|
int shift_x, shift_y, scale_x, scale_y;
|
||||||
|
|
||||||
|
/* save old positions, will be used to reposition childs */
|
||||||
|
ox = h->x;
|
||||||
|
oy = h->y;
|
||||||
|
oc = h->cols;
|
||||||
|
ol = h->lines;
|
||||||
|
|
||||||
|
h->x = x1;
|
||||||
|
h->y = y1;
|
||||||
|
h->lines = y2 - y1;
|
||||||
|
h->cols = x2 - x1;
|
||||||
|
|
||||||
|
/* values by which controls should be moved */
|
||||||
|
shift_x = h->x - ox;
|
||||||
|
shift_y = h->y - oy;
|
||||||
|
scale_x = h->cols - oc;
|
||||||
|
scale_y = h->lines - ol;
|
||||||
|
|
||||||
|
if (h->current == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ((shift_x != 0) || (shift_y != 0) || (scale_x != 0) || (scale_y != 0)) {
|
||||||
|
Widget *c = h->current;
|
||||||
|
|
||||||
|
do {
|
||||||
|
/* 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 */
|
||||||
|
|
||||||
|
int x = c->x;
|
||||||
|
int y = c->y;
|
||||||
|
int cols = c->cols;
|
||||||
|
int lines = c->lines;
|
||||||
|
|
||||||
|
if ((c->pos_flags & WPOS_KEEP_LEFT) && (c->pos_flags & WPOS_KEEP_RIGHT)) {
|
||||||
|
x += shift_x;
|
||||||
|
cols += scale_x;
|
||||||
|
} else if (c->pos_flags & WPOS_KEEP_LEFT)
|
||||||
|
x += shift_x;
|
||||||
|
else if (c->pos_flags & WPOS_KEEP_RIGHT)
|
||||||
|
x += shift_x + scale_x;
|
||||||
|
|
||||||
|
if ((c->pos_flags & WPOS_KEEP_TOP) && (c->pos_flags & WPOS_KEEP_BOTTOM)) {
|
||||||
|
y += shift_y;
|
||||||
|
lines += scale_y;
|
||||||
|
} else if (c->pos_flags & WPOS_KEEP_TOP)
|
||||||
|
y += shift_y;
|
||||||
|
else if (c->pos_flags & WPOS_KEEP_BOTTOM)
|
||||||
|
y += shift_y + scale_y;
|
||||||
|
|
||||||
|
widget_set_size (c, y, x, lines, cols);
|
||||||
|
|
||||||
|
c = c->next;
|
||||||
|
} while (h->current != c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* this function sets only size, leaving positioning to automatic methods */
|
||||||
|
void
|
||||||
|
dlg_set_size (Dlg_head *h, int lines, int cols)
|
||||||
|
{
|
||||||
|
int x = h->x;
|
||||||
|
int y = h->y;
|
||||||
|
|
||||||
|
if (h->flags & DLG_CENTER) {
|
||||||
|
y = (LINES - lines) / 2;
|
||||||
|
x = (COLS - cols) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((h->flags & DLG_TRYUP) && (y > 3))
|
||||||
|
y -= 2;
|
||||||
|
|
||||||
|
dlg_set_position (h, y, x, y + lines, x + cols);
|
||||||
|
}
|
||||||
|
|
||||||
/* Default dialog callback */
|
/* Default dialog callback */
|
||||||
cb_ret_t default_dlg_callback (Dlg_head *h, dlg_msg_t msg, int parm)
|
cb_ret_t default_dlg_callback (Dlg_head *h, dlg_msg_t msg, int parm)
|
||||||
{
|
{
|
||||||
(void) parm;
|
(void) parm;
|
||||||
|
|
||||||
if (msg == DLG_DRAW && h->color) {
|
switch (msg) {
|
||||||
common_dialog_repaint (h);
|
case DLG_DRAW:
|
||||||
return MSG_HANDLED;
|
if (h->color != NULL) {
|
||||||
}
|
common_dialog_repaint (h);
|
||||||
if (msg == DLG_IDLE){
|
return MSG_HANDLED;
|
||||||
|
}
|
||||||
|
return MSG_NOT_HANDLED;
|
||||||
|
|
||||||
|
case DLG_IDLE:
|
||||||
dlg_broadcast_msg_to (h, WIDGET_IDLE, 0, W_WANT_IDLE);
|
dlg_broadcast_msg_to (h, WIDGET_IDLE, 0, W_WANT_IDLE);
|
||||||
return MSG_HANDLED;
|
return MSG_HANDLED;
|
||||||
|
|
||||||
|
case DLG_RESIZE:
|
||||||
|
/* 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 DLG_CENTER, end after that reposition
|
||||||
|
controls in dialog according to flags of widget) */
|
||||||
|
dlg_set_size (h, h->lines, h->cols);
|
||||||
|
return MSG_HANDLED;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return MSG_NOT_HANDLED;
|
return MSG_NOT_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,14 +243,6 @@ create_dlg (int y1, int x1, int lines, int cols, const int *color_set,
|
|||||||
{
|
{
|
||||||
Dlg_head *new_d;
|
Dlg_head *new_d;
|
||||||
|
|
||||||
if (flags & DLG_CENTER) {
|
|
||||||
y1 = (LINES - lines) / 2;
|
|
||||||
x1 = (COLS - cols) / 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((flags & DLG_TRYUP) && (y1 > 3))
|
|
||||||
y1 -= 2;
|
|
||||||
|
|
||||||
new_d = g_new0 (Dlg_head, 1);
|
new_d = g_new0 (Dlg_head, 1);
|
||||||
if (color_set != NULL) {
|
if (color_set != NULL) {
|
||||||
new_d->color = g_new (int, DLG_COLOR_NUM);
|
new_d->color = g_new (int, DLG_COLOR_NUM);
|
||||||
@ -177,9 +252,10 @@ create_dlg (int y1, int x1, int lines, int cols, const int *color_set,
|
|||||||
new_d->callback = callback ? callback : default_dlg_callback;
|
new_d->callback = callback ? callback : default_dlg_callback;
|
||||||
new_d->x = x1;
|
new_d->x = x1;
|
||||||
new_d->y = y1;
|
new_d->y = y1;
|
||||||
new_d->cols = cols;
|
|
||||||
new_d->lines = lines;
|
|
||||||
new_d->flags = flags;
|
new_d->flags = flags;
|
||||||
|
new_d->data = NULL;
|
||||||
|
|
||||||
|
dlg_set_size (new_d, lines, cols);
|
||||||
|
|
||||||
/* Strip existing spaces, add one space before and after the title */
|
/* Strip existing spaces, add one space before and after the title */
|
||||||
if (title) {
|
if (title) {
|
||||||
@ -220,7 +296,7 @@ set_idle_proc (Dlg_head *d, int enable)
|
|||||||
* from the bottom, make the widget current. Return widget number.
|
* from the bottom, make the widget current. Return widget number.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
add_widget (Dlg_head *h, void *w)
|
add_widget_autopos (Dlg_head *h, void *w, widget_pos_flags_t pos_flags)
|
||||||
{
|
{
|
||||||
Widget *widget = (Widget *) w;
|
Widget *widget = (Widget *) w;
|
||||||
|
|
||||||
@ -232,6 +308,7 @@ add_widget (Dlg_head *h, void *w)
|
|||||||
widget->y += h->y;
|
widget->y += h->y;
|
||||||
widget->parent = h;
|
widget->parent = h;
|
||||||
widget->dlg_id = h->count++;
|
widget->dlg_id = h->count++;
|
||||||
|
widget->pos_flags = pos_flags;
|
||||||
|
|
||||||
if (h->current) {
|
if (h->current) {
|
||||||
widget->next = h->current;
|
widget->next = h->current;
|
||||||
@ -249,6 +326,13 @@ add_widget (Dlg_head *h, void *w)
|
|||||||
return widget->dlg_id;
|
return widget->dlg_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* wrapper to simply add lefttop positioned controls */
|
||||||
|
int
|
||||||
|
add_widget (Dlg_head *h, void *w)
|
||||||
|
{
|
||||||
|
add_widget_autopos (h, w, WPOS_KEEP_LEFT | WPOS_KEEP_TOP);
|
||||||
|
}
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
REFRESH_COVERS_PART, /* If the refresh fn convers only a part */
|
REFRESH_COVERS_PART, /* If the refresh fn convers only a part */
|
||||||
REFRESH_COVERS_ALL /* If the refresh fn convers all the screen */
|
REFRESH_COVERS_ALL /* If the refresh fn convers all the screen */
|
||||||
@ -541,7 +625,7 @@ dialog_handle_key (Dlg_head *h, int d_key)
|
|||||||
case XCTRL('l'):
|
case XCTRL('l'):
|
||||||
#ifdef HAVE_SLANG
|
#ifdef HAVE_SLANG
|
||||||
tty_touch_screen ();
|
tty_touch_screen ();
|
||||||
tty_refresh ();
|
mc_refresh ();
|
||||||
#else
|
#else
|
||||||
/* Use this if the refreshes fail */
|
/* Use this if the refreshes fail */
|
||||||
clr_scr ();
|
clr_scr ();
|
||||||
|
44
src/dialog.h
44
src/dialog.h
@ -112,6 +112,7 @@ typedef struct Dlg_head {
|
|||||||
/* Internal variables */
|
/* Internal variables */
|
||||||
int count; /* Number of widgets */
|
int count; /* Number of widgets */
|
||||||
struct Widget *current; /* Curently active widget */
|
struct Widget *current; /* Curently active widget */
|
||||||
|
void *data; /* data can be passed to dialog */
|
||||||
dlg_cb_fn callback;
|
dlg_cb_fn callback;
|
||||||
struct Dlg_head *parent; /* Parent dialog */
|
struct Dlg_head *parent; /* Parent dialog */
|
||||||
} Dlg_head;
|
} Dlg_head;
|
||||||
@ -125,17 +126,32 @@ typedef struct Widget Widget;
|
|||||||
/* Widget callback */
|
/* Widget callback */
|
||||||
typedef cb_ret_t (*callback_fn) (Widget *widget, widget_msg_t msg, int parm);
|
typedef cb_ret_t (*callback_fn) (Widget *widget, widget_msg_t msg, int parm);
|
||||||
|
|
||||||
|
/* widget options */
|
||||||
|
typedef enum {
|
||||||
|
W_WANT_HOTKEY = (1 << 1),
|
||||||
|
W_WANT_CURSOR = (1 << 2),
|
||||||
|
W_WANT_IDLE = (1 << 3),
|
||||||
|
W_IS_INPUT = (1 << 4)
|
||||||
|
} widget_options_t;
|
||||||
|
|
||||||
|
/* Flags for widget repositioning on dialog resize */
|
||||||
|
typedef enum {
|
||||||
|
WPOS_KEEP_LEFT = (1 << 0), /* keep widget distance to left border of dialog */
|
||||||
|
WPOS_KEEP_RIGHT = (1 << 1), /* keep widget distance to right border of dialog */
|
||||||
|
WPOS_KEEP_TOP = (1 << 2), /* keep widget distance to top border of dialog */
|
||||||
|
WPOS_KEEP_BOTTOM = (1 << 3), /* keep widget distance to bottom border of dialog */
|
||||||
|
WPOS_KEEP_HORZ = WPOS_KEEP_LEFT | WPOS_KEEP_RIGHT,
|
||||||
|
WPOS_KEEP_VERT = WPOS_KEEP_TOP | WPOS_KEEP_BOTTOM,
|
||||||
|
WPOS_KEEP_ALL = WPOS_KEEP_HORZ | WPOS_KEEP_VERT
|
||||||
|
} widget_pos_flags_t;
|
||||||
|
|
||||||
/* Every Widget must have this as its first element */
|
/* Every Widget must have this as its first element */
|
||||||
struct Widget {
|
struct Widget {
|
||||||
int x, y;
|
int x, y;
|
||||||
int cols, lines;
|
int cols, lines;
|
||||||
|
widget_options_t options;
|
||||||
#define W_WANT_HOTKEY (1 << 1)
|
widget_pos_flags_t pos_flags; /* repositioning flags */
|
||||||
#define W_WANT_CURSOR (1 << 2)
|
int dlg_id; /* Number of the widget, starting with 0 */
|
||||||
#define W_WANT_IDLE (1 << 3)
|
|
||||||
#define W_IS_INPUT (1 << 4)
|
|
||||||
int options;
|
|
||||||
int dlg_id; /* Number of the widget, starting with 0 */
|
|
||||||
struct Widget *next;
|
struct Widget *next;
|
||||||
struct Widget *prev;
|
struct Widget *prev;
|
||||||
callback_fn callback;
|
callback_fn callback;
|
||||||
@ -162,7 +178,14 @@ Dlg_head *create_dlg (int y1, int x1, int lines, int cols,
|
|||||||
|
|
||||||
void dlg_set_default_colors (void);
|
void dlg_set_default_colors (void);
|
||||||
|
|
||||||
int add_widget (Dlg_head *dest, void *Widget);
|
int add_widget_autopos (Dlg_head *dest, void *w, widget_pos_flags_t pos_flags);
|
||||||
|
int add_widget (Dlg_head *dest, void *w);
|
||||||
|
|
||||||
|
/* sets size of dialog, leaving positioning to automatic mehtods
|
||||||
|
according to dialog flags */
|
||||||
|
void dlg_set_size (Dlg_head *h, int lines, int cols);
|
||||||
|
/* this function allows to set dialog position */
|
||||||
|
void dlg_set_position (Dlg_head *h, int y1, int x1, int y2, int x2);
|
||||||
|
|
||||||
/* Runs dialog d */
|
/* Runs dialog d */
|
||||||
int run_dlg (Dlg_head *d);
|
int run_dlg (Dlg_head *d);
|
||||||
@ -177,7 +200,7 @@ void set_idle_proc (Dlg_head *d, int enable);
|
|||||||
void dlg_redraw (Dlg_head *h);
|
void dlg_redraw (Dlg_head *h);
|
||||||
void destroy_dlg (Dlg_head *h);
|
void destroy_dlg (Dlg_head *h);
|
||||||
|
|
||||||
void widget_set_size (Widget *widget, int x1, int y1, int x2, int y2);
|
void widget_set_size (Widget *widget, int y, int x, int lines, int cols);
|
||||||
|
|
||||||
void dlg_broadcast_msg (Dlg_head *h, widget_msg_t message, int reverse);
|
void dlg_broadcast_msg (Dlg_head *h, widget_msg_t message, int reverse);
|
||||||
|
|
||||||
@ -187,9 +210,6 @@ void init_widget (Widget *w, int y, int x, int lines, int cols,
|
|||||||
/* Default callback for dialogs */
|
/* Default callback for dialogs */
|
||||||
cb_ret_t default_dlg_callback (Dlg_head *h, dlg_msg_t msg, int parm);
|
cb_ret_t default_dlg_callback (Dlg_head *h, dlg_msg_t msg, int parm);
|
||||||
|
|
||||||
/* Default callback for widgets */
|
|
||||||
cb_ret_t default_proc (widget_msg_t msg, int parm);
|
|
||||||
|
|
||||||
/* Default paint routine for dialogs */
|
/* Default paint routine for dialogs */
|
||||||
void common_dialog_repaint (struct Dlg_head *h);
|
void common_dialog_repaint (struct Dlg_head *h);
|
||||||
|
|
||||||
|
24
src/file.c
24
src/file.c
@ -427,7 +427,7 @@ copy_file_file (FileOpContext *ctx, const char *src_path, const char *dst_path,
|
|||||||
file_progress_show_target (ctx, dst_path) == FILE_ABORT)
|
file_progress_show_target (ctx, dst_path) == FILE_ABORT)
|
||||||
return FILE_ABORT;
|
return FILE_ABORT;
|
||||||
|
|
||||||
tty_refresh ();
|
mc_refresh ();
|
||||||
|
|
||||||
while (mc_stat (dst_path, &sb2) == 0) {
|
while (mc_stat (dst_path, &sb2) == 0) {
|
||||||
if (S_ISDIR (sb2.st_mode)) {
|
if (S_ISDIR (sb2.st_mode)) {
|
||||||
@ -582,7 +582,7 @@ copy_file_file (FileOpContext *ctx, const char *src_path, const char *dst_path,
|
|||||||
|
|
||||||
return_status = file_progress_show (ctx, 0, file_size);
|
return_status = file_progress_show (ctx, 0, file_size);
|
||||||
|
|
||||||
tty_refresh ();
|
mc_refresh ();
|
||||||
|
|
||||||
if (return_status != FILE_CONT)
|
if (return_status != FILE_CONT)
|
||||||
goto ret;
|
goto ret;
|
||||||
@ -682,7 +682,7 @@ copy_file_file (FileOpContext *ctx, const char *src_path, const char *dst_path,
|
|||||||
return_status =
|
return_status =
|
||||||
file_progress_show (ctx, n_read_total + ctx->do_reget, file_size);
|
file_progress_show (ctx, n_read_total + ctx->do_reget, file_size);
|
||||||
}
|
}
|
||||||
tty_refresh ();
|
mc_refresh ();
|
||||||
if (return_status != FILE_CONT)
|
if (return_status != FILE_CONT)
|
||||||
goto ret;
|
goto ret;
|
||||||
}
|
}
|
||||||
@ -996,7 +996,7 @@ move_file_file (FileOpContext *ctx, const char *s, const char *d,
|
|||||||
|| file_progress_show_target (ctx, d) == FILE_ABORT)
|
|| file_progress_show_target (ctx, d) == FILE_ABORT)
|
||||||
return FILE_ABORT;
|
return FILE_ABORT;
|
||||||
|
|
||||||
tty_refresh ();
|
mc_refresh ();
|
||||||
|
|
||||||
while (mc_lstat (s, &src_stats) != 0) {
|
while (mc_lstat (s, &src_stats) != 0) {
|
||||||
/* Source doesn't exist */
|
/* Source doesn't exist */
|
||||||
@ -1071,7 +1071,7 @@ move_file_file (FileOpContext *ctx, const char *s, const char *d,
|
|||||||
|| (return_status = file_progress_show (ctx, 0, 0)) != FILE_CONT)
|
|| (return_status = file_progress_show (ctx, 0, 0)) != FILE_CONT)
|
||||||
return return_status;
|
return return_status;
|
||||||
|
|
||||||
tty_refresh ();
|
mc_refresh ();
|
||||||
|
|
||||||
retry_src_remove:
|
retry_src_remove:
|
||||||
if (mc_unlink (s)) {
|
if (mc_unlink (s)) {
|
||||||
@ -1107,7 +1107,7 @@ move_dir_dir (FileOpContext *ctx, const char *s, const char *d,
|
|||||||
file_progress_show_target (ctx, d) == FILE_ABORT)
|
file_progress_show_target (ctx, d) == FILE_ABORT)
|
||||||
return FILE_ABORT;
|
return FILE_ABORT;
|
||||||
|
|
||||||
tty_refresh ();
|
mc_refresh ();
|
||||||
|
|
||||||
mc_stat (s, &sbuf);
|
mc_stat (s, &sbuf);
|
||||||
dstat_ok = (mc_stat (d, &dbuf) == 0);
|
dstat_ok = (mc_stat (d, &dbuf) == 0);
|
||||||
@ -1178,7 +1178,7 @@ move_dir_dir (FileOpContext *ctx, const char *s, const char *d,
|
|||||||
|| (return_status = file_progress_show (ctx, 0, 0)) != FILE_CONT)
|
|| (return_status = file_progress_show (ctx, 0, 0)) != FILE_CONT)
|
||||||
goto ret;
|
goto ret;
|
||||||
|
|
||||||
tty_refresh ();
|
mc_refresh ();
|
||||||
if (ctx->erase_at_end) {
|
if (ctx->erase_at_end) {
|
||||||
for (; erase_list && return_status != FILE_ABORT;) {
|
for (; erase_list && return_status != FILE_ABORT;) {
|
||||||
if (S_ISDIR (erase_list->st_mode)) {
|
if (S_ISDIR (erase_list->st_mode)) {
|
||||||
@ -1217,7 +1217,7 @@ erase_file (FileOpContext *ctx, const char *s, off_t *progress_count,
|
|||||||
|
|
||||||
if (file_progress_show_deleting (ctx, s) == FILE_ABORT)
|
if (file_progress_show_deleting (ctx, s) == FILE_ABORT)
|
||||||
return FILE_ABORT;
|
return FILE_ABORT;
|
||||||
tty_refresh ();
|
mc_refresh ();
|
||||||
|
|
||||||
if (progress_count && mc_lstat (s, &buf)) {
|
if (progress_count && mc_lstat (s, &buf)) {
|
||||||
/* ignore, most likely the mc_unlink fails, too */
|
/* ignore, most likely the mc_unlink fails, too */
|
||||||
@ -1282,7 +1282,7 @@ recursive_erase (FileOpContext *ctx, const char *s, off_t *progress_count,
|
|||||||
return return_status;
|
return return_status;
|
||||||
if (file_progress_show_deleting (ctx, s) == FILE_ABORT)
|
if (file_progress_show_deleting (ctx, s) == FILE_ABORT)
|
||||||
return FILE_ABORT;
|
return FILE_ABORT;
|
||||||
tty_refresh ();
|
mc_refresh ();
|
||||||
|
|
||||||
while (my_rmdir (s)) {
|
while (my_rmdir (s)) {
|
||||||
return_status =
|
return_status =
|
||||||
@ -1334,7 +1334,7 @@ erase_dir (FileOpContext *ctx, const char *s, off_t *progress_count,
|
|||||||
|
|
||||||
if (file_progress_show_deleting (ctx, s) == FILE_ABORT)
|
if (file_progress_show_deleting (ctx, s) == FILE_ABORT)
|
||||||
return FILE_ABORT;
|
return FILE_ABORT;
|
||||||
tty_refresh ();
|
mc_refresh ();
|
||||||
|
|
||||||
/* The old way to detect a non empty directory was:
|
/* The old way to detect a non empty directory was:
|
||||||
error = my_rmdir (s);
|
error = my_rmdir (s);
|
||||||
@ -1376,7 +1376,7 @@ erase_dir_iff_empty (FileOpContext *ctx, const char *s)
|
|||||||
|
|
||||||
if (file_progress_show_deleting (ctx, s) == FILE_ABORT)
|
if (file_progress_show_deleting (ctx, s) == FILE_ABORT)
|
||||||
return FILE_ABORT;
|
return FILE_ABORT;
|
||||||
tty_refresh ();
|
mc_refresh ();
|
||||||
|
|
||||||
if (1 != check_dir_is_empty (s)) /* not empty or error */
|
if (1 != check_dir_is_empty (s)) /* not empty or error */
|
||||||
return FILE_CONT;
|
return FILE_CONT;
|
||||||
@ -2110,7 +2110,7 @@ panel_operate (void *source_panel, FileOperation operation,
|
|||||||
&& file_progress_show (ctx, 0, 0) == FILE_ABORT)
|
&& file_progress_show (ctx, 0, 0) == FILE_ABORT)
|
||||||
goto clean_up;
|
goto clean_up;
|
||||||
|
|
||||||
tty_refresh ();
|
mc_refresh ();
|
||||||
} /* Loop for every file */
|
} /* Loop for every file */
|
||||||
} /* Many entries */
|
} /* Many entries */
|
||||||
clean_up:
|
clean_up:
|
||||||
|
@ -52,6 +52,7 @@
|
|||||||
#include "cmd.h" /* view_file_at_line */
|
#include "cmd.h" /* view_file_at_line */
|
||||||
#include "boxes.h"
|
#include "boxes.h"
|
||||||
#include "history.h" /* MC_HISTORY_SHARED_SEARCH */
|
#include "history.h" /* MC_HISTORY_SHARED_SEARCH */
|
||||||
|
#include "layout.h" /* mc_refresh() */
|
||||||
|
|
||||||
/* Size of the find parameters window */
|
/* Size of the find parameters window */
|
||||||
#if HAVE_CHARSET
|
#if HAVE_CHARSET
|
||||||
@ -664,7 +665,7 @@ search_content (Dlg_head *h, const char *directory, const char *filename)
|
|||||||
g_snprintf (buffer, sizeof (buffer), _("Grepping in %s"), str_trunc (filename, FIND2_X_USE));
|
g_snprintf (buffer, sizeof (buffer), _("Grepping in %s"), str_trunc (filename, FIND2_X_USE));
|
||||||
|
|
||||||
status_update (buffer);
|
status_update (buffer);
|
||||||
tty_refresh ();
|
mc_refresh ();
|
||||||
|
|
||||||
tty_enable_interrupt_key ();
|
tty_enable_interrupt_key ();
|
||||||
tty_got_interrupt ();
|
tty_got_interrupt ();
|
||||||
@ -896,7 +897,7 @@ do_search (struct Dlg_head *h)
|
|||||||
tty_setcolor (DLG_NORMALC (h));
|
tty_setcolor (DLG_NORMALC (h));
|
||||||
dlg_move (h, FIND2_Y - 7, FIND2_X - 4);
|
dlg_move (h, FIND2_Y - 7, FIND2_X - 4);
|
||||||
tty_print_char (rotating_dash [pos]);
|
tty_print_char (rotating_dash [pos]);
|
||||||
tty_refresh ();
|
mc_refresh ();
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
goto do_search_begin;
|
goto do_search_begin;
|
||||||
|
@ -124,21 +124,22 @@ static struct _hotlist_but {
|
|||||||
int ret_cmd, flags, y, x;
|
int ret_cmd, flags, y, x;
|
||||||
const char *text;
|
const char *text;
|
||||||
int type;
|
int type;
|
||||||
|
widget_pos_flags_t pos_flags;
|
||||||
} hotlist_but[] = {
|
} hotlist_but[] = {
|
||||||
{ B_MOVE, NORMAL_BUTTON, 1, 42, N_("&Move"), LIST_HOTLIST},
|
{ B_MOVE, NORMAL_BUTTON, 1, 42, N_("&Move"), LIST_HOTLIST, WPOS_KEEP_LEFT | WPOS_KEEP_BOTTOM },
|
||||||
{ B_REMOVE, NORMAL_BUTTON, 1, 30, N_("&Remove"), LIST_HOTLIST},
|
{ B_REMOVE, NORMAL_BUTTON, 1, 30, N_("&Remove"), LIST_HOTLIST, WPOS_KEEP_LEFT | WPOS_KEEP_BOTTOM },
|
||||||
{ B_APPEND, NORMAL_BUTTON, 1, 15, N_("&Append"), LIST_MOVELIST},
|
{ B_APPEND, NORMAL_BUTTON, 1, 15, N_("&Append"), LIST_MOVELIST, WPOS_KEEP_LEFT | WPOS_KEEP_BOTTOM },
|
||||||
{ B_INSERT, NORMAL_BUTTON, 1, 0, N_("&Insert"), LIST_MOVELIST},
|
{ B_INSERT, NORMAL_BUTTON, 1, 0, N_("&Insert"), LIST_MOVELIST, WPOS_KEEP_LEFT | WPOS_KEEP_BOTTOM },
|
||||||
{ B_NEW_ENTRY, NORMAL_BUTTON, 1, 15, N_("New &Entry"), LIST_HOTLIST},
|
{ B_NEW_ENTRY, NORMAL_BUTTON, 1, 15, N_("New &Entry"), LIST_HOTLIST, WPOS_KEEP_LEFT | WPOS_KEEP_BOTTOM },
|
||||||
{ B_NEW_GROUP, NORMAL_BUTTON, 1, 0, N_("New &Group"), LIST_HOTLIST},
|
{ B_NEW_GROUP, NORMAL_BUTTON, 1, 0, N_("New &Group"), LIST_HOTLIST, WPOS_KEEP_LEFT | WPOS_KEEP_BOTTOM },
|
||||||
{ B_CANCEL, NORMAL_BUTTON, 0, 53, N_("&Cancel"), LIST_HOTLIST|LIST_VFSLIST|LIST_MOVELIST},
|
{ B_CANCEL, NORMAL_BUTTON, 0, 53, N_("&Cancel"), LIST_HOTLIST | LIST_VFSLIST|LIST_MOVELIST, WPOS_KEEP_LEFT | WPOS_KEEP_BOTTOM },
|
||||||
{ B_UP_GROUP, NORMAL_BUTTON, 0, 42, N_("&Up"), LIST_HOTLIST|LIST_MOVELIST},
|
{ B_UP_GROUP, NORMAL_BUTTON, 0, 42, N_("&Up"), LIST_HOTLIST | LIST_MOVELIST, WPOS_KEEP_LEFT | WPOS_KEEP_BOTTOM },
|
||||||
{ B_ADD_CURRENT, NORMAL_BUTTON, 0, 20, N_("&Add current"), LIST_HOTLIST},
|
{ B_ADD_CURRENT, NORMAL_BUTTON, 0, 20, N_("&Add current"), LIST_HOTLIST, WPOS_KEEP_LEFT | WPOS_KEEP_BOTTOM },
|
||||||
#ifdef USE_VFS
|
#ifdef USE_VFS
|
||||||
{ B_REFRESH_VFS, NORMAL_BUTTON, 0, 43, N_("&Refresh"), LIST_VFSLIST},
|
{ B_REFRESH_VFS, NORMAL_BUTTON, 0, 43, N_("&Refresh"), LIST_VFSLIST, WPOS_KEEP_LEFT | WPOS_KEEP_BOTTOM },
|
||||||
{ B_FREE_ALL_VFS, NORMAL_BUTTON, 0, 20, N_("Fr&ee VFSs now"), LIST_VFSLIST},
|
{ B_FREE_ALL_VFS, NORMAL_BUTTON, 0, 20, N_("Fr&ee VFSs now"), LIST_VFSLIST, WPOS_KEEP_LEFT | WPOS_KEEP_BOTTOM },
|
||||||
#endif
|
#endif
|
||||||
{ B_ENTER, DEFPUSH_BUTTON, 0, 0, N_("Change &To"), LIST_HOTLIST|LIST_VFSLIST|LIST_MOVELIST},
|
{ B_ENTER, DEFPUSH_BUTTON, 0, 0, N_("Change &To"), LIST_HOTLIST | LIST_VFSLIST | LIST_MOVELIST, WPOS_KEEP_LEFT | WPOS_KEEP_BOTTOM }
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Directory hotlist */
|
/* Directory hotlist */
|
||||||
@ -491,6 +492,11 @@ hotlist_callback (Dlg_head *h, dlg_msg_t msg, int parm)
|
|||||||
update_path_name ();
|
update_path_name ();
|
||||||
return MSG_HANDLED;
|
return MSG_HANDLED;
|
||||||
|
|
||||||
|
case DLG_RESIZE:
|
||||||
|
/* simply call dlg_set_size() with new size */
|
||||||
|
dlg_set_size (h, LINES - 2, COLS - 6);
|
||||||
|
return MSG_HANDLED;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return default_dlg_callback (h, msg, parm);
|
return default_dlg_callback (h, msg, parm);
|
||||||
}
|
}
|
||||||
@ -634,13 +640,14 @@ init_hotlist (int list_type)
|
|||||||
|
|
||||||
for (i = 0; i < BUTTONS; i++) {
|
for (i = 0; i < BUTTONS; i++) {
|
||||||
if (hotlist_but[i].type & list_type)
|
if (hotlist_but[i].type & list_type)
|
||||||
add_widget (hotlist_dlg,
|
add_widget_autopos (hotlist_dlg,
|
||||||
button_new (BY + hotlist_but[i].y,
|
button_new (BY + hotlist_but[i].y,
|
||||||
BX + hotlist_but[i].x,
|
BX + hotlist_but[i].x,
|
||||||
hotlist_but[i].ret_cmd,
|
hotlist_but[i].ret_cmd,
|
||||||
hotlist_but[i].flags,
|
hotlist_but[i].flags,
|
||||||
hotlist_but[i].text,
|
hotlist_but[i].text,
|
||||||
hotlist_button_callback));
|
hotlist_button_callback),
|
||||||
|
hotlist_but[i].pos_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We add the labels.
|
/* We add the labels.
|
||||||
@ -648,11 +655,12 @@ init_hotlist (int list_type)
|
|||||||
* pname_group will hold name of current group
|
* pname_group will hold name of current group
|
||||||
*/
|
*/
|
||||||
pname = label_new (UY - 11 + LINES, UX + 2, "");
|
pname = label_new (UY - 11 + LINES, UX + 2, "");
|
||||||
add_widget (hotlist_dlg, pname);
|
add_widget_autopos (hotlist_dlg, pname, WPOS_KEEP_BOTTOM | WPOS_KEEP_LEFT);
|
||||||
if (!hotlist_state.moving) {
|
if (!hotlist_state.moving) {
|
||||||
add_widget (hotlist_dlg,
|
add_widget_autopos (hotlist_dlg,
|
||||||
label_new (UY - 12 + LINES, UX + 1,
|
label_new (UY - 12 + LINES, UX + 1,
|
||||||
_(" Directory path ")));
|
_(" Directory path ")),
|
||||||
|
WPOS_KEEP_BOTTOM | WPOS_KEEP_LEFT);
|
||||||
|
|
||||||
/* This one holds the displayed pathname */
|
/* This one holds the displayed pathname */
|
||||||
pname_group = label_new (UY, UX + 1, _(" Directory label "));
|
pname_group = label_new (UY, UX + 1, _(" Directory label "));
|
||||||
@ -672,7 +680,7 @@ init_hotlist (int list_type)
|
|||||||
#endif /* !USE_VFS */
|
#endif /* !USE_VFS */
|
||||||
fill_listbox ();
|
fill_listbox ();
|
||||||
|
|
||||||
add_widget (hotlist_dlg, l_hotlist);
|
add_widget_autopos (hotlist_dlg, l_hotlist, WPOS_KEEP_ALL);
|
||||||
/* add listbox to the dialogs */
|
/* add listbox to the dialogs */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "../src/tty/mouse.h" /* Gpm_Event */
|
#include "../src/tty/mouse.h" /* Gpm_Event */
|
||||||
#include "../src/tty/color.h"
|
#include "../src/tty/color.h"
|
||||||
#include "dialog.h"
|
#include "dialog.h"
|
||||||
|
#include "widget.h" /* default_proc*/
|
||||||
#include "info.h"
|
#include "info.h"
|
||||||
#include "dir.h" /* required by panel */
|
#include "dir.h" /* required by panel */
|
||||||
#include "panel.h" /* for the panel structure */
|
#include "panel.h" /* for the panel structure */
|
||||||
|
39
src/layout.c
39
src/layout.c
@ -64,6 +64,7 @@
|
|||||||
#include "tree.h"
|
#include "tree.h"
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
#include "strutil.h"
|
#include "strutil.h"
|
||||||
|
#include "background.h" /* we_are_background */
|
||||||
|
|
||||||
/* Needed for the extern declarations of integer parameters */
|
/* Needed for the extern declarations of integer parameters */
|
||||||
#include "dir.h"
|
#include "dir.h"
|
||||||
@ -585,6 +586,22 @@ repaint_screen (void)
|
|||||||
tty_refresh ();
|
tty_refresh ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
mc_refresh (void)
|
||||||
|
{
|
||||||
|
#ifdef WITH_BACKGROUND
|
||||||
|
if (we_are_background)
|
||||||
|
return;
|
||||||
|
#endif /* WITH_BACKGROUND */
|
||||||
|
if (winch_flag == 0)
|
||||||
|
tty_refresh ();
|
||||||
|
else {
|
||||||
|
/* if winch was caugth, we should do not only redraw screen, but
|
||||||
|
reposition/resize all */
|
||||||
|
change_screen_size ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
panel_do_cols (int index)
|
panel_do_cols (int index)
|
||||||
{
|
{
|
||||||
@ -645,10 +662,8 @@ setup_panels (void)
|
|||||||
|
|
||||||
if (command_prompt) {
|
if (command_prompt) {
|
||||||
widget_set_size (&cmdline->widget, LINES - 1 - keybar_visible,
|
widget_set_size (&cmdline->widget, LINES - 1 - keybar_visible,
|
||||||
promptl, 1,
|
promptl, 1, COLS - promptl);
|
||||||
COLS - promptl - (keybar_visible ? 0 : 1));
|
winput_set_origin (cmdline, promptl, COLS - promptl);
|
||||||
winput_set_origin (cmdline, promptl,
|
|
||||||
COLS - promptl - (keybar_visible ? 0 : 1));
|
|
||||||
widget_set_size (&the_prompt->widget, LINES - 1 - keybar_visible,
|
widget_set_size (&the_prompt->widget, LINES - 1 - keybar_visible,
|
||||||
0, 1, promptl);
|
0, 1, promptl);
|
||||||
} else {
|
} else {
|
||||||
@ -715,6 +730,8 @@ low_level_change_screen_size (void)
|
|||||||
void
|
void
|
||||||
change_screen_size (void)
|
change_screen_size (void)
|
||||||
{
|
{
|
||||||
|
Dlg_head *d;
|
||||||
|
|
||||||
winch_flag = 0;
|
winch_flag = 0;
|
||||||
#if defined(HAVE_SLANG) || NCURSES_VERSION_MAJOR >= 4
|
#if defined(HAVE_SLANG) || NCURSES_VERSION_MAJOR >= 4
|
||||||
#if defined TIOCGWINSZ
|
#if defined TIOCGWINSZ
|
||||||
@ -738,8 +755,12 @@ change_screen_size (void)
|
|||||||
#endif
|
#endif
|
||||||
setup_panels ();
|
setup_panels ();
|
||||||
|
|
||||||
/* Inform currently running dialog */
|
/* Inform all running dialogs */
|
||||||
(*current_dlg->callback) (current_dlg, DLG_RESIZE, 0);
|
d = current_dlg;
|
||||||
|
while (d != NULL) {
|
||||||
|
(*d->callback) (d, DLG_RESIZE, 0);
|
||||||
|
d = d->parent;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef RESIZABLE_MENUBAR
|
#ifdef RESIZABLE_MENUBAR
|
||||||
menubar_arrange (the_menubar);
|
menubar_arrange (the_menubar);
|
||||||
@ -765,7 +786,7 @@ void set_hintbar(const char *str)
|
|||||||
{
|
{
|
||||||
label_set_text (the_hint, str);
|
label_set_text (the_hint, str);
|
||||||
if (ok_to_refresh > 0)
|
if (ok_to_refresh > 0)
|
||||||
tty_refresh();
|
mc_refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_vfs_message (const char *msg, ...)
|
void print_vfs_message (const char *msg, ...)
|
||||||
@ -796,7 +817,7 @@ void print_vfs_message (const char *msg, ...)
|
|||||||
|
|
||||||
/* Restore cursor position */
|
/* Restore cursor position */
|
||||||
tty_gotoyx (row, col);
|
tty_gotoyx (row, col);
|
||||||
tty_refresh ();
|
mc_refresh ();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -818,7 +839,7 @@ void rotate_dash (void)
|
|||||||
tty_gotoyx (0, COLS - 1);
|
tty_gotoyx (0, COLS - 1);
|
||||||
tty_setcolor (NORMAL_COLOR);
|
tty_setcolor (NORMAL_COLOR);
|
||||||
tty_print_char (rotating_dash [pos]);
|
tty_print_char (rotating_dash [pos]);
|
||||||
tty_refresh ();
|
mc_refresh ();
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ void set_hintbar (const char *str);
|
|||||||
/* Clear screen */
|
/* Clear screen */
|
||||||
void clr_scr (void);
|
void clr_scr (void);
|
||||||
void repaint_screen (void);
|
void repaint_screen (void);
|
||||||
|
void mc_refresh (void);
|
||||||
|
|
||||||
extern int winch_flag;
|
extern int winch_flag;
|
||||||
extern int equal_split;
|
extern int equal_split;
|
||||||
|
@ -91,7 +91,7 @@ _("Please press the %s\n"
|
|||||||
"If you want to escape, press a single Escape key\n"
|
"If you want to escape, press a single Escape key\n"
|
||||||
"and wait as well."),
|
"and wait as well."),
|
||||||
_(key_name_conv_tab [action - B_USER].longname));
|
_(key_name_conv_tab [action - B_USER].longname));
|
||||||
tty_refresh ();
|
mc_refresh ();
|
||||||
if (learnkeys [action - B_USER].sequence != NULL) {
|
if (learnkeys [action - B_USER].sequence != NULL) {
|
||||||
g_free (learnkeys [action - B_USER].sequence);
|
g_free (learnkeys [action - B_USER].sequence);
|
||||||
learnkeys [action - B_USER].sequence = NULL;
|
learnkeys [action - B_USER].sequence = NULL;
|
||||||
|
@ -553,7 +553,7 @@ directory_history_list (WPanel *panel)
|
|||||||
if (!panel->dir_history)
|
if (!panel->dir_history)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
s = show_hist (panel->dir_history, panel->widget.x, panel->widget.y);
|
s = show_hist (panel->dir_history, &panel->widget);
|
||||||
|
|
||||||
if (!s)
|
if (!s)
|
||||||
return;
|
return;
|
||||||
@ -598,7 +598,7 @@ load_prompt (int fd, void *unused)
|
|||||||
* automatically: force a cursor update and a screen refresh
|
* automatically: force a cursor update and a screen refresh
|
||||||
*/
|
*/
|
||||||
update_cursor (midnight_dlg);
|
update_cursor (midnight_dlg);
|
||||||
tty_refresh ();
|
mc_refresh ();
|
||||||
}
|
}
|
||||||
update_prompt = 1;
|
update_prompt = 1;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
#include "help.h"
|
#include "help.h"
|
||||||
#include "dialog.h"
|
#include "dialog.h"
|
||||||
|
#include "widget.h"
|
||||||
#include "main.h" /* is_right */
|
#include "main.h" /* is_right */
|
||||||
#include "strutil.h"
|
#include "strutil.h"
|
||||||
|
|
||||||
|
@ -2140,7 +2140,7 @@ start_search (WPanel *panel)
|
|||||||
panel->search_char[0] = '\0';
|
panel->search_char[0] = '\0';
|
||||||
panel->search_chpoint = 0;
|
panel->search_chpoint = 0;
|
||||||
display_mini_info (panel);
|
display_mini_info (panel);
|
||||||
tty_refresh ();
|
mc_refresh ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
#include "../../src/tty/win.h" /* xterm_flag */
|
#include "../../src/tty/win.h" /* xterm_flag */
|
||||||
|
|
||||||
#include "../../src/main.h"
|
#include "../../src/main.h"
|
||||||
#include "../../src/layout.h" /* winch_flag */
|
#include "../../src/layout.h" /* winch_flag, mc_refresh() */
|
||||||
#include "../../src/cons.saver.h"
|
#include "../../src/cons.saver.h"
|
||||||
#include "../../src/strutil.h" /* str_casecmp */
|
#include "../../src/strutil.h" /* str_casecmp */
|
||||||
|
|
||||||
@ -1509,7 +1509,7 @@ tty_get_event (struct Gpm_Event *event, gboolean redo_event, gboolean block)
|
|||||||
static int dirty = 3;
|
static int dirty = 3;
|
||||||
|
|
||||||
if ((dirty == 3) || is_idle ()) {
|
if ((dirty == 3) || is_idle ()) {
|
||||||
tty_refresh ();
|
mc_refresh ();
|
||||||
dirty = 1;
|
dirty = 1;
|
||||||
} else
|
} else
|
||||||
dirty++;
|
dirty++;
|
||||||
|
@ -47,7 +47,6 @@
|
|||||||
#include "../../src/tty/color-internal.h"
|
#include "../../src/tty/color-internal.h"
|
||||||
#include "../../src/tty/win.h"
|
#include "../../src/tty/win.h"
|
||||||
|
|
||||||
#include "../../src/background.h" /* we_are_background */
|
|
||||||
#include "../../src/strutil.h" /* str_term_form */
|
#include "../../src/strutil.h" /* str_term_form */
|
||||||
|
|
||||||
/* include at last !!! */
|
/* include at last !!! */
|
||||||
@ -317,13 +316,8 @@ tty_tgetstr (const char *cap)
|
|||||||
void
|
void
|
||||||
tty_refresh (void)
|
tty_refresh (void)
|
||||||
{
|
{
|
||||||
#ifdef WITH_BACKGROUND
|
refresh ();
|
||||||
if (!we_are_background)
|
doupdate ();
|
||||||
#endif /* WITH_BACKGROUND */
|
|
||||||
{
|
|
||||||
refresh ();
|
|
||||||
doupdate ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -51,7 +51,6 @@
|
|||||||
#include "../../src/tty/key.h" /* define_sequence */
|
#include "../../src/tty/key.h" /* define_sequence */
|
||||||
#include "../../src/tty/win.h"
|
#include "../../src/tty/win.h"
|
||||||
|
|
||||||
#include "../../src/background.h" /* we_are_background */
|
|
||||||
#include "../../src/strutil.h" /* str_term_form */
|
#include "../../src/strutil.h" /* str_term_form */
|
||||||
|
|
||||||
/*** global variables **************************************************/
|
/*** global variables **************************************************/
|
||||||
@ -497,10 +496,7 @@ tty_tgetstr (const char *cap)
|
|||||||
void
|
void
|
||||||
tty_refresh (void)
|
tty_refresh (void)
|
||||||
{
|
{
|
||||||
#ifdef WITH_BACKGROUND
|
SLsmg_refresh ();
|
||||||
if (!we_are_background)
|
|
||||||
#endif /* WITH_BACKGROUND */
|
|
||||||
SLsmg_refresh ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -45,7 +45,6 @@ extern void tty_nodelay (gboolean set);
|
|||||||
extern int tty_baudrate (void);
|
extern int tty_baudrate (void);
|
||||||
|
|
||||||
extern int tty_lowlevel_getch (void);
|
extern int tty_lowlevel_getch (void);
|
||||||
extern int tty_getch (void);
|
|
||||||
|
|
||||||
/* {{{ Output }}} */
|
/* {{{ Output }}} */
|
||||||
|
|
||||||
|
@ -3079,7 +3079,7 @@ view_search_update_cmd_callback(const void *user_data, gsize char_offset)
|
|||||||
view->update_activate += view->update_steps;
|
view->update_activate += view->update_steps;
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
view_percent (view, char_offset);
|
view_percent (view, char_offset);
|
||||||
tty_refresh ();
|
mc_refresh ();
|
||||||
}
|
}
|
||||||
if (tty_got_interrupt ())
|
if (tty_got_interrupt ())
|
||||||
return MC_SEARCH_CB_ABORT;
|
return MC_SEARCH_CB_ABORT;
|
||||||
@ -3169,7 +3169,7 @@ do_search (WView *view)
|
|||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
d = create_message (D_NORMAL, _("Search"), _("Searching %s"), view->last_search_string);
|
d = create_message (D_NORMAL, _("Search"), _("Searching %s"), view->last_search_string);
|
||||||
tty_refresh ();
|
mc_refresh ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*for avoid infinite search loop we need to increase or decrease start offset of search */
|
/*for avoid infinite search loop we need to increase or decrease start offset of search */
|
||||||
@ -3217,7 +3217,7 @@ do_search (WView *view)
|
|||||||
dlg_run_done (d);
|
dlg_run_done (d);
|
||||||
destroy_dlg (d);
|
destroy_dlg (d);
|
||||||
d = create_message (D_NORMAL, _("Search"), _("Seeking to search result"));
|
d = create_message (D_NORMAL, _("Search"), _("Seeking to search result"));
|
||||||
tty_refresh ();
|
mc_refresh ();
|
||||||
}
|
}
|
||||||
|
|
||||||
view_moveto_match (view);
|
view_moveto_match (view);
|
||||||
|
149
src/widget.c
149
src/widget.c
@ -148,6 +148,28 @@ draw_hotkey (Widget *w, const struct hotkey_t hotkey, gboolean focused)
|
|||||||
tty_print_string (hotkey.end);
|
tty_print_string (hotkey.end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Default callback for widgets */
|
||||||
|
cb_ret_t
|
||||||
|
default_proc (widget_msg_t msg, int parm)
|
||||||
|
{
|
||||||
|
(void) parm;
|
||||||
|
|
||||||
|
switch (msg) {
|
||||||
|
case WIDGET_INIT:
|
||||||
|
case WIDGET_FOCUS:
|
||||||
|
case WIDGET_UNFOCUS:
|
||||||
|
case WIDGET_DRAW:
|
||||||
|
case WIDGET_DESTROY:
|
||||||
|
case WIDGET_CURSOR:
|
||||||
|
case WIDGET_IDLE:
|
||||||
|
return MSG_HANDLED;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return MSG_NOT_HANDLED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int button_event (Gpm_Event *event, void *);
|
static int button_event (Gpm_Event *event, void *);
|
||||||
|
|
||||||
int quote = 0;
|
int quote = 0;
|
||||||
@ -1011,55 +1033,111 @@ listbox_fwd (WListbox *l)
|
|||||||
listbox_select_first (l);
|
listbox_select_first (l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
Widget *widget;
|
||||||
|
int count;
|
||||||
|
size_t maxlen;
|
||||||
|
} dlg_hist_data;
|
||||||
|
|
||||||
|
static cb_ret_t
|
||||||
|
dlg_hist_reposition (Dlg_head *dlg_head)
|
||||||
|
{
|
||||||
|
dlg_hist_data *data;
|
||||||
|
int x = 0, y, he, wi;
|
||||||
|
|
||||||
|
/* guard checks */
|
||||||
|
if ((dlg_head == NULL)
|
||||||
|
|| (dlg_head->data == NULL))
|
||||||
|
return MSG_NOT_HANDLED;
|
||||||
|
|
||||||
|
data = (dlg_hist_data *) dlg_head->data;
|
||||||
|
|
||||||
|
y = data->widget->y;
|
||||||
|
he = data->count + 2;
|
||||||
|
|
||||||
|
if (he <= y || y > (LINES - 6)) {
|
||||||
|
he = min (he, y - 1);
|
||||||
|
y -= he;
|
||||||
|
} else {
|
||||||
|
y++;
|
||||||
|
he = min (he, LINES - y);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data->widget->x > 2)
|
||||||
|
x = data->widget->x - 2;
|
||||||
|
|
||||||
|
wi = data->maxlen + 4;
|
||||||
|
|
||||||
|
if ((wi + x) > COLS) {
|
||||||
|
wi = min (wi, COLS);
|
||||||
|
x = COLS - wi;
|
||||||
|
}
|
||||||
|
|
||||||
|
dlg_set_position (dlg_head, y, x, y + he, x + wi);
|
||||||
|
|
||||||
|
return MSG_HANDLED;
|
||||||
|
}
|
||||||
|
|
||||||
|
static cb_ret_t
|
||||||
|
dlg_hist_callback (Dlg_head *h, dlg_msg_t msg, int parm)
|
||||||
|
{
|
||||||
|
switch (msg) {
|
||||||
|
case DLG_RESIZE:
|
||||||
|
return dlg_hist_reposition (h);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return default_dlg_callback (h, msg, parm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
show_hist (GList *history, int widget_x, int widget_y)
|
show_hist (GList *history, Widget *widget)
|
||||||
{
|
{
|
||||||
GList *hi, *z;
|
GList *hi, *z;
|
||||||
size_t maxlen = str_term_width1 (i18n_htitle ()), i, count = 0;
|
size_t maxlen, i, count = 0;
|
||||||
int x, y, w, h;
|
char *q, *r = NULL;
|
||||||
char *q = NULL, *r = NULL;
|
|
||||||
Dlg_head *query_dlg;
|
Dlg_head *query_dlg;
|
||||||
WListbox *query_list;
|
WListbox *query_list;
|
||||||
|
dlg_hist_data hist_data;
|
||||||
|
|
||||||
z = history;
|
if (history == NULL)
|
||||||
if (!z)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
maxlen = str_term_width1 (i18n_htitle ());
|
||||||
|
|
||||||
z = g_list_first (history);
|
z = g_list_first (history);
|
||||||
hi = z;
|
hi = z;
|
||||||
while (hi) {
|
while (hi) {
|
||||||
if ((i = str_term_width1 ((char *) hi->data)) > maxlen)
|
i = str_term_width1 ((char *) hi->data);
|
||||||
maxlen = i;
|
maxlen = max (maxlen, i);
|
||||||
count++;
|
count++;
|
||||||
hi = g_list_next (hi);
|
hi = g_list_next (hi);
|
||||||
}
|
}
|
||||||
|
|
||||||
y = widget_y;
|
hist_data.maxlen = maxlen;
|
||||||
h = count + 2;
|
hist_data.widget = widget;
|
||||||
if (h <= y || y > LINES - 6) {
|
hist_data.count = count;
|
||||||
h = min (h, y - 1);
|
|
||||||
y -= h;
|
|
||||||
} else {
|
|
||||||
y++;
|
|
||||||
h = min (h, LINES - y);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (widget_x > 2)
|
|
||||||
x = widget_x - 2;
|
|
||||||
else
|
|
||||||
x = 0;
|
|
||||||
if ((w = maxlen + 4) + x > COLS) {
|
|
||||||
w = min (w, COLS);
|
|
||||||
x = COLS - w;
|
|
||||||
}
|
|
||||||
|
|
||||||
query_dlg =
|
query_dlg =
|
||||||
create_dlg (y, x, h, w, dialog_colors, NULL, "[History-query]",
|
create_dlg (0, 0, 4, 4, dialog_colors, dlg_hist_callback,
|
||||||
i18n_htitle (), DLG_COMPACT);
|
"[History-query]", i18n_htitle (), DLG_COMPACT);
|
||||||
query_list = listbox_new (1, 1, h - 2, w - 2, NULL);
|
query_dlg->data = &hist_data;
|
||||||
add_widget (query_dlg, query_list);
|
|
||||||
|
|
||||||
if (y < widget_y) {
|
query_list = listbox_new (1, 1, 2, 2, NULL);
|
||||||
|
|
||||||
|
/* this call makes list stick to all sides of dialog, effectively make
|
||||||
|
it be resized with dialog */
|
||||||
|
add_widget_autopos (query_dlg, query_list, WPOS_KEEP_ALL);
|
||||||
|
|
||||||
|
/* to avoid diplicating of (calculating sizes in two places)
|
||||||
|
code, call dlg_hist_callback function here, to set dialog and
|
||||||
|
controls positions.
|
||||||
|
The main idea - create 4x4 dialog and add 2x2 list in
|
||||||
|
center of it, and let dialog function resize it to needed
|
||||||
|
size. */
|
||||||
|
dlg_hist_callback (query_dlg, DLG_RESIZE, 0);
|
||||||
|
|
||||||
|
if (query_dlg->y < widget->y) {
|
||||||
/* traverse */
|
/* traverse */
|
||||||
hi = z;
|
hi = z;
|
||||||
while (hi) {
|
while (hi) {
|
||||||
@ -1088,10 +1166,10 @@ show_hist (GList *history, int widget_x, int widget_y)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_show_hist (WInput * in)
|
do_show_hist (WInput *in)
|
||||||
{
|
{
|
||||||
char *r;
|
char *r;
|
||||||
r = show_hist (in->history, in->widget.x, in->widget.y);
|
r = show_hist (in->history, &in->widget);
|
||||||
if (r) {
|
if (r) {
|
||||||
assign_text (in, r);
|
assign_text (in, r);
|
||||||
g_free (r);
|
g_free (r);
|
||||||
@ -2210,6 +2288,9 @@ listbox_callback (Widget *w, widget_msg_t msg, int parm)
|
|||||||
listbox_destroy (l);
|
listbox_destroy (l);
|
||||||
return MSG_HANDLED;
|
return MSG_HANDLED;
|
||||||
|
|
||||||
|
case WIDGET_RESIZED:
|
||||||
|
return MSG_HANDLED;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return default_proc (msg, parm);
|
return default_proc (msg, parm);
|
||||||
}
|
}
|
||||||
@ -2246,7 +2327,7 @@ listbox_event (Gpm_Event *event, void *data)
|
|||||||
/* We need to refresh ourselves since the dialog manager doesn't */
|
/* We need to refresh ourselves since the dialog manager doesn't */
|
||||||
/* know about this event */
|
/* know about this event */
|
||||||
listbox_callback (w, WIDGET_DRAW, 0);
|
listbox_callback (w, WIDGET_DRAW, 0);
|
||||||
tty_refresh ();
|
mc_refresh ();
|
||||||
return MOU_REPEAT;
|
return MOU_REPEAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +92,9 @@ typedef struct WGauge {
|
|||||||
|
|
||||||
GList *history_get (const char *input_name);
|
GList *history_get (const char *input_name);
|
||||||
void history_put (const char *input_name, GList *h);
|
void history_put (const char *input_name, GList *h);
|
||||||
char *show_hist (GList *history, int widget_y, int widget_x);
|
/* for repositioning of history dialog we should pass widget to this
|
||||||
|
* function, as position of history dialog depends on widget's position */
|
||||||
|
char *show_hist (GList *history, Widget *widget);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Widget widget;
|
Widget widget;
|
||||||
@ -162,6 +164,9 @@ typedef struct WGroupbox {
|
|||||||
} WGroupbox;
|
} WGroupbox;
|
||||||
|
|
||||||
|
|
||||||
|
/* Default callback for widgets */
|
||||||
|
cb_ret_t default_proc (widget_msg_t msg, int parm);
|
||||||
|
|
||||||
/* Constructors */
|
/* Constructors */
|
||||||
WButton *button_new (int y, int x, int action, int flags, const char *text,
|
WButton *button_new (int y, int x, int action, int flags, const char *text,
|
||||||
bcback callback);
|
bcback callback);
|
||||||
|
57
src/wtools.c
57
src/wtools.c
@ -94,20 +94,37 @@ create_listbox_window (int cols, int lines, const char *title, const char *help)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Returns the number of the item selected */
|
/* Returns the number of the item selected */
|
||||||
int run_listbox (Listbox *l)
|
int
|
||||||
|
run_listbox (Listbox *l)
|
||||||
{
|
{
|
||||||
int val;
|
int val = -1;
|
||||||
|
|
||||||
run_dlg (l->dlg);
|
if (run_dlg (l->dlg) != B_CANCEL)
|
||||||
if (l->dlg->ret_value == B_CANCEL)
|
|
||||||
val = -1;
|
|
||||||
else
|
|
||||||
val = l->list->pos;
|
val = l->list->pos;
|
||||||
destroy_dlg (l->dlg);
|
destroy_dlg (l->dlg);
|
||||||
g_free (l);
|
g_free (l);
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* default query callback, used to reposition query */
|
||||||
|
static cb_ret_t
|
||||||
|
default_query_callback (Dlg_head *h, dlg_msg_t msg, int parm)
|
||||||
|
{
|
||||||
|
switch (msg) {
|
||||||
|
case DLG_RESIZE:
|
||||||
|
{
|
||||||
|
int xpos = COLS / 2 - h->cols / 2;
|
||||||
|
int ypos = LINES / 3 - (h->lines - 3) / 2;
|
||||||
|
|
||||||
|
/* set position */
|
||||||
|
dlg_set_position (h, ypos, xpos, ypos + h->lines, xpos + h->cols);
|
||||||
|
}
|
||||||
|
return MSG_HANDLED;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return default_dlg_callback (h, msg, parm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static Dlg_head *last_query_dlg;
|
static Dlg_head *last_query_dlg;
|
||||||
|
|
||||||
@ -124,16 +141,10 @@ query_dialog (const char *header, const char *text, int flags, int count, ...)
|
|||||||
int win_len = 0;
|
int win_len = 0;
|
||||||
int i;
|
int i;
|
||||||
int result = -1;
|
int result = -1;
|
||||||
int xpos, ypos;
|
|
||||||
int cols, lines;
|
int cols, lines;
|
||||||
char *cur_name;
|
char *cur_name;
|
||||||
static const int *query_colors;
|
const int *query_colors = (flags & D_ERROR) ?
|
||||||
|
alarm_colors : dialog_colors;
|
||||||
/* set dialog colors */
|
|
||||||
if (flags & D_ERROR)
|
|
||||||
query_colors = alarm_colors;
|
|
||||||
else
|
|
||||||
query_colors = dialog_colors;
|
|
||||||
|
|
||||||
if (header == MSG_ERROR)
|
if (header == MSG_ERROR)
|
||||||
header = _("Error");
|
header = _("Error");
|
||||||
@ -153,18 +164,18 @@ query_dialog (const char *header, const char *text, int flags, int count, ...)
|
|||||||
str_msg_term_size (text, &lines, &cols);
|
str_msg_term_size (text, &lines, &cols);
|
||||||
cols = 6 + max (win_len, max (str_term_width1 (header), cols));
|
cols = 6 + max (win_len, max (str_term_width1 (header), cols));
|
||||||
lines += 4 + (count > 0 ? 2 : 0);
|
lines += 4 + (count > 0 ? 2 : 0);
|
||||||
xpos = COLS / 2 - cols / 2;
|
|
||||||
ypos = LINES / 3 - (lines - 3) / 2;
|
|
||||||
|
|
||||||
/* prepare dialog */
|
/* prepare dialog */
|
||||||
query_dlg =
|
query_dlg =
|
||||||
create_dlg (ypos, xpos, lines, cols, query_colors, NULL,
|
create_dlg (0, 0, lines, cols, query_colors, default_query_callback,
|
||||||
"[QueryBox]", header, DLG_NONE);
|
"[QueryBox]", header, DLG_NONE);
|
||||||
|
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
cols = (cols - win_len - 2) / 2 + 2;
|
cols = (cols - win_len - 2) / 2 + 2;
|
||||||
va_start (ap, count);
|
va_start (ap, count);
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
|
int xpos;
|
||||||
|
|
||||||
cur_name = va_arg (ap, char *);
|
cur_name = va_arg (ap, char *);
|
||||||
xpos = str_term_width1 (cur_name) + 6;
|
xpos = str_term_width1 (cur_name) + 6;
|
||||||
if (strchr (cur_name, '&') != NULL)
|
if (strchr (cur_name, '&') != NULL)
|
||||||
@ -182,12 +193,14 @@ query_dialog (const char *header, const char *text, int flags, int count, ...)
|
|||||||
|
|
||||||
add_widget (query_dlg, label_new (2, 3, text));
|
add_widget (query_dlg, label_new (2, 3, text));
|
||||||
|
|
||||||
|
/* do resize before running and selecting any widget */
|
||||||
|
default_query_callback (query_dlg, DLG_RESIZE, 0);
|
||||||
|
|
||||||
if (defbutton)
|
if (defbutton)
|
||||||
dlg_select_widget (defbutton);
|
dlg_select_widget (defbutton);
|
||||||
|
|
||||||
/* run dialog and make result */
|
/* run dialog and make result */
|
||||||
run_dlg (query_dlg);
|
switch (run_dlg (query_dlg)) {
|
||||||
switch (query_dlg->ret_value) {
|
|
||||||
case B_CANCEL:
|
case B_CANCEL:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -223,6 +236,10 @@ do_create_message (int flags, const char *title, const char *text)
|
|||||||
p = g_strconcat ("\n", text, "\n", (char *) NULL);
|
p = g_strconcat ("\n", text, "\n", (char *) NULL);
|
||||||
query_dialog (title, p, flags, 0);
|
query_dialog (title, p, flags, 0);
|
||||||
d = last_query_dlg;
|
d = last_query_dlg;
|
||||||
|
|
||||||
|
/* do resize before initing and running */
|
||||||
|
default_query_callback (d, DLG_RESIZE, 0);
|
||||||
|
|
||||||
init_dlg (d);
|
init_dlg (d);
|
||||||
g_free (p);
|
g_free (p);
|
||||||
|
|
||||||
|
@ -65,6 +65,7 @@ What to do with this?
|
|||||||
/* \todo Fix: Namespace pollution: horrible */
|
/* \todo Fix: Namespace pollution: horrible */
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
#include <stdlib.h> /* atoi() */
|
||||||
#include <sys/types.h> /* POSIX-required by sys/socket.h and netdb.h */
|
#include <sys/types.h> /* POSIX-required by sys/socket.h and netdb.h */
|
||||||
#include <netdb.h> /* struct hostent */
|
#include <netdb.h> /* struct hostent */
|
||||||
#include <sys/socket.h> /* AF_INET */
|
#include <sys/socket.h> /* AF_INET */
|
||||||
@ -1039,7 +1040,7 @@ again:
|
|||||||
|
|
||||||
port = ntohs (port);
|
port = ntohs (port);
|
||||||
|
|
||||||
addr = malloc (NI_MAXHOST);
|
addr = g_malloc (NI_MAXHOST);
|
||||||
if (addr == NULL)
|
if (addr == NULL)
|
||||||
ERRNOR (ENOMEM, -1);
|
ERRNOR (ENOMEM, -1);
|
||||||
|
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user