mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 12:56:51 +03:00
Merge branch '1490_multi_screens'
* 1490_multi_screens: (21 commits) Updated EN and RU man pages. Lock file is created and destroyed with full path. Implemented file locking in hex editor. Allow use file locking in various components of MC. Ask user before exit if there are opened screens in MC. SIGWINCH handling in suspended dialogs. Close dialogs during MC shutdown. Support of multiple editors and viewers. Added code names for parentheses, brackets and braces. MC Edit: column_highlighting flag is a member of WEdit struct. MCView: reimplemented messages and commands handling. Added type for MC viewer exit codes. Changed MC viewer run interface. Added function to get dialog title. Renamed current_dlg variable to top_dlg. Added modal flag to the dialog structure. Renamed dlg_id and parent fields of Widget structure. Reimplemented widget list in dialog using GList. Added dialog state (active, suspended, closed). Modified dialog initialization. Reimplemented dialogs stack using GList. ...
This commit is contained in:
commit
9adda31a9f
@ -1213,16 +1213,16 @@ command shows a tree figure of the directories.
|
||||
.PP
|
||||
The
|
||||
.\"LINK2"
|
||||
Find file
|
||||
"Find file"
|
||||
.\"Find File"
|
||||
command allows you to search for a specific file.
|
||||
.PP
|
||||
The "Swap panels" command swaps the contents of the two directory panels.
|
||||
.PP
|
||||
The "Panels on/off" command shows the output of the last shell command.
|
||||
The "Switch panels on/off" command shows the output of the last shell command.
|
||||
This works only on xterm and on Linux and FreeBSD console.
|
||||
.PP
|
||||
The Compare directories (C\-x d) command compares the directory
|
||||
The "Compare directories" command compares the directory
|
||||
panels with each other. You can then use the Copy (F5) command to make
|
||||
the panels identical. There are three compare methods. The quick method
|
||||
compares only file size and file date. The thorough method makes a
|
||||
@ -1231,32 +1231,42 @@ machine does not support the mmap(2) system call. The size\-only
|
||||
compare method just compares the file sizes and does not check the
|
||||
contents or the date times, it just checks the file size.
|
||||
.PP
|
||||
The Command history command shows a list of typed commands. The
|
||||
The
|
||||
.\"LINK2"
|
||||
"External panelize"
|
||||
.\"External panelize"
|
||||
allows you to execute an external program, and make the output of that
|
||||
program the contents of the current panel.
|
||||
.PP
|
||||
The "Command history" command shows a list of typed commands. The
|
||||
selected command is copied to the command line. The command history
|
||||
can also be accessed by typing Alt\-p or Alt\-n.
|
||||
.PP
|
||||
The
|
||||
.\"LINK2"
|
||||
Directory hotlist (C\-\\)
|
||||
"Directory hotlist"
|
||||
.\"Hotlist"
|
||||
command makes changing of the current directory to often used directories
|
||||
faster.
|
||||
.PP
|
||||
The
|
||||
.\"LINK2"
|
||||
External panelize
|
||||
.\"External panelize"
|
||||
allows you to execute an external program, and make the output of that
|
||||
program the contents of the current panel.
|
||||
"Screen list"
|
||||
.\"Screen selector"
|
||||
command shows a dialog window with the list of currently running
|
||||
internal editors, viewers and other MC modules that support this mode.
|
||||
.PP
|
||||
The
|
||||
.\"LINK2"
|
||||
Extension file edit
|
||||
"Edit extension file"
|
||||
.\"Extension File Edit"
|
||||
command allows you to specify programs to executed when you try to
|
||||
execute, view, edit and do a bunch of other thing on files
|
||||
with certain extensions (filename endings). The
|
||||
with certain extensions (filename endings).
|
||||
.PP
|
||||
The
|
||||
.\"LINK2"
|
||||
Menu file edit
|
||||
"Edit menu file"
|
||||
.\"Menu File Edit"
|
||||
command may be used for editing the user menu (which appears by
|
||||
pressing F2).
|
||||
@ -2909,11 +2919,9 @@ indent and ispell.
|
||||
.PP
|
||||
Sections:
|
||||
.IP
|
||||
|
||||
.\"LINK2"
|
||||
Options of editor in ini-file
|
||||
.\"Internal File Editor / options"
|
||||
|
||||
.PP
|
||||
The editor is very easy to use and requires no tutoring. To see what
|
||||
keys do what, just consult the appropriate pull\-down menu. Other keys
|
||||
@ -2949,13 +2957,11 @@ commands go into the file
|
||||
.B .mc/cedit/cooledit.macros
|
||||
in your home directory. You can delete a macro by deleting the
|
||||
appropriate line in this file.
|
||||
|
||||
.PP
|
||||
To change charset of displayed text may use M\-e (Alt\-e).
|
||||
Recoding is made from selected codepage into system codepage. To
|
||||
cancel the recoding you may select "<No translation>" in charset
|
||||
selection dialog.
|
||||
|
||||
.PP
|
||||
.B F19
|
||||
will format the currently highlighted block (plain text or
|
||||
@ -2976,16 +2982,32 @@ to 7 bits in the options menu to keep the spacing clean.
|
||||
|
||||
.\"NODE "Internal File Editor / options"
|
||||
.SH "Options of editor in ini-file"
|
||||
|
||||
In this section described some options in ini-file.
|
||||
Options placed in '[Midnight Commander]' section
|
||||
|
||||
.TP
|
||||
.I editor_wordcompletion_collect_entire_file
|
||||
Search autocomplete candidates in entire of file or just from
|
||||
begin of file to cursor position (0)
|
||||
|
||||
|
||||
.\"NODE "Screen selector"
|
||||
.SH "Screen selector"
|
||||
Midnight Commander supports running many internal modules (such as
|
||||
editor, viewer and diff viewer) simultaneously and switching between
|
||||
them without closing open files. Using several file managers at a time,
|
||||
however, is not currently supported.
|
||||
.PP
|
||||
Let's call each of these modules a screen. There are three ways to
|
||||
switch between screens, using one of these global shortcuts:
|
||||
.TP
|
||||
.B Alt\-}
|
||||
switch to the next screen;
|
||||
.TP
|
||||
.B Alt\-{
|
||||
switch to the previous screen;
|
||||
.TP
|
||||
.B Alt\-`
|
||||
open a dialog window with the list of currently open screens (or use the
|
||||
"Screen list" menu item).
|
||||
.\"NODE "Completion"
|
||||
.SH "Completion"
|
||||
Let the Midnight Commander type for you.
|
||||
|
@ -1,6 +1,6 @@
|
||||
.\"TOPICS "Разделы помощи:"
|
||||
.\" TODO: Перевести раздел EXTernal File System
|
||||
.TH MC 1 "Июнь 2010" "MC Version 4.7.3" "GNU Midnight Commander"
|
||||
.TH MC "15 Июня 2010" "MC Version 4.7.3" "GNU Midnight Commander"
|
||||
.\"SKIP_SECTION"
|
||||
.SH "НАИМЕНОВАНИЕ"
|
||||
mc \- Визуальная оболочка для Unix\-подобных систем.
|
||||
@ -1230,7 +1230,6 @@ cd\&.
|
||||
После этого надо нажать клавишу <Enter>.
|
||||
.\"NODE " Command Menu"
|
||||
.SH " Меню 'Команды'"
|
||||
.PP
|
||||
.B Меню пользователя (F2)
|
||||
.PP
|
||||
Вызывает
|
||||
@ -1240,35 +1239,34 @@ cd\&.
|
||||
Меню пользователя предоставляет простой способ расширения возможностей
|
||||
Midnight Commander за счет добавления в личное меню пользователя вызова
|
||||
часто используемых программ.
|
||||
.PP
|
||||
При обращении к пункту меню
|
||||
.\"LINK2"
|
||||
.I Дерево каталогов
|
||||
.I "Дерево каталогов"
|
||||
.\"Directory Tree"
|
||||
выводится окно, отображающее структуру каталогов файловой системы.
|
||||
.PP
|
||||
Команда
|
||||
.\"LINK2"
|
||||
.I Поиск файла
|
||||
.I "Поиск файла"
|
||||
.\"Find File"
|
||||
позволяет найти на диске файл с заданным именем. "Горячие" клавиши \-
|
||||
.BR M\-? .
|
||||
.PP
|
||||
Команда
|
||||
.I "Переставить панели"
|
||||
("Swap panels") меняет местами содержимое
|
||||
правой и левой панелей. "Горячие" клавиши \-
|
||||
меняет местами содержимое правой и левой панелей. "Горячие" клавиши \-
|
||||
.BR C\-u .
|
||||
.PP
|
||||
По команде
|
||||
.I "Отключить панели"
|
||||
("Panels on/off") показывается вывод последней из выполнявшихся команд
|
||||
shell. Эта команда работает только через xterm и на консоли Linux и
|
||||
FreeBSD. "Горячие" клавиши \-
|
||||
показывается вывод последней из выполнявшихся команд облочки. Эта команда
|
||||
работает только через xterm и на консоли Linux и FreeBSD. "Горячие" клавиши \-
|
||||
.BR C\-o .
|
||||
.PP
|
||||
По команде
|
||||
.I "Сравнить каталоги"
|
||||
("Compare directories", "горячие" клавиши \-
|
||||
("горячие" клавиши \-
|
||||
.BR "C\-x d" )
|
||||
сравнивается содержимое каталогов, отображаемых на левой и правой
|
||||
панелях. После сравнения можно воспользоваться командой
|
||||
@ -1283,14 +1281,13 @@ FreeBSD. "Горячие" клавиши \-
|
||||
.PP
|
||||
Пункт меню
|
||||
.\"LINK2"
|
||||
.I "Критерий панелизации"
|
||||
.I "Внешняя панелизация"
|
||||
.\"External panelize"
|
||||
позволяет выполнить внешнюю программу, сделав ее вывод содержимым
|
||||
текущей панели (характерный пример \- панелизация вывода команды find).
|
||||
.PP
|
||||
.PP
|
||||
Пункт меню
|
||||
.I "История команд"
|
||||
.I "История командной строки"
|
||||
выводит окно со списком ранее выполнявшихся
|
||||
команд. Подсвеченную строку из истории можно скопировать в командную
|
||||
строку оболочки (перемещение подсветки \- стрелками вверх/вниз,
|
||||
@ -1310,13 +1307,11 @@ FreeBSD. "Горячие" клавиши \-
|
||||
.\"LINK2"
|
||||
.I "Быстрый доступ к каталогам"
|
||||
.\"Hotlist"
|
||||
.B C\-\\\\
|
||||
позволяет создать список каталогов, которые часто используются, и
|
||||
обеспечить быстрый переход к нужному каталогу из этого списка.
|
||||
.PP
|
||||
Пункт меню
|
||||
.I "Список активных ВФС"
|
||||
.B C\-x a
|
||||
отображает список виртуальных файловых систем, активных на настоящий
|
||||
момент. Можно перейти на выбранную виртуальную файловую систему. Для
|
||||
Обновления списка выберите кнопку "Освежить" в диалоговом окне.
|
||||
@ -1327,10 +1322,17 @@ FreeBSD. "Горячие" клавиши \-
|
||||
.\"LINK2"
|
||||
.I "Фоновые задания"
|
||||
.\"Background Jobs"
|
||||
.B C\-x j
|
||||
отображает список фоновых заданий, запущенных в диалоге
|
||||
копирования/перемещения кнопкой "В фоне".
|
||||
.PP
|
||||
Пункт меню
|
||||
.\"LINK2"
|
||||
.I "Список экранов"
|
||||
.\"Screen selector"
|
||||
отображает диалоговое окно со списком одновременно работающих в данный
|
||||
момент встроенноых редакторов, программ просмотра и других модулей MC,
|
||||
поддерживающих такой режим работы.
|
||||
.PP
|
||||
После выбора пункта меню
|
||||
.\"LINK2"
|
||||
.I "Файл расширений"
|
||||
@ -3274,16 +3276,32 @@ pipe text blocks through shell commands like indent).
|
||||
|
||||
.\"NODE "Internal File Editor / options"
|
||||
.SH "Опции в ини-файле для редактора"
|
||||
|
||||
.PP
|
||||
В данном разделе кратко описаны опции ini\-файла, относящиеся к редактору.
|
||||
Опции записываются в секцию '[Midnight Commander]'
|
||||
|
||||
.TP
|
||||
.I editor_wordcompletion_collect_entire_file
|
||||
При автодополнении для сбора похожих слов слов просматривать весь файл(1)
|
||||
или только от начала до курсора (0)
|
||||
|
||||
|
||||
.\"NODE "Screen selector"
|
||||
.SH "Список экранов"
|
||||
Midnight Commander поддерживает возможность одновременной работы своих
|
||||
встроенных модулей (таких как редактор, программа просмотра, программа сравнения
|
||||
файлов) и переключения между ними без необходимости закрытия загруженных файлов.
|
||||
Файловый менеджер может быть только один, несколько файловых менеджеров,
|
||||
работающих одновременно, не поддерживаются. Назовём каждый из таких модулей
|
||||
экраном.
|
||||
.PP
|
||||
Есть три способа переключения между экранами:
|
||||
переходк к следующему экрану в списке клавиатурной комбинацией
|
||||
.BR Alt\-} ,
|
||||
переходк к предыдущему экрану в списке клавиатурной комбинацией
|
||||
.BR Alt\-{ ,
|
||||
вызов дилогового окна со списком экранов клавиатурной комбинацией
|
||||
.BR Alt\-`
|
||||
или с помощью пункта меню.
|
||||
Все эти комбинации клавиш одинаковы во всех экранах.
|
||||
|
||||
.\"NODE "Completion"
|
||||
.SH "Завершение ввода (Completion)"
|
||||
|
@ -23,6 +23,7 @@ libmc_la_SOURCES = \
|
||||
fs.h \
|
||||
glibcompat.c glibcompat.h \
|
||||
global.h \
|
||||
lock.c lock.h \
|
||||
timefmt.h
|
||||
|
||||
if USE_MAINTAINER_MODE
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* editor file locking.
|
||||
/* file locking
|
||||
|
||||
Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
|
||||
|
||||
@ -22,11 +22,11 @@
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief Source: editor file locking
|
||||
* \brief Source: file locking
|
||||
* \author Adam Byrtek
|
||||
* \date 2003
|
||||
*
|
||||
* Locking scheme used in mcedit is based on a documentation found
|
||||
* Locking scheme is based on a documentation found
|
||||
* in JED editor sources. Abstract from lock.c file (by John E. Davis):
|
||||
*
|
||||
* The basic idea here is quite simple. Whenever a buffer is attached to
|
||||
@ -54,13 +54,9 @@
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/vfs/mc-vfs/vfs.h"
|
||||
#include "lib/strutil.h" /* utf string functions */
|
||||
#include "lib/lock.h"
|
||||
|
||||
|
||||
#include "edit-impl.h"
|
||||
#include "editlock.h"
|
||||
|
||||
#include "src/wtools.h" /* edit_query_dialog () */
|
||||
#include "src/wtools.h" /* query_dialog() */
|
||||
|
||||
#define BUF_SIZE 255
|
||||
#define PID_BUF_SIZE 10
|
||||
@ -164,7 +160,7 @@ lock_get_info (const char *lockfname)
|
||||
Returns 1 on success, 0 on failure, -1 if abort
|
||||
Warning: Might do screen refresh and lose edit->force */
|
||||
int
|
||||
edit_lock_file (const char *fname)
|
||||
lock_file (const char *fname)
|
||||
{
|
||||
char *lockfname, *newlock, *msg, *lock;
|
||||
struct stat statbuf;
|
||||
@ -199,8 +195,8 @@ edit_lock_file (const char *fname)
|
||||
"User: %s\nProcess ID: %d"), x_basename (lockfname) + 2,
|
||||
lockinfo->who, (int) lockinfo->pid);
|
||||
/* TODO: Implement "Abort" - needs to rewind undo stack */
|
||||
switch (edit_query_dialog2
|
||||
(_("File locked"), msg, _("&Grab lock"),
|
||||
switch (query_dialog
|
||||
(_("File locked"), msg, D_NORMAL, 2, _("&Grab lock"),
|
||||
_("&Ignore lock"))) {
|
||||
case 0:
|
||||
break;
|
||||
@ -229,9 +225,9 @@ edit_lock_file (const char *fname)
|
||||
}
|
||||
|
||||
/* Lowers file lock if possible
|
||||
Always returns 0 to make 'lock = edit_unlock_file (f)' possible */
|
||||
Always returns 0 */
|
||||
int
|
||||
edit_unlock_file (const char *fname)
|
||||
unlock_file (const char *fname)
|
||||
{
|
||||
char *lockfname, *lock;
|
||||
struct stat statbuf;
|
15
lib/lock.h
Normal file
15
lib/lock.h
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
/** \file
|
||||
* \brief Header: file locking
|
||||
* \author Adam Byrtek
|
||||
* \date 2003
|
||||
* Look at lock.c for more details
|
||||
*/
|
||||
|
||||
#ifndef MC_LOCK_H
|
||||
#define MC_LOCK_H
|
||||
|
||||
int lock_file (const char *fname);
|
||||
int unlock_file (const char *fname);
|
||||
|
||||
#endif /* MC_LOCK_H */
|
@ -180,6 +180,12 @@ const key_code_name_t key_name_conv_tab[] = {
|
||||
{ (int) '_', "underline", N_("Underline"), "_" },
|
||||
{ (int) '_', "understrike", N_("Understrike"), "_" },
|
||||
{ (int) '|', "pipe", N_("Pipe"), "|" },
|
||||
{ (int) '(', "lparenthese", N_("Left parenthese"), "(" },
|
||||
{ (int) ')', "rparenthese", N_("Right parenthese"), ")" },
|
||||
{ (int) '[', "lbracket", N_("Left bracket"), "[" },
|
||||
{ (int) ']', "rbracket", N_("Right bracket"), "]" },
|
||||
{ (int) '{', "lbrace", N_("Left brace"), "{" },
|
||||
{ (int) '}', "rbrace", N_("Right brace"), "}" },
|
||||
{ (int) '\n', "enter", N_("Enter"), "Enter" },
|
||||
{ (int) '\t', "tab", N_("Tab key"), "Tab" },
|
||||
{ (int) ' ', "space", N_("Space key"), "Space" },
|
||||
|
@ -238,6 +238,7 @@ CmdFilteredView = alt-exclamation
|
||||
CmdSelect = kpplus
|
||||
CmdUnselect = kpminus
|
||||
CmdReverseSelection = kpasterisk
|
||||
CmdDialogList = alt-prime
|
||||
ExtMap1 = ctrl-x
|
||||
|
||||
[main:xmap]
|
||||
@ -377,6 +378,10 @@ DialogNextItem = right; down
|
||||
DialogHelp = f1
|
||||
DialogSuspend = ctrl-z
|
||||
DialogRefresh = ctrl-l
|
||||
CmdDialogList = alt-prime
|
||||
CmdDialogNext = alt-rbrace
|
||||
CmdDialogPrev = alt-lbrace
|
||||
|
||||
|
||||
[diffviewer]
|
||||
DiffDisplaySymbols = alt-s; s
|
||||
|
@ -242,6 +242,7 @@ CmdFilteredView = alt-exclamation
|
||||
CmdSelect = kpplus
|
||||
CmdUnselect = kpminus
|
||||
CmdReverseSelection = kpasterisk
|
||||
CmdDialogList = alt-prime
|
||||
ExtMap1 = ctrl-x
|
||||
|
||||
[main:xmap]
|
||||
@ -381,6 +382,10 @@ DialogNextItem = right; down
|
||||
DialogHelp = f1
|
||||
DialogSuspend = ctrl-z
|
||||
DialogRefresh = ctrl-l
|
||||
CmdDialogList = alt-prime
|
||||
CmdDialogNext = alt-rbrace
|
||||
CmdDialogPrev = alt-lbrace
|
||||
|
||||
|
||||
[diffviewer]
|
||||
DiffDisplaySymbols = alt-s; s
|
||||
|
@ -41,22 +41,21 @@ if CHARSET
|
||||
SRC_USE_charset=$(SRC_charset)
|
||||
endif
|
||||
|
||||
|
||||
mc_LDADD = \
|
||||
../lib/libmc.la \
|
||||
viewer/libmcviewer.la \
|
||||
$(MCLIBS) $(DIFFLIB) $(EDITLIB) $(SLANGLIB) \
|
||||
$(GLIB_LIBS) $(PCRE_LIBS) \
|
||||
$(LIBICONV) $(INTLLIBS)
|
||||
$(DIFFLIB) $(EDITLIB) \
|
||||
../lib/libmc.la \
|
||||
$(MCLIBS) $(SLANGLIB) $(GLIB_LIBS) \
|
||||
$(PCRE_LIBS) $(LIBICONV) $(INTLLIBS)
|
||||
|
||||
if USE_SAMBA_FS
|
||||
# this is a hack for linking with own samba library in simple way
|
||||
mc_LDADD += ../lib/vfs/mc-vfs/samba/libsamba.a
|
||||
endif
|
||||
|
||||
|
||||
SRC_mc_widgets = \
|
||||
dialog.c dialog.h \
|
||||
dialog-switch.c dialog-switch.h \
|
||||
menu.c menu.h \
|
||||
screen.c panel.h \
|
||||
tree.c tree.h \
|
||||
|
16
src/achown.c
16
src/achown.c
@ -222,7 +222,7 @@ static void update_mode (Dlg_head * h)
|
||||
tty_setcolor (COLOR_NORMAL);
|
||||
dlg_move (h, BY + 2, 9);
|
||||
tty_printf ("%12o", get_mode ());
|
||||
send_message (h->current, WIDGET_FOCUS, 0);
|
||||
send_message ((Widget *) h->current->data, WIDGET_FOCUS, 0);
|
||||
}
|
||||
|
||||
static cb_ret_t
|
||||
@ -264,7 +264,7 @@ do_enter_key (Dlg_head * h, int f_pos)
|
||||
chl_end = 0;
|
||||
|
||||
chl_dlg =
|
||||
create_dlg (lyy, lxx, 13, 17, dialog_colors, chl_callback,
|
||||
create_dlg (TRUE, lyy, lxx, 13, 17, dialog_colors, chl_callback,
|
||||
"[Advanced Chown]", title, DLG_COMPACT | DLG_REVERSE);
|
||||
|
||||
/* get new listboxes */
|
||||
@ -405,7 +405,7 @@ static cb_ret_t
|
||||
advanced_chown_callback (Dlg_head *h, Widget *sender,
|
||||
dlg_msg_t msg, int parm, void *data)
|
||||
{
|
||||
int i = 0, f_pos = BUTTONS - h->current->dlg_id - single_set - 1;
|
||||
int i = 0, f_pos = BUTTONS - dlg_get_current_widget_id (h) - single_set - 1;
|
||||
|
||||
switch (msg) {
|
||||
case DLG_DRAW:
|
||||
@ -467,8 +467,8 @@ advanced_chown_callback (Dlg_head *h, Widget *sender,
|
||||
(x_toggle & (1 << parm)) ? '-' : '+';
|
||||
x_toggle ^= (1 << parm);
|
||||
update_mode (h);
|
||||
dlg_broadcast_msg (h, WIDGET_DRAW, 0);
|
||||
send_message (h->current, WIDGET_FOCUS, 0);
|
||||
dlg_broadcast_msg (h, WIDGET_DRAW, FALSE);
|
||||
send_message ((Widget *) h->current->data, WIDGET_FOCUS, 0);
|
||||
break;
|
||||
|
||||
case XCTRL ('x'):
|
||||
@ -484,8 +484,8 @@ advanced_chown_callback (Dlg_head *h, Widget *sender,
|
||||
(x_toggle & (1 << parm)) ? '-' : '+';
|
||||
x_toggle ^= (1 << parm);
|
||||
update_mode (h);
|
||||
dlg_broadcast_msg (h, WIDGET_DRAW, 0);
|
||||
send_message (h->current, WIDGET_FOCUS, 0);
|
||||
dlg_broadcast_msg (h, WIDGET_DRAW, FALSE);
|
||||
send_message ((Widget *) h->current->data, WIDGET_FOCUS, 0);
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
@ -581,7 +581,7 @@ init_chown_advanced (void)
|
||||
x_toggle = 070;
|
||||
|
||||
ch_dlg =
|
||||
create_dlg (0, 0, dlg_h, dlg_w, dialog_colors, advanced_chown_callback,
|
||||
create_dlg (TRUE, 0, 0, dlg_h, dlg_w, dialog_colors, advanced_chown_callback,
|
||||
"[Advanced Chown]", _("Chown advanced command"),
|
||||
DLG_CENTER | DLG_REVERSE);
|
||||
|
||||
|
@ -171,7 +171,7 @@ do_background (struct FileOpContext *ctx, char *info)
|
||||
from_parent_fd = back_comm[0];
|
||||
|
||||
we_are_background = 1;
|
||||
current_dlg = NULL;
|
||||
top_dlg = NULL;
|
||||
|
||||
/* Make stdin/stdout/stderr point somewhere */
|
||||
close (0);
|
||||
|
10
src/boxes.c
10
src/boxes.c
@ -202,7 +202,7 @@ display_init (int radio_sel, char *init_text, int _check_status, char **_status)
|
||||
|
||||
displays_status = _status;
|
||||
|
||||
dd = create_dlg (0, 0, dlg_height, dlg_width, dialog_colors,
|
||||
dd = create_dlg (TRUE, 0, 0, dlg_height, dlg_width, dialog_colors,
|
||||
display_callback, "[Listing Mode...]", display_title,
|
||||
DLG_CENTER | DLG_REVERSE);
|
||||
|
||||
@ -597,7 +597,7 @@ init_disp_bits_box (void)
|
||||
do_refresh ();
|
||||
|
||||
dbits_dlg =
|
||||
create_dlg (0, 0, DISPY, DISPX, dialog_colors, NULL,
|
||||
create_dlg (TRUE, 0, 0, DISPY, DISPX, dialog_colors, NULL,
|
||||
"[Display bits]", _("Display bits"), DLG_CENTER | DLG_REVERSE);
|
||||
|
||||
add_widget (dbits_dlg, label_new (3, 4, _("Input / display codepage:")));
|
||||
@ -691,7 +691,7 @@ tree_box (const char *current_dir)
|
||||
(void) current_dir;
|
||||
|
||||
/* Create the components */
|
||||
dlg = create_dlg (0, 0, LINES - 9, COLS - 20, dialog_colors,
|
||||
dlg = create_dlg (TRUE, 0, 0, LINES - 9, COLS - 20, dialog_colors,
|
||||
tree_callback, "[Directory Tree]",
|
||||
_("Directory tree"), DLG_CENTER | DLG_REVERSE);
|
||||
|
||||
@ -983,7 +983,7 @@ jobs_cmd (void)
|
||||
}
|
||||
#endif /* ENABLE_NLS */
|
||||
|
||||
jobs_dlg = create_dlg (0, 0, JOBS_Y, JOBS_X, dialog_colors, NULL,
|
||||
jobs_dlg = create_dlg (TRUE, 0, 0, JOBS_Y, JOBS_X, dialog_colors, NULL,
|
||||
"[Background jobs]", _("Background Jobs"), DLG_CENTER | DLG_REVERSE);
|
||||
|
||||
bg_list = listbox_new (2, 3, JOBS_Y - 9, JOBS_X - 7, FALSE, NULL);
|
||||
@ -1074,7 +1074,7 @@ vfs_smb_get_authinfo (const char *host, const char *share, const char *domain, c
|
||||
|
||||
title = g_strdup_printf (_("Password for \\\\%s\\%s"), host, share);
|
||||
|
||||
auth_dlg = create_dlg (0, 0, dialog_y, dialog_x, dialog_colors, NULL,
|
||||
auth_dlg = create_dlg (TRUE, 0, 0, dialog_y, dialog_x, dialog_colors, NULL,
|
||||
"[Smb Authinfo]", title, DLG_CENTER | DLG_REVERSE);
|
||||
|
||||
g_free (title);
|
||||
|
@ -162,7 +162,7 @@ static cb_ret_t
|
||||
chmod_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *data)
|
||||
{
|
||||
char buffer[BUF_TINY];
|
||||
int id = h->current->dlg_id - BUTTONS + single_set * 2 - 1;
|
||||
int id = dlg_get_current_widget_id (h) - BUTTONS + single_set * 2 - 1;
|
||||
|
||||
switch (msg)
|
||||
{
|
||||
@ -207,7 +207,7 @@ init_chmod (void)
|
||||
single_set = (current_panel->marked < 2) ? 2 : 0;
|
||||
|
||||
ch_dlg =
|
||||
create_dlg (0, 0, 22 - single_set, 70, dialog_colors,
|
||||
create_dlg (TRUE, 0, 0, 22 - single_set, 70, dialog_colors,
|
||||
chmod_callback, "[Chmod]", _("Chmod command"), DLG_CENTER | DLG_REVERSE);
|
||||
|
||||
for (i = 0; i < BUTTONS; i++)
|
||||
|
@ -154,7 +154,7 @@ init_chown (void)
|
||||
single_set = (current_panel->marked < 2) ? 3 : 0;
|
||||
|
||||
ch_dlg =
|
||||
create_dlg (0, 0, 18, 74, dialog_colors, chown_callback, "[Chown]",
|
||||
create_dlg (TRUE, 0, 0, 18, 74, dialog_colors, chown_callback, "[Chown]",
|
||||
_("Chown command"), DLG_CENTER | DLG_REVERSE);
|
||||
|
||||
for (i = 0; i < BUTTONS - single_set; i++)
|
||||
|
72
src/cmd.c
72
src/cmd.c
@ -67,6 +67,7 @@
|
||||
#include "subshell.h" /* use_subshell */
|
||||
#include "consaver/cons.saver.h" /* console_flag */
|
||||
#include "dialog.h" /* Widget */
|
||||
#include "dialog-switch.h"
|
||||
#include "wtools.h" /* message() */
|
||||
#include "main.h" /* change_panel() */
|
||||
#include "panel.h" /* current_panel */
|
||||
@ -121,7 +122,6 @@ view_file_at_line (const char *filename, int plain_view, int internal, int start
|
||||
static const char *viewer = NULL;
|
||||
int move_dir = 0;
|
||||
|
||||
|
||||
if (plain_view)
|
||||
{
|
||||
int changed_hex_mode = 0;
|
||||
@ -140,17 +140,29 @@ view_file_at_line (const char *filename, int plain_view, int internal, int start
|
||||
mcview_default_hex_mode = 0;
|
||||
mcview_default_nroff_flag = 0;
|
||||
mcview_default_magic_flag = 0;
|
||||
mcview_viewer (NULL, filename, &move_dir, start_line);
|
||||
|
||||
switch (mcview_viewer (NULL, filename, start_line))
|
||||
{
|
||||
case MCVIEW_WANT_NEXT:
|
||||
move_dir = 1;
|
||||
break;
|
||||
case MCVIEW_WANT_PREV:
|
||||
move_dir = -1;
|
||||
break;
|
||||
default:
|
||||
move_dir = 0;
|
||||
}
|
||||
|
||||
if (changed_hex_mode && !mcview_altered_hex_mode)
|
||||
mcview_default_hex_mode = 1;
|
||||
if (changed_nroff_flag && !mcview_altered_nroff_flag)
|
||||
mcview_default_nroff_flag = 1;
|
||||
if (changed_magic_flag && !mcview_altered_magic_flag)
|
||||
mcview_default_magic_flag = 1;
|
||||
repaint_screen ();
|
||||
return move_dir;
|
||||
|
||||
dialog_switch_process_pending ();
|
||||
}
|
||||
if (internal)
|
||||
else if (internal)
|
||||
{
|
||||
char view_entry[BUF_TINY];
|
||||
|
||||
@ -161,22 +173,35 @@ view_file_at_line (const char *filename, int plain_view, int internal, int start
|
||||
|
||||
if (regex_command (filename, view_entry, &move_dir) == 0)
|
||||
{
|
||||
mcview_viewer (NULL, filename, &move_dir, start_line);
|
||||
repaint_screen ();
|
||||
switch (mcview_viewer (NULL, filename, start_line))
|
||||
{
|
||||
case MCVIEW_WANT_NEXT:
|
||||
move_dir = 1;
|
||||
break;
|
||||
case MCVIEW_WANT_PREV:
|
||||
move_dir = -1;
|
||||
break;
|
||||
default:
|
||||
move_dir = 0;
|
||||
}
|
||||
|
||||
dialog_switch_process_pending ();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!viewer)
|
||||
if (viewer == NULL)
|
||||
{
|
||||
viewer = getenv ("VIEWER");
|
||||
if (!viewer)
|
||||
if (viewer == NULL)
|
||||
viewer = getenv ("PAGER");
|
||||
if (!viewer)
|
||||
if (viewer == NULL)
|
||||
viewer = "view";
|
||||
}
|
||||
|
||||
execute_with_vfs_arg (viewer, filename);
|
||||
}
|
||||
|
||||
return move_dir;
|
||||
}
|
||||
|
||||
@ -300,12 +325,13 @@ filtered_view_cmd (void)
|
||||
input_dialog (_("Filtered view"),
|
||||
_("Filter command and arguments:"),
|
||||
MC_HISTORY_FM_FILTERED_VIEW, selection (current_panel)->fname);
|
||||
if (!command)
|
||||
return;
|
||||
|
||||
mcview_viewer (command, "", NULL, 0);
|
||||
|
||||
g_free (command);
|
||||
if (command != NULL)
|
||||
{
|
||||
mcview_viewer (command, "", 0);
|
||||
g_free (command);
|
||||
dialog_switch_process_pending ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -329,11 +355,16 @@ do_edit_at_line (const char *what, int start_line)
|
||||
}
|
||||
execute_with_vfs_arg (editor, what);
|
||||
}
|
||||
|
||||
if (mc_run_mode == MC_RUN_FULL)
|
||||
{
|
||||
update_panels (UP_OPTIMIZE, UP_KEEPSEL);
|
||||
|
||||
#ifdef USE_INTERNAL_EDIT
|
||||
if (use_internal_edit)
|
||||
dialog_switch_process_pending ();
|
||||
else
|
||||
#endif /* USE_INTERNAL_EDIT */
|
||||
repaint_screen ();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -345,7 +376,7 @@ do_edit (const char *what)
|
||||
void
|
||||
edit_cmd (void)
|
||||
{
|
||||
if (regex_command (selection (current_panel)->fname, "Edit", 0) == 0)
|
||||
if (regex_command (selection (current_panel)->fname, "Edit", NULL) == 0)
|
||||
do_edit (selection (current_panel)->fname);
|
||||
}
|
||||
|
||||
@ -959,10 +990,9 @@ diff_view_cmd (void)
|
||||
dview_diff_cmd ();
|
||||
|
||||
if (mc_run_mode == MC_RUN_FULL)
|
||||
{
|
||||
update_panels (UP_OPTIMIZE, UP_KEEPSEL);
|
||||
repaint_screen ();
|
||||
}
|
||||
|
||||
dialog_switch_process_pending ();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -387,6 +387,9 @@
|
||||
#define CK_DiffViewCmd 7076
|
||||
#define CK_PanelOptionsBox 7077
|
||||
#define CK_RelativeSymlinkCmd 7078
|
||||
#define CK_DialogListCmd 7079
|
||||
#define CK_DialogNextCmd 7080
|
||||
#define CK_DialogPrevCmd 7081
|
||||
|
||||
/* panels */
|
||||
#define CK_PanelChdirOtherPanel 8001
|
||||
|
@ -1035,7 +1035,7 @@ query_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *da
|
||||
listbox_select_entry ((WListbox *) h->current, i);
|
||||
end = str_get_prev_char (&(input->buffer[end])) - input->buffer;
|
||||
handle_char (input, parm);
|
||||
send_message (h->current, WIDGET_DRAW, 0);
|
||||
send_message ((Widget *) h->current->data, WIDGET_DRAW, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1127,7 +1127,7 @@ query_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *da
|
||||
if (need_redraw == 2)
|
||||
{
|
||||
insert_text (input, last_text, low);
|
||||
send_message (h->current, WIDGET_DRAW, 0);
|
||||
send_message ((Widget *) h->current->data, WIDGET_DRAW, 0);
|
||||
}
|
||||
else if (need_redraw == 1)
|
||||
{
|
||||
@ -1236,7 +1236,7 @@ complete_engine (WInput * in, int what_to_do)
|
||||
min_end = end;
|
||||
query_height = h;
|
||||
query_width = w;
|
||||
query_dlg = create_dlg (y, x, query_height, query_width,
|
||||
query_dlg = create_dlg (TRUE, y, x, query_height, query_width,
|
||||
dialog_colors, query_callback,
|
||||
"[Completion]", NULL, DLG_COMPACT);
|
||||
query_list = listbox_new (1, 1, h - 2, w - 2, FALSE, NULL);
|
||||
|
262
src/dialog-switch.c
Normal file
262
src/dialog-switch.c
Normal file
@ -0,0 +1,262 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2010 Free Software Foundation
|
||||
*
|
||||
* This program 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 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Original idea and code: Oleg "Olegarch" Konovalov <olegarch@linuxinside.com>
|
||||
* Written by: 2007 Daniel Borca <dborca@yahoo.com>
|
||||
* 2010 Andrew Borodin <aborodin@vmail.ru>
|
||||
*/
|
||||
|
||||
/** \file dialog-switch.c
|
||||
* \brief Source: support of multiply editors and viewers.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/tty/tty.h" /* LINES, COLS */
|
||||
|
||||
#include "dialog.h"
|
||||
#include "widget.h"
|
||||
#include "layout.h" /* repaint_screen() */
|
||||
#include "main-widgets.h" /* midnight_dlg */
|
||||
#include "main.h" /* midnight_shutdown */
|
||||
#include "wtools.h" /* Listbox */
|
||||
#include "dialog-switch.h"
|
||||
|
||||
/*** global variables **************************************************/
|
||||
|
||||
/*** file scope macro definitions **************************************/
|
||||
|
||||
/*** file scope type declarations **************************************/
|
||||
|
||||
/*** file scope variables **********************************************/
|
||||
|
||||
/* List of dialogs: filemanagers, editors, viewers */
|
||||
static GList *mc_dialogs = NULL;
|
||||
/* Currently active dialog */
|
||||
static GList *mc_current = NULL;
|
||||
/* Is there any dialogs that we have to run after returning to the manager from another dialog */
|
||||
static gboolean dialog_switch_pending = FALSE;
|
||||
|
||||
/*** file scope functions **********************************************/
|
||||
|
||||
static unsigned char
|
||||
get_hotkey (int n)
|
||||
{
|
||||
return (n <= 9) ? '0' + n : 'a' + n - 10;
|
||||
}
|
||||
|
||||
static void
|
||||
dialog_switch_goto (GList *dlg)
|
||||
{
|
||||
if (mc_current != dlg)
|
||||
{
|
||||
Dlg_head *old = (Dlg_head *) mc_current->data;
|
||||
|
||||
mc_current = dlg;
|
||||
|
||||
if (old == midnight_dlg)
|
||||
{
|
||||
/* switch from panels to another dialog (editor, viewer, etc) */
|
||||
dialog_switch_pending = TRUE;
|
||||
dialog_switch_process_pending ();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* switch from editor, viewer, etc to another dialog */
|
||||
old->state = DLG_SUSPENDED;
|
||||
|
||||
if ((Dlg_head *) dlg->data != midnight_dlg)
|
||||
/* switch to another editor, viewer, etc */
|
||||
/* return to panels before run the required dialog */
|
||||
dialog_switch_pending = TRUE;
|
||||
else
|
||||
/* switch to panels */
|
||||
do_refresh ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*** public functions **************************************************/
|
||||
|
||||
void
|
||||
dialog_switch_add (Dlg_head *h)
|
||||
{
|
||||
GList *dlg;
|
||||
|
||||
dlg = g_list_find (mc_dialogs, h);
|
||||
|
||||
if (dlg != NULL)
|
||||
mc_current = dlg;
|
||||
else
|
||||
{
|
||||
mc_dialogs = g_list_prepend (mc_dialogs, h);
|
||||
mc_current = mc_dialogs;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
dialog_switch_remove (Dlg_head *h)
|
||||
{
|
||||
GList *this;
|
||||
|
||||
if ((Dlg_head *) mc_current->data == h)
|
||||
this = mc_current;
|
||||
else
|
||||
this = g_list_find (mc_dialogs, h);
|
||||
|
||||
if (this != NULL)
|
||||
{
|
||||
GList *next;
|
||||
|
||||
next = g_list_next (this);
|
||||
mc_dialogs = g_list_delete_link (mc_dialogs, this);
|
||||
mc_current = next == NULL ? mc_dialogs : next;
|
||||
}
|
||||
}
|
||||
|
||||
size_t
|
||||
dialog_switch_num (void)
|
||||
{
|
||||
return g_list_length (mc_dialogs);
|
||||
}
|
||||
|
||||
void
|
||||
dialog_switch_next (void)
|
||||
{
|
||||
GList *next;
|
||||
|
||||
if (midnight_shutdown || mc_current == NULL)
|
||||
return;
|
||||
|
||||
next = g_list_next (mc_current);
|
||||
if (next == NULL)
|
||||
next = mc_dialogs;
|
||||
|
||||
dialog_switch_goto (next);
|
||||
}
|
||||
|
||||
void
|
||||
dialog_switch_prev (void)
|
||||
{
|
||||
GList *prev;
|
||||
|
||||
if (midnight_shutdown || mc_current == NULL)
|
||||
return;
|
||||
|
||||
prev = g_list_previous (mc_current);
|
||||
if (prev == NULL)
|
||||
prev = g_list_last (mc_dialogs);
|
||||
|
||||
dialog_switch_goto (prev);
|
||||
}
|
||||
|
||||
void
|
||||
dialog_switch_list (void)
|
||||
{
|
||||
const size_t dlg_num = g_list_length (mc_dialogs);
|
||||
int lines, cols;
|
||||
Listbox *listbox;
|
||||
GList *h;
|
||||
int i = 0;
|
||||
int rv;
|
||||
|
||||
if (midnight_shutdown || mc_current == NULL)
|
||||
return;
|
||||
|
||||
lines = min ((size_t) (LINES * 2/3), dlg_num);
|
||||
cols = COLS * 2/3;
|
||||
|
||||
listbox = create_listbox_window (lines, cols, _("Screens"), "[Screen selector]");
|
||||
|
||||
for (h = mc_dialogs; h != NULL; h = g_list_next (h))
|
||||
{
|
||||
Dlg_head *dlg;
|
||||
char *title;
|
||||
|
||||
dlg = (Dlg_head *) h->data;
|
||||
|
||||
if ((dlg != NULL) && (dlg->get_title != NULL))
|
||||
title = dlg->get_title (dlg, listbox->list->widget.cols - 2); /* FIXME! */
|
||||
else
|
||||
title = g_strdup ("");
|
||||
|
||||
listbox_add_item (listbox->list, LISTBOX_APPEND_BEFORE, get_hotkey (i++), title, NULL);
|
||||
|
||||
g_free (title);
|
||||
}
|
||||
|
||||
listbox_select_entry (listbox->list, dlg_num - 1 - g_list_position (mc_dialogs, mc_current));
|
||||
rv = run_listbox (listbox);
|
||||
|
||||
if (rv >= 0)
|
||||
{
|
||||
h = g_list_nth (mc_dialogs, dlg_num - 1 - rv);
|
||||
dialog_switch_goto (h);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
dialog_switch_process_pending (void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
while (dialog_switch_pending)
|
||||
{
|
||||
Dlg_head *h = (Dlg_head *) mc_current->data;
|
||||
|
||||
dialog_switch_pending = FALSE;
|
||||
h->state = DLG_SUSPENDED;
|
||||
ret = run_dlg (h);
|
||||
if (h->state == DLG_CLOSED)
|
||||
{
|
||||
destroy_dlg (h);
|
||||
/* return to panels */
|
||||
if (mc_run_mode == MC_RUN_FULL)
|
||||
{
|
||||
mc_current = g_list_find (mc_dialogs, midnight_dlg);
|
||||
update_panels (UP_OPTIMIZE, UP_KEEPSEL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
repaint_screen ();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
dialog_switch_got_winch (void)
|
||||
{
|
||||
GList *dlg;
|
||||
|
||||
for (dlg = mc_dialogs; dlg != NULL; dlg = g_list_next (dlg))
|
||||
if (dlg != mc_current)
|
||||
((Dlg_head *) dlg->data)->winch_pending = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
dialog_switch_shutdown (void)
|
||||
{
|
||||
while (mc_dialogs != NULL)
|
||||
{
|
||||
Dlg_head *dlg = (Dlg_head *) mc_dialogs->data;
|
||||
|
||||
run_dlg (dlg);
|
||||
destroy_dlg (dlg);
|
||||
}
|
||||
}
|
21
src/dialog-switch.h
Normal file
21
src/dialog-switch.h
Normal file
@ -0,0 +1,21 @@
|
||||
|
||||
#ifndef MC_DIALOG_SWITCH_H
|
||||
#define MC_DIALOG_SWITCH_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
struct Dlg_head;
|
||||
|
||||
void dialog_switch_add (struct Dlg_head *h);
|
||||
void dialog_switch_remove (struct Dlg_head *h);
|
||||
size_t dialog_switch_num (void);
|
||||
|
||||
void dialog_switch_next (void);
|
||||
void dialog_switch_prev (void);
|
||||
void dialog_switch_list (void);
|
||||
|
||||
int dialog_switch_process_pending (void);
|
||||
void dialog_switch_got_winch (void);
|
||||
void dialog_switch_shutdown (void);
|
||||
|
||||
#endif /* MC_DIALOG_SWITCH_H */
|
634
src/dialog.c
634
src/dialog.c
File diff suppressed because it is too large
Load Diff
106
src/dialog.h
106
src/dialog.h
@ -1,5 +1,9 @@
|
||||
/* Dialog box features module for the Midnight Commander
|
||||
Copyright (C) 1994, 1995 Radek Doulik, Miguel de Icaza
|
||||
Copyright (C) 1994, 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
|
||||
2005, 2007, 2009, 2010 Free Software Foundation
|
||||
|
||||
Authors: 1994, 1995 Radek Doulik, Miguel de Icaza
|
||||
2009, 2010 Andrew Borodin
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -23,13 +27,17 @@
|
||||
#ifndef MC_DIALOG_H
|
||||
#define MC_DIALOG_H
|
||||
|
||||
#include <sys/types.h> /* size_t */
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/tty/mouse.h"
|
||||
#include "lib/util.h" /* Hook */
|
||||
|
||||
/* Common return values */
|
||||
#define B_EXIT 0
|
||||
#define B_CANCEL 1
|
||||
#define B_ENTER 2
|
||||
#define B_HELP 3
|
||||
#define B_EXIT 0
|
||||
#define B_CANCEL 1
|
||||
#define B_ENTER 2
|
||||
#define B_HELP 3
|
||||
#define B_USER 100
|
||||
|
||||
typedef struct Widget Widget;
|
||||
@ -83,16 +91,41 @@ typedef enum
|
||||
DLG_END = 12 /* Shut down dialog */
|
||||
} dlg_msg_t;
|
||||
|
||||
/* Flags for create_dlg */
|
||||
typedef enum
|
||||
{
|
||||
DLG_REVERSE = (1 << 5), /* Tab order is opposite to the add order */
|
||||
DLG_WANT_TAB = (1 << 4), /* Should the tab key be sent to the dialog? */
|
||||
DLG_WANT_IDLE = (1 << 3), /* Dialog wants idle events */
|
||||
DLG_COMPACT = (1 << 2), /* Suppress spaces around the frame */
|
||||
DLG_TRYUP = (1 << 1), /* Try to move two lines up the dialog */
|
||||
DLG_CENTER = (1 << 0), /* Center the dialog */
|
||||
DLG_NONE = 0 /* No options */
|
||||
} dlg_flags_t;
|
||||
|
||||
/* Dialog state */
|
||||
typedef enum
|
||||
{
|
||||
DLG_ACTIVE = 0, /* Dialog is visible and active */
|
||||
DLG_SUSPENDED = 1, /* Dialog is suspended */
|
||||
DLG_CLOSED = 2 /* Dialog is closed */
|
||||
} dlg_state_t;
|
||||
|
||||
/* Dialog callback */
|
||||
typedef struct Dlg_head Dlg_head;
|
||||
typedef cb_ret_t (*dlg_cb_fn) (struct Dlg_head * h, Widget * sender,
|
||||
typedef cb_ret_t (*dlg_cb_fn) (Dlg_head * h, Widget * sender,
|
||||
dlg_msg_t msg, int parm, void *data);
|
||||
|
||||
/* menu command execution */
|
||||
typedef cb_ret_t (*menu_exec_fn) (int command);
|
||||
|
||||
/* 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) (unsigned long command);
|
||||
|
||||
/* get dialog name to show in dialog list */
|
||||
typedef char *(*dlg_title_str) (const Dlg_head * h, size_t len);
|
||||
|
||||
/* Dialog color constants */
|
||||
#define DLG_COLOR_NUM 4
|
||||
#define DLG_NORMALC(h) ((h)->color[0])
|
||||
@ -103,11 +136,11 @@ typedef char *(*dlg_shortcut_str) (unsigned long command);
|
||||
struct Dlg_head
|
||||
{
|
||||
/* Set by the user */
|
||||
int flags; /* User flags */
|
||||
gboolean modal; /* type of dialog: modal or not */
|
||||
dlg_flags_t flags; /* User flags */
|
||||
const char *help_ctx; /* Name of the help entry */
|
||||
int *color; /* Color set. Unused in viewer and editor */
|
||||
/*notconst */ char *title;
|
||||
/* Title of the dialog */
|
||||
char *title; /* Title of the dialog */
|
||||
|
||||
/* Set and received by the user */
|
||||
int ret_value; /* Result of run_dlg() */
|
||||
@ -117,16 +150,20 @@ struct Dlg_head
|
||||
int cols, lines; /* Width and height of the window */
|
||||
|
||||
/* Internal flags */
|
||||
unsigned int running:1; /* The dialog is currently active */
|
||||
unsigned int fullscreen:1; /* Parents dialogs don't need refresh */
|
||||
dlg_state_t state;
|
||||
gboolean fullscreen; /* Parents dialogs don't need refresh */
|
||||
gboolean winch_pending; /* SIGWINCH signal has been got. Resize dialog after rise */
|
||||
int mouse_status; /* For the autorepeat status of the mouse */
|
||||
|
||||
/* Internal variables */
|
||||
int count; /* Number of widgets */
|
||||
struct Widget *current; /* Curently active widget */
|
||||
GList *widgets; /* widgets list */
|
||||
GList *current; /* Curently active widget */
|
||||
void *data; /* Data can be passed to dialog */
|
||||
|
||||
dlg_cb_fn callback;
|
||||
dlg_shortcut_str get_shortcut; /* Shortcut string */
|
||||
dlg_title_str get_title; /* useless for modal dialogs */
|
||||
|
||||
struct Dlg_head *parent; /* Parent dialog */
|
||||
};
|
||||
|
||||
@ -134,7 +171,6 @@ struct Dlg_head
|
||||
extern int dialog_colors[4];
|
||||
extern int alarm_colors[4];
|
||||
|
||||
|
||||
/* Widget callback */
|
||||
typedef cb_ret_t (*callback_fn) (Widget * widget, widget_msg_t msg, int parm);
|
||||
|
||||
@ -166,30 +202,19 @@ struct Widget
|
||||
int cols, lines;
|
||||
widget_options_t options;
|
||||
widget_pos_flags_t pos_flags; /* repositioning flags */
|
||||
int dlg_id; /* Number of the widget, starting with 0 */
|
||||
struct Widget *next;
|
||||
struct Widget *prev;
|
||||
unsigned int id; /* Number of the widget, starting with 0 */
|
||||
callback_fn callback;
|
||||
mouse_h mouse;
|
||||
struct Dlg_head *parent;
|
||||
struct Dlg_head *owner;
|
||||
};
|
||||
|
||||
/* draw box in window */
|
||||
void draw_box (Dlg_head * h, int y, int x, int ys, int xs, gboolean single);
|
||||
|
||||
/* Flags for create_dlg: */
|
||||
#define DLG_REVERSE (1 << 5) /* Tab order is opposite to the add order */
|
||||
#define DLG_WANT_TAB (1 << 4) /* Should the tab key be sent to the dialog? */
|
||||
#define DLG_WANT_IDLE (1 << 3) /* Dialog wants idle events */
|
||||
#define DLG_COMPACT (1 << 2) /* Suppress spaces around the frame */
|
||||
#define DLG_TRYUP (1 << 1) /* Try to move two lines up the dialog */
|
||||
#define DLG_CENTER (1 << 0) /* Center the dialog */
|
||||
#define DLG_NONE (000000) /* No options */
|
||||
|
||||
/* Creates a dialog head */
|
||||
Dlg_head *create_dlg (int y1, int x1, int lines, int cols,
|
||||
Dlg_head *create_dlg (gboolean modal, int y1, int x1, int lines, int cols,
|
||||
const int *colors, dlg_cb_fn callback,
|
||||
const char *help_ctx, const char *title, int flags);
|
||||
const char *help_ctx, const char *title, dlg_flags_t flags);
|
||||
|
||||
void dlg_set_default_colors (void);
|
||||
|
||||
@ -202,22 +227,23 @@ 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 */
|
||||
void init_dlg (Dlg_head * h);
|
||||
int run_dlg (Dlg_head * d);
|
||||
void destroy_dlg (Dlg_head * h);
|
||||
|
||||
void dlg_run_done (Dlg_head * h);
|
||||
void dlg_process_event (Dlg_head * h, int key, Gpm_Event * event);
|
||||
void init_dlg (Dlg_head * h);
|
||||
|
||||
char *dlg_get_title (const Dlg_head *h, size_t len);
|
||||
|
||||
/* To activate/deactivate the idle message generation */
|
||||
void set_idle_proc (Dlg_head * d, int enable);
|
||||
|
||||
void dlg_redraw (Dlg_head * h);
|
||||
void destroy_dlg (Dlg_head * h);
|
||||
|
||||
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, gboolean reverse);
|
||||
|
||||
void init_widget (Widget * w, int y, int x, int lines, int cols,
|
||||
callback_fn callback, mouse_h mouse_handler);
|
||||
@ -231,7 +257,7 @@ void common_dialog_repaint (struct Dlg_head *h);
|
||||
#define widget_move(w, _y, _x) tty_gotoyx (((Widget *)(w))->y + _y, ((Widget *)(w))->x + _x)
|
||||
#define dlg_move(h, _y, _x) tty_gotoyx (((Dlg_head *)(h))->y + _y, ((Dlg_head *)(h))->x + _x)
|
||||
|
||||
extern Dlg_head *current_dlg;
|
||||
extern GList *top_dlg;
|
||||
|
||||
/* A hook list for idle events */
|
||||
extern Hook *idle_hook;
|
||||
@ -239,7 +265,7 @@ extern Hook *idle_hook;
|
||||
static inline cb_ret_t
|
||||
send_message (Widget * w, widget_msg_t msg, int parm)
|
||||
{
|
||||
return (*(w->callback)) (w, msg, parm);
|
||||
return w->callback (w, msg, parm);
|
||||
}
|
||||
|
||||
/* Return 1 if the widget is active, 0 otherwise */
|
||||
@ -247,7 +273,13 @@ static inline int
|
||||
dlg_widget_active (void *w)
|
||||
{
|
||||
Widget *w1 = (Widget *) w;
|
||||
return (w1->parent->current == w1);
|
||||
return ((Widget *) w1->owner->current->data == w1);
|
||||
}
|
||||
|
||||
static inline unsigned int
|
||||
dlg_get_current_widget_id (const Dlg_head * h)
|
||||
{
|
||||
return ((Widget *) h->current->data)->id;
|
||||
}
|
||||
|
||||
void dlg_replace_widget (Widget * old, Widget * new);
|
||||
@ -262,7 +294,7 @@ void dlg_one_up (Dlg_head * h);
|
||||
void dlg_one_down (Dlg_head * h);
|
||||
int dlg_focus (Dlg_head * h);
|
||||
Widget *find_widget_type (const Dlg_head * h, callback_fn callback);
|
||||
void dlg_select_by_id (const Dlg_head * h, int id);
|
||||
void dlg_select_by_id (const Dlg_head * h, unsigned int id);
|
||||
|
||||
/* Redraw all dialogs */
|
||||
void do_refresh (void);
|
||||
|
@ -82,7 +82,7 @@ typedef struct WDiff
|
||||
|
||||
const char *args; /* Args passed to diff */
|
||||
const char *file[2]; /* filenames */
|
||||
const char *label[2];
|
||||
char *label[2];
|
||||
FBUF *f[2];
|
||||
const char *backup_sufix;
|
||||
gboolean merged;
|
||||
|
@ -51,7 +51,7 @@
|
||||
#include "src/history.h"
|
||||
#include "src/panel.h" /* Needed for current_panel and other_panel */
|
||||
#include "src/layout.h" /* Needed for get_current_index and get_other_panel */
|
||||
#include "src/main.h" /* mc_run_mode */
|
||||
#include "src/main.h" /* mc_run_mode, midnight_shutdown */
|
||||
#include "src/selcodepage.h"
|
||||
|
||||
#include "ydiff.h"
|
||||
@ -2312,8 +2312,8 @@ dview_init (WDiff * dview, const char *args, const char *file1, const char *file
|
||||
dview->args = args;
|
||||
dview->file[0] = file1;
|
||||
dview->file[1] = file2;
|
||||
dview->label[0] = label1;
|
||||
dview->label[1] = label2;
|
||||
dview->label[0] = g_strdup (label1);
|
||||
dview->label[1] = g_strdup (label2);
|
||||
dview->f[0] = f[0];
|
||||
dview->f[1] = f[1];
|
||||
dview->hdiff = NULL;
|
||||
@ -2450,6 +2450,9 @@ dview_fini (WDiff * dview)
|
||||
g_array_foreach (dview->a[1], DIFFLN, cc_free_elt);
|
||||
g_array_free (dview->a[1], TRUE);
|
||||
|
||||
g_free (dview->label[0]);
|
||||
g_free (dview->label[1]);
|
||||
|
||||
dview->a[1] = NULL;
|
||||
dview->a[0] = NULL;
|
||||
}
|
||||
@ -2748,6 +2751,8 @@ dview_redo (WDiff * dview)
|
||||
static void
|
||||
dview_edit (WDiff * dview, int ord)
|
||||
{
|
||||
Dlg_head *h;
|
||||
gboolean h_modal;
|
||||
int linenum, lineofs;
|
||||
|
||||
if (dview->dsrc == DATA_SRC_TMP)
|
||||
@ -2756,8 +2761,13 @@ dview_edit (WDiff * dview, int ord)
|
||||
return;
|
||||
}
|
||||
|
||||
h = ((Widget *) dview)->owner;
|
||||
h_modal = h->modal;
|
||||
|
||||
get_line_numbers (dview->a[ord], dview->skip_rows, &linenum, &lineofs);
|
||||
h->modal = TRUE; /* not allow edit file in several editors */
|
||||
do_edit_at_line (dview->file[ord], linenum);
|
||||
h->modal = h_modal;
|
||||
dview_redo (dview);
|
||||
dview_update (dview);
|
||||
}
|
||||
@ -2794,7 +2804,7 @@ dview_goto_cmd (WDiff * dview, int ord)
|
||||
}
|
||||
}
|
||||
dview->skip_rows = dview->search.last_accessed_num_line = i;
|
||||
snprintf (prev, sizeof (prev), "%d", newline);
|
||||
g_snprintf (prev, sizeof (prev), "%d", newline);
|
||||
}
|
||||
g_free (input);
|
||||
}
|
||||
@ -2805,7 +2815,7 @@ dview_goto_cmd (WDiff * dview, int ord)
|
||||
static void
|
||||
dview_labels (WDiff * dview)
|
||||
{
|
||||
Dlg_head *h = dview->widget.parent;
|
||||
Dlg_head *h = dview->widget.owner;
|
||||
WButtonBar *b = find_buttonbar (h);
|
||||
|
||||
buttonbar_set_label (b, 1, Q_ ("ButtonBar|Help"), diff_map, (Widget *) dview);
|
||||
@ -2930,23 +2940,35 @@ static gboolean
|
||||
dview_ok_to_exit (WDiff * dview)
|
||||
{
|
||||
gboolean res = TRUE;
|
||||
int act;
|
||||
|
||||
if (!dview->merged)
|
||||
return res;
|
||||
switch (query_dialog
|
||||
(_("Quit"), _("File was modified, Save with exit?"), D_NORMAL, 2, _("&Yes"),
|
||||
_("&No")))
|
||||
|
||||
act = query_dialog (_("Quit"), !midnight_shutdown ?
|
||||
_("File was modified. Save with exit?") :
|
||||
_("Midnight Commander is being shut down.\nSave modified file?"),
|
||||
D_NORMAL, 2, _("&Yes"), _("&No"));
|
||||
|
||||
/* Esc is No */
|
||||
if (midnight_shutdown || (act == -1))
|
||||
act = 1;
|
||||
|
||||
switch (act)
|
||||
{
|
||||
case -1:
|
||||
case -1: /* Esc */
|
||||
res = FALSE;
|
||||
break;
|
||||
case 0:
|
||||
res = TRUE;
|
||||
case 0: /* Yes */
|
||||
(void) dview_save (dview);
|
||||
break;
|
||||
case 1:
|
||||
res = TRUE;
|
||||
break;
|
||||
case 1: /* No */
|
||||
if (mc_util_restore_from_backup_if_possible (dview->file[0], "~~~"))
|
||||
res = mc_util_unlink_backup_if_possible (dview->file[0], "~~~");
|
||||
/* fall through */
|
||||
default:
|
||||
res = TRUE;
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
@ -3126,7 +3148,7 @@ static cb_ret_t
|
||||
dview_callback (Widget * w, widget_msg_t msg, int parm)
|
||||
{
|
||||
WDiff *dview = (WDiff *) w;
|
||||
Dlg_head *h = dview->widget.parent;
|
||||
Dlg_head *h = dview->widget.owner;
|
||||
cb_ret_t i;
|
||||
|
||||
switch (msg)
|
||||
@ -3205,7 +3227,10 @@ dview_dialog_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, v
|
||||
case DLG_VALIDATE:
|
||||
dview = (WDiff *) find_widget_type (h, dview_callback);
|
||||
if (!dview_ok_to_exit (dview))
|
||||
h->running = 1;
|
||||
h->state = DLG_ACTIVE;
|
||||
else
|
||||
h->state = DLG_CLOSED;
|
||||
|
||||
return MSG_HANDLED;
|
||||
|
||||
default:
|
||||
@ -3213,6 +3238,23 @@ dview_dialog_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, v
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static char *
|
||||
dview_get_title (const Dlg_head *h, size_t len)
|
||||
{
|
||||
const WDiff *dview = (const WDiff *) find_widget_type (h, dview_callback);
|
||||
const char *modified = dview->merged ? " (*) " : " ";
|
||||
size_t len1;
|
||||
|
||||
len -= (size_t) str_term_width1 (_("Diff:")) + strlen (modified);
|
||||
len1 = (len - 3)/2;
|
||||
|
||||
return g_strconcat (_("Diff:"), modified,
|
||||
str_term_trim (dview->label[0], len1), " | ",
|
||||
str_term_trim (dview->label[1], len - len1), (char *) NULL);
|
||||
}
|
||||
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
@ -3221,12 +3263,11 @@ diff_view (const char *file1, const char *file2, const char *label1, const char
|
||||
{
|
||||
int error;
|
||||
WDiff *dview;
|
||||
WButtonBar *bar;
|
||||
Dlg_head *dview_dlg;
|
||||
|
||||
/* Create dialog and widgets, put them on the dialog */
|
||||
dview_dlg =
|
||||
create_dlg (0, 0, LINES, COLS, NULL, dview_dialog_callback,
|
||||
create_dlg (FALSE, 0, 0, LINES, COLS, NULL, dview_dialog_callback,
|
||||
"[Diff Viewer]", NULL, DLG_WANT_TAB);
|
||||
|
||||
dview = g_new0 (WDiff, 1);
|
||||
@ -3236,10 +3277,10 @@ diff_view (const char *file1, const char *file2, const char *label1, const char
|
||||
|
||||
widget_want_cursor (dview->widget, 0);
|
||||
|
||||
bar = buttonbar_new (1);
|
||||
|
||||
add_widget (dview_dlg, dview);
|
||||
add_widget (dview_dlg, bar);
|
||||
add_widget (dview_dlg, buttonbar_new (TRUE));
|
||||
|
||||
dview_dlg->get_title = dview_get_title;
|
||||
|
||||
error = dview_init (dview, "-a", file1, file2, label1, label2, DATA_SRC_MEM); /* XXX binary diff? */
|
||||
|
||||
@ -3249,7 +3290,9 @@ diff_view (const char *file1, const char *file2, const char *label1, const char
|
||||
*/
|
||||
if (error == 0)
|
||||
run_dlg (dview_dlg);
|
||||
destroy_dlg (dview_dlg);
|
||||
|
||||
if ((error != 0) || (dview_dlg->state == DLG_CLOSED))
|
||||
destroy_dlg (dview_dlg);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ endif
|
||||
libedit_la_SOURCES = \
|
||||
bookmark.c edit.c editcmd.c editwidget.c editdraw.c editkeys.c \
|
||||
editmenu.c editoptions.c edit-impl.h edit.h edit-widget.h \
|
||||
editlock.c editlock.h syntax.c wordproc.c \
|
||||
syntax.c wordproc.c \
|
||||
choosesyntax.c etags.c etags.h editcmd_dialogs.c editcmd_dialogs.h
|
||||
|
||||
libedit_la_CFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir) $(PCRE_CFLAGS)
|
||||
|
@ -215,7 +215,7 @@ int edit_save_confirm_cmd (WEdit * edit);
|
||||
int edit_save_as_cmd (WEdit * edit);
|
||||
WEdit *edit_init (WEdit * edit, int lines, int columns, const char *filename, long line);
|
||||
int edit_clean (WEdit * edit);
|
||||
int edit_ok_to_exit (WEdit * edit);
|
||||
gboolean edit_ok_to_exit (WEdit * edit);
|
||||
int edit_renew (WEdit * edit);
|
||||
int edit_new_cmd (WEdit * edit);
|
||||
int edit_reload (WEdit * edit, const char *filename);
|
||||
@ -289,6 +289,9 @@ void edit_syntax_dialog (WEdit * edit, const char *current_syntax);
|
||||
void edit_mail_dialog (WEdit * edit);
|
||||
void format_paragraph (WEdit * edit, int force);
|
||||
|
||||
unsigned int edit_unlock_file (WEdit * edit);
|
||||
unsigned int edit_lock_file (WEdit * edit);
|
||||
|
||||
/* either command or char_for_insertion must be passed as -1 */
|
||||
void edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion);
|
||||
|
||||
@ -332,6 +335,4 @@ extern int option_edit_bottom_extreme;
|
||||
extern const char *option_whole_chars_search;
|
||||
extern int search_create_bookmark;
|
||||
|
||||
extern int column_highlighting;
|
||||
|
||||
#endif /* MC_EDIT_IMPL_H */
|
||||
|
@ -75,6 +75,7 @@ struct WEdit
|
||||
unsigned int screen_modified:1; /* File has been changed since the last screen draw */
|
||||
unsigned int delete_file:1; /* New file, needs to be deleted unless modified */
|
||||
unsigned int highlight:1; /* There is a selected block */
|
||||
unsigned int column_highlight:1;
|
||||
unsigned int utf8:1; /* It's multibyte file codeset */
|
||||
long prev_col; /* recent column position of the cursor - used when moving
|
||||
up or down past lines that are shorter than the current line */
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include "lib/skin.h" /* EDITOR_NORMAL_COLOR */
|
||||
#include "lib/vfs/mc-vfs/vfs.h"
|
||||
#include "lib/strutil.h" /* utf string functions */
|
||||
#include "lib/lock.h"
|
||||
|
||||
#include "src/widget.h"
|
||||
#include "src/cmd.h" /* view_other_cmd() */
|
||||
@ -61,7 +62,6 @@
|
||||
#include "src/keybind.h"
|
||||
|
||||
#include "edit-impl.h"
|
||||
#include "editlock.h"
|
||||
#include "edit-widget.h"
|
||||
|
||||
int option_word_wrap_line_length = DEFAULT_WRAP_LINE_LENGTH;
|
||||
@ -952,7 +952,7 @@ edit_clean (WEdit * edit)
|
||||
|
||||
/* a stale lock, remove it */
|
||||
if (edit->locked)
|
||||
edit->locked = edit_unlock_file (edit->filename);
|
||||
edit->locked = edit_unlock_file (edit);
|
||||
|
||||
/* save cursor position */
|
||||
if (option_save_position)
|
||||
@ -1273,7 +1273,7 @@ edit_modification (WEdit * edit)
|
||||
|
||||
/* raise lock when file modified */
|
||||
if (!edit->modified && !edit->delete_file)
|
||||
edit->locked = edit_lock_file (edit->filename);
|
||||
edit->locked = edit_lock_file (edit);
|
||||
edit->modified = 1;
|
||||
}
|
||||
|
||||
@ -2302,7 +2302,7 @@ edit_left_word_move (WEdit * edit, int s)
|
||||
for (;;)
|
||||
{
|
||||
int c1, c2;
|
||||
if (column_highlighting
|
||||
if (edit->column_highlight
|
||||
&& edit->mark1 != edit->mark2
|
||||
&& edit->over_col == 0 && edit->curs1 == edit_bol (edit, edit->curs1))
|
||||
break;
|
||||
@ -2334,7 +2334,7 @@ edit_right_word_move (WEdit * edit, int s)
|
||||
for (;;)
|
||||
{
|
||||
int c1, c2;
|
||||
if (column_highlighting
|
||||
if (edit->column_highlight
|
||||
&& edit->mark1 != edit->mark2
|
||||
&& edit->over_col == 0 && edit->curs1 == edit_eol (edit, edit->curs1))
|
||||
break;
|
||||
@ -2389,7 +2389,7 @@ static void
|
||||
edit_left_char_move_cmd (WEdit * edit)
|
||||
{
|
||||
int cw = 1;
|
||||
if (column_highlighting
|
||||
if (edit->column_highlight
|
||||
&& option_cursor_beyond_eol
|
||||
&& edit->mark1 != edit->mark2
|
||||
&& edit->over_col == 0 && edit->curs1 == edit_bol (edit, edit->curs1))
|
||||
@ -2519,10 +2519,10 @@ edit_do_undo (WEdit * edit)
|
||||
edit_delete (edit, 1);
|
||||
break;
|
||||
case COLUMN_ON:
|
||||
column_highlighting = 1;
|
||||
edit->column_highlight = 1;
|
||||
break;
|
||||
case COLUMN_OFF:
|
||||
column_highlighting = 0;
|
||||
edit->column_highlight = 0;
|
||||
break;
|
||||
}
|
||||
if (ac >= 256 && ac < 512)
|
||||
@ -2897,7 +2897,7 @@ edit_execute_key_command (WEdit * edit, unsigned long command, int char_for_inse
|
||||
edit_push_key_press (edit);
|
||||
|
||||
edit_execute_cmd (edit, command, char_for_insertion);
|
||||
if (column_highlighting)
|
||||
if (edit->column_highlight)
|
||||
edit->force |= REDRAW_PAGE;
|
||||
}
|
||||
|
||||
@ -2916,12 +2916,12 @@ edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion)
|
||||
|
||||
/* The next key press will unhighlight the found string, so update
|
||||
* the whole page */
|
||||
if (edit->found_len || column_highlighting)
|
||||
if (edit->found_len || edit->column_highlight)
|
||||
edit->force |= REDRAW_PAGE;
|
||||
|
||||
if (command / 100 == 6)
|
||||
{ /* a highlight command like shift-arrow */
|
||||
column_highlighting = 0;
|
||||
edit->column_highlight = 0;
|
||||
if (!edit->highlight || (edit->mark2 != -1 && edit->mark1 != edit->mark2))
|
||||
{
|
||||
edit_mark_cmd (edit, 1); /* clear */
|
||||
@ -3020,9 +3020,9 @@ edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion)
|
||||
{
|
||||
if (!option_persistent_selections)
|
||||
{
|
||||
if (column_highlighting)
|
||||
if (edit->column_highlight)
|
||||
edit_push_action (edit, COLUMN_ON);
|
||||
column_highlighting = 0;
|
||||
edit->column_highlight = 0;
|
||||
edit_mark_cmd (edit, 1);
|
||||
}
|
||||
}
|
||||
@ -3160,19 +3160,19 @@ edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion)
|
||||
break;
|
||||
|
||||
case CK_Page_Up_Alt_Highlight:
|
||||
column_highlighting = 1;
|
||||
edit->column_highlight = 1;
|
||||
case CK_Page_Up:
|
||||
case CK_Page_Up_Highlight:
|
||||
edit_move_up (edit, edit->num_widget_lines - 1, 1);
|
||||
break;
|
||||
case CK_Page_Down_Alt_Highlight:
|
||||
column_highlighting = 1;
|
||||
edit->column_highlight = 1;
|
||||
case CK_Page_Down:
|
||||
case CK_Page_Down_Highlight:
|
||||
edit_move_down (edit, edit->num_widget_lines - 1, 1);
|
||||
break;
|
||||
case CK_Left_Alt_Highlight:
|
||||
column_highlighting = 1;
|
||||
edit->column_highlight = 1;
|
||||
case CK_Left:
|
||||
case CK_Left_Highlight:
|
||||
if (option_fake_half_tabs)
|
||||
@ -3190,7 +3190,7 @@ edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion)
|
||||
edit_left_char_move_cmd (edit);
|
||||
break;
|
||||
case CK_Right_Alt_Highlight:
|
||||
column_highlighting = 1;
|
||||
edit->column_highlight = 1;
|
||||
case CK_Right:
|
||||
case CK_Right_Highlight:
|
||||
if (option_fake_half_tabs)
|
||||
@ -3223,37 +3223,37 @@ edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion)
|
||||
edit_right_word_move_cmd (edit);
|
||||
break;
|
||||
case CK_Up_Alt_Highlight:
|
||||
column_highlighting = 1;
|
||||
edit->column_highlight = 1;
|
||||
case CK_Up:
|
||||
case CK_Up_Highlight:
|
||||
edit_move_up (edit, 1, 0);
|
||||
break;
|
||||
case CK_Down_Alt_Highlight:
|
||||
column_highlighting = 1;
|
||||
edit->column_highlight = 1;
|
||||
case CK_Down:
|
||||
case CK_Down_Highlight:
|
||||
edit_move_down (edit, 1, 0);
|
||||
break;
|
||||
case CK_Paragraph_Up_Alt_Highlight:
|
||||
column_highlighting = 1;
|
||||
edit->column_highlight = 1;
|
||||
case CK_Paragraph_Up:
|
||||
case CK_Paragraph_Up_Highlight:
|
||||
edit_move_up_paragraph (edit, 0);
|
||||
break;
|
||||
case CK_Paragraph_Down_Alt_Highlight:
|
||||
column_highlighting = 1;
|
||||
edit->column_highlight = 1;
|
||||
case CK_Paragraph_Down:
|
||||
case CK_Paragraph_Down_Highlight:
|
||||
edit_move_down_paragraph (edit, 0);
|
||||
break;
|
||||
case CK_Scroll_Up_Alt_Highlight:
|
||||
column_highlighting = 1;
|
||||
edit->column_highlight = 1;
|
||||
case CK_Scroll_Up:
|
||||
case CK_Scroll_Up_Highlight:
|
||||
edit_move_up (edit, 1, 1);
|
||||
break;
|
||||
case CK_Scroll_Down_Alt_Highlight:
|
||||
column_highlighting = 1;
|
||||
edit->column_highlight = 1;
|
||||
case CK_Scroll_Down:
|
||||
case CK_Scroll_Down_Highlight:
|
||||
edit_move_down (edit, 1, 1);
|
||||
@ -3298,16 +3298,16 @@ edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion)
|
||||
case CK_Mark:
|
||||
if (edit->mark2 >= 0)
|
||||
{
|
||||
if (column_highlighting)
|
||||
if (edit->column_highlight)
|
||||
edit_push_action (edit, COLUMN_ON);
|
||||
column_highlighting = 0;
|
||||
edit->column_highlight = 0;
|
||||
}
|
||||
edit_mark_cmd (edit, 0);
|
||||
break;
|
||||
case CK_Column_Mark:
|
||||
if (!column_highlighting)
|
||||
if (!edit->column_highlight)
|
||||
edit_push_action (edit, COLUMN_OFF);
|
||||
column_highlighting = 1;
|
||||
edit->column_highlight = 1;
|
||||
edit_mark_cmd (edit, 0);
|
||||
break;
|
||||
case CK_Mark_All:
|
||||
@ -3315,9 +3315,9 @@ edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion)
|
||||
edit->force |= REDRAW_PAGE;
|
||||
break;
|
||||
case CK_Unmark:
|
||||
if (column_highlighting)
|
||||
if (edit->column_highlight)
|
||||
edit_push_action (edit, COLUMN_ON);
|
||||
column_highlighting = 0;
|
||||
edit->column_highlight = 0;
|
||||
edit_mark_cmd (edit, 1);
|
||||
break;
|
||||
|
||||
@ -3508,7 +3508,7 @@ edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion)
|
||||
edit_get_match_keyword_cmd (edit);
|
||||
break;
|
||||
case CK_Quit:
|
||||
dlg_stop (edit->widget.parent);
|
||||
dlg_stop (edit->widget.owner);
|
||||
break;
|
||||
case CK_New:
|
||||
edit_new_cmd (edit);
|
||||
@ -3769,3 +3769,29 @@ edit_move_down (WEdit * edit, unsigned long i, int do_scroll)
|
||||
{
|
||||
edit_move_updown (edit, i, do_scroll, FALSE);
|
||||
}
|
||||
|
||||
unsigned int
|
||||
edit_unlock_file (WEdit * edit)
|
||||
{
|
||||
char *fullpath;
|
||||
unsigned int ret;
|
||||
|
||||
fullpath = g_build_filename (edit->dir, edit->filename, (char *) NULL);
|
||||
ret = unlock_file (fullpath);
|
||||
g_free (fullpath);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
edit_lock_file (WEdit * edit)
|
||||
{
|
||||
char *fullpath;
|
||||
unsigned int ret;
|
||||
|
||||
fullpath = g_build_filename (edit->dir, edit->filename, (char *) NULL);
|
||||
ret = lock_file (fullpath);
|
||||
g_free (fullpath);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -51,12 +51,13 @@
|
||||
#include "lib/mcconfig.h"
|
||||
#include "lib/skin.h"
|
||||
#include "lib/strutil.h" /* utf string functions */
|
||||
#include "lib/lock.h"
|
||||
#include "lib/vfs/mc-vfs/vfs.h"
|
||||
|
||||
#include "src/history.h"
|
||||
#include "src/widget.h" /* listbox_new() */
|
||||
#include "src/layout.h" /* clr_scr() */
|
||||
#include "src/main.h" /* mc_home */
|
||||
#include "src/main.h" /* mc_home, midnight_shutdown */
|
||||
#include "src/setup.h" /* option_tab_spacing */
|
||||
#include "src/help.h" /* interactive_display() */
|
||||
#include "src/wtools.h" /* message() */
|
||||
@ -66,7 +67,6 @@
|
||||
#include "src/clipboard.h" /* copy_file_to_ext_clip, paste_to_file_from_ext_clip */
|
||||
|
||||
#include "src/editor/edit-impl.h"
|
||||
#include "src/editor/editlock.h"
|
||||
#include "src/editor/edit-widget.h"
|
||||
#include "src/editor/editcmd_dialogs.h"
|
||||
#include "src/editor/etags.h"
|
||||
@ -623,13 +623,13 @@ edit_save_as_cmd (WEdit * edit)
|
||||
{
|
||||
edit->stat1.st_mode |= S_IWUSR;
|
||||
}
|
||||
save_lock = edit_lock_file (exp);
|
||||
save_lock = lock_file (exp);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* filenames equal, check if already locked */
|
||||
if (!edit->locked && !edit->delete_file)
|
||||
save_lock = edit_lock_file (exp);
|
||||
save_lock = lock_file (exp);
|
||||
}
|
||||
|
||||
if (different_filename)
|
||||
@ -649,14 +649,14 @@ edit_save_as_cmd (WEdit * edit)
|
||||
if (different_filename)
|
||||
{
|
||||
if (save_lock)
|
||||
edit_unlock_file (exp);
|
||||
unlock_file (exp);
|
||||
if (edit->locked)
|
||||
edit->locked = edit_unlock_file (edit->filename);
|
||||
edit->locked = edit_unlock_file (edit);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (edit->locked || save_lock)
|
||||
edit->locked = edit_unlock_file (edit->filename);
|
||||
edit->locked = edit_unlock_file (edit);
|
||||
}
|
||||
|
||||
edit_set_filename (edit, exp);
|
||||
@ -675,7 +675,7 @@ edit_save_as_cmd (WEdit * edit)
|
||||
case -1:
|
||||
/* Failed, so maintain modify (not save) lock */
|
||||
if (save_lock)
|
||||
edit_unlock_file (exp);
|
||||
unlock_file (exp);
|
||||
g_free (exp);
|
||||
edit->force |= REDRAW_COMPLETELY;
|
||||
return 0;
|
||||
@ -932,12 +932,12 @@ edit_save_cmd (WEdit * edit)
|
||||
int res, save_lock = 0;
|
||||
|
||||
if (!edit->locked && !edit->delete_file)
|
||||
save_lock = edit_lock_file (edit->filename);
|
||||
save_lock = edit_lock_file (edit);
|
||||
res = edit_save_file (edit, edit->filename);
|
||||
|
||||
/* Maintain modify (not save) lock on failure */
|
||||
if ((res > 0 && edit->locked) || save_lock)
|
||||
edit->locked = edit_unlock_file (edit->filename);
|
||||
edit->locked = edit_unlock_file (edit);
|
||||
|
||||
/* On failure try 'save as', it does locking on its own */
|
||||
if (!res)
|
||||
@ -988,7 +988,13 @@ edit_load_file_from_filename (WEdit * edit, char *exp)
|
||||
}
|
||||
|
||||
if (prev_locked)
|
||||
edit_unlock_file (prev_filename);
|
||||
{
|
||||
char *fullpath;
|
||||
|
||||
fullpath = g_build_filename (edit->dir, prev_filename, (char *) NULL);
|
||||
unlock_file (fullpath);
|
||||
g_free (fullpath);
|
||||
}
|
||||
g_free (prev_filename);
|
||||
return 0;
|
||||
}
|
||||
@ -1150,7 +1156,7 @@ eval_marks (WEdit * edit, long *start_mark, long *end_mark)
|
||||
*end_mark = max (edit->mark1, edit->curs1);
|
||||
edit->column2 = edit->curs_col + edit->over_col;
|
||||
}
|
||||
if (column_highlighting
|
||||
if (edit->column_highlight
|
||||
&& (((edit->mark1 > edit->curs1) && (edit->column1 < edit->column2))
|
||||
|| ((edit->mark1 < edit->curs1) && (edit->column1 > edit->column2))))
|
||||
{
|
||||
@ -1321,7 +1327,7 @@ edit_block_copy_cmd (WEdit * edit)
|
||||
|
||||
edit_push_markers (edit);
|
||||
|
||||
if (column_highlighting)
|
||||
if (edit->column_highlight)
|
||||
{
|
||||
edit_insert_column_of_text (edit, copy_buf, size, abs (edit->column2 - edit->column1));
|
||||
}
|
||||
@ -1334,11 +1340,11 @@ edit_block_copy_cmd (WEdit * edit)
|
||||
g_free (copy_buf);
|
||||
edit_scroll_screen_over_cursor (edit);
|
||||
|
||||
if (column_highlighting)
|
||||
if (edit->column_highlight)
|
||||
{
|
||||
edit_set_markers (edit, 0, 0, 0, 0);
|
||||
edit_push_action (edit, COLUMN_ON);
|
||||
column_highlighting = 0;
|
||||
edit->column_highlight = 0;
|
||||
}
|
||||
else if (start_mark < current && end_mark > current)
|
||||
edit_set_markers (edit, start_mark, end_mark + end_mark - start_mark, 0, 0);
|
||||
@ -1359,7 +1365,7 @@ edit_block_move_cmd (WEdit * edit)
|
||||
|
||||
if (eval_marks (edit, &start_mark, &end_mark))
|
||||
return;
|
||||
if (column_highlighting)
|
||||
if (edit->column_highlight)
|
||||
{
|
||||
edit_update_curs_col (edit);
|
||||
x = edit->curs_col;
|
||||
@ -1381,7 +1387,7 @@ edit_block_move_cmd (WEdit * edit)
|
||||
|
||||
edit_push_markers (edit);
|
||||
current = edit->curs1;
|
||||
if (column_highlighting)
|
||||
if (edit->column_highlight)
|
||||
{
|
||||
long line;
|
||||
int size, c1, c2;
|
||||
@ -1415,7 +1421,7 @@ edit_block_move_cmd (WEdit * edit)
|
||||
}
|
||||
edit_set_markers (edit, 0, 0, 0, 0);
|
||||
edit_push_action (edit, COLUMN_ON);
|
||||
column_highlighting = 0;
|
||||
edit->column_highlight = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1489,7 +1495,7 @@ edit_block_delete (WEdit * edit)
|
||||
|
||||
if (eval_marks (edit, &start_mark, &end_mark))
|
||||
return 0;
|
||||
if (column_highlighting && edit->mark2 < 0)
|
||||
if (edit->column_highlight && edit->mark2 < 0)
|
||||
edit_mark_cmd (edit, 0);
|
||||
if ((end_mark - start_mark) > option_max_undo / 2)
|
||||
{
|
||||
@ -1523,7 +1529,7 @@ edit_block_delete (WEdit * edit)
|
||||
count = start_mark;
|
||||
if (start_mark < end_mark)
|
||||
{
|
||||
if (column_highlighting)
|
||||
if (edit->column_highlight)
|
||||
{
|
||||
if (edit->mark2 < 0)
|
||||
edit_mark_cmd (edit, 0);
|
||||
@ -2039,33 +2045,48 @@ edit_search_cmd (WEdit * edit, int again)
|
||||
* Check if it's OK to close the editor. If there are unsaved changes,
|
||||
* ask user. Return 1 if it's OK to exit, 0 to continue editing.
|
||||
*/
|
||||
int
|
||||
gboolean
|
||||
edit_ok_to_exit (WEdit * edit)
|
||||
{
|
||||
int act;
|
||||
|
||||
if (!edit->modified)
|
||||
return 1;
|
||||
return TRUE;
|
||||
|
||||
if (!edit_check_newline (edit))
|
||||
return 0;
|
||||
|
||||
switch (edit_query_dialog3
|
||||
(_("Quit"), _("File was modified, save with exit?"),
|
||||
_("&Cancel quit"), _("&Yes"), _("&No")))
|
||||
if (!midnight_shutdown)
|
||||
{
|
||||
case 1:
|
||||
edit_push_markers (edit);
|
||||
edit_set_markers (edit, 0, 0, 0, 0);
|
||||
if (!edit_save_cmd (edit))
|
||||
return 0;
|
||||
break;
|
||||
case 2:
|
||||
break;
|
||||
case 0:
|
||||
case -1:
|
||||
return 0;
|
||||
if (!edit_check_newline (edit))
|
||||
return FALSE;
|
||||
|
||||
act = edit_query_dialog3 (_("Quit"), _("File was modified. Save with exit?"),
|
||||
_("&Yes"), _("&No"), _("&Cancel quit"));
|
||||
}
|
||||
else
|
||||
{
|
||||
act = edit_query_dialog2 (_("Quit"), _("Midnight Commander is being shut down.\nSave modified file?"),
|
||||
_("&Yes"), _("&No"));
|
||||
|
||||
/* Esc is No */
|
||||
if (act == -1)
|
||||
act = 1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
switch (act)
|
||||
{
|
||||
case 0: /* Yes */
|
||||
edit_push_markers (edit);
|
||||
edit_set_markers (edit, 0, 0, 0, 0);
|
||||
if (!edit_save_cmd (edit) || midnight_shutdown)
|
||||
return (gboolean) midnight_shutdown;
|
||||
break;
|
||||
case 1: /* No */
|
||||
break;
|
||||
case 2: /* Cancel quit */
|
||||
case -1: /* Esc */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Return a null terminated length of text. Result must be g_free'd */
|
||||
@ -2074,7 +2095,7 @@ edit_get_block (WEdit * edit, long start, long finish, int *l)
|
||||
{
|
||||
unsigned char *s, *r;
|
||||
r = s = g_malloc0 (finish - start + 1);
|
||||
if (column_highlighting)
|
||||
if (edit->column_highlight)
|
||||
{
|
||||
*l = 0;
|
||||
/* copy from buffer, excluding chars that are out of the column 'margins' */
|
||||
@ -2114,7 +2135,7 @@ edit_save_block (WEdit * edit, const char *filename, long start, long finish)
|
||||
if (file == -1)
|
||||
return 0;
|
||||
|
||||
if (column_highlighting)
|
||||
if (edit->column_highlight)
|
||||
{
|
||||
int r;
|
||||
r = mc_write (file, VERTICAL_MAGIC, sizeof (VERTICAL_MAGIC));
|
||||
|
@ -320,7 +320,7 @@ editcmd_dialog_raw_key_query (const char *heading, const char *query, int cancel
|
||||
};
|
||||
|
||||
struct Dlg_head *raw_dlg =
|
||||
create_dlg (0, 0, 7, w, dialog_colors, editcmd_dialog_raw_key_query_cb,
|
||||
create_dlg (TRUE, 0, 0, 7, w, dialog_colors, editcmd_dialog_raw_key_query_cb,
|
||||
NULL, heading, DLG_CENTER | DLG_TRYUP | DLG_WANT_TAB);
|
||||
add_widget (raw_dlg, input_new (3 - cancel, w - 5, (int *) input_colors,
|
||||
2, "", 0, INPUT_COMPLETE_DEFAULT));
|
||||
@ -376,7 +376,7 @@ editcmd_dialog_completion_show (WEdit * edit, int max_len, int word_len,
|
||||
|
||||
/* create the dialog */
|
||||
compl_dlg =
|
||||
create_dlg (start_y, start_x, compl_dlg_h, compl_dlg_w,
|
||||
create_dlg (TRUE, start_y, start_x, compl_dlg_h, compl_dlg_w,
|
||||
dialog_colors, NULL, "[Completion]", NULL, DLG_COMPACT);
|
||||
|
||||
/* create the listbox */
|
||||
@ -464,7 +464,7 @@ editcmd_dialog_select_definition_show (WEdit * edit, char *match_expr, int max_l
|
||||
start_y -= (offset + 1);
|
||||
|
||||
/* create the dialog */
|
||||
def_dlg = create_dlg (start_y, start_x, def_dlg_h, def_dlg_w,
|
||||
def_dlg = create_dlg (TRUE, start_y, start_x, def_dlg_h, def_dlg_w,
|
||||
dialog_colors, NULL, "[Definitions]", match_expr, DLG_COMPACT);
|
||||
|
||||
/* create the listbox */
|
||||
|
@ -118,7 +118,7 @@ status_string (WEdit * edit, char *s, int w)
|
||||
if (simple_statusbar)
|
||||
g_snprintf (s, w,
|
||||
"%c%c%c%c %3ld %5ld/%ld %6ld/%ld %s %s",
|
||||
edit->mark1 != edit->mark2 ? (column_highlighting ? 'C' : 'B') : '-',
|
||||
edit->mark1 != edit->mark2 ? (edit->column_highlight ? 'C' : 'B') : '-',
|
||||
edit->modified ? 'M' : '-',
|
||||
edit->macro_i < 0 ? '-' : 'R',
|
||||
edit->overwrite == 0 ? '-' : 'O',
|
||||
@ -134,7 +134,7 @@ status_string (WEdit * edit, char *s, int w)
|
||||
else
|
||||
g_snprintf (s, w,
|
||||
"[%c%c%c%c] %2ld L:[%3ld+%2ld %3ld/%3ld] *(%-4ld/%4ldb) %s %s",
|
||||
edit->mark1 != edit->mark2 ? (column_highlighting ? 'C' : 'B') : '-',
|
||||
edit->mark1 != edit->mark2 ? (edit->column_highlight ? 'C' : 'B') : '-',
|
||||
edit->modified ? 'M' : '-',
|
||||
edit->macro_i < 0 ? '-' : 'R',
|
||||
edit->overwrite == 0 ? '-' : 'O',
|
||||
@ -470,7 +470,7 @@ edit_draw_this_line (WEdit * edit, long b, long row, long start_col, long end_co
|
||||
p->style |= MOD_CURSOR;
|
||||
if (q >= m1 && q < m2)
|
||||
{
|
||||
if (column_highlighting)
|
||||
if (edit->column_highlight)
|
||||
{
|
||||
int x;
|
||||
x = edit_move_forward3 (edit, b, 0, q);
|
||||
@ -823,7 +823,7 @@ edit_render (WEdit * edit, int page, int row_start, int col_start, int row_end,
|
||||
edit->force |= REDRAW_PAGE | REDRAW_IN_BOUNDS;
|
||||
|
||||
if (edit->force & REDRAW_COMPLETELY)
|
||||
buttonbar_redraw (find_buttonbar (edit->widget.parent));
|
||||
buttonbar_redraw (find_buttonbar (edit->widget.owner));
|
||||
render_edit_text (edit, row_start, col_start, row_end, col_end);
|
||||
/*
|
||||
* edit->force != 0 means a key was pending and the redraw
|
||||
|
@ -1,15 +0,0 @@
|
||||
|
||||
/** \file
|
||||
* \brief Header: editor file locking
|
||||
* \author Adam Byrtek
|
||||
* \date 2003
|
||||
* Look at editlock.c for more details
|
||||
*/
|
||||
|
||||
#ifndef MC_EDIT_LOCK_H
|
||||
#define MC_EDIT_LOCK_H
|
||||
|
||||
int edit_lock_file (const char *fname);
|
||||
int edit_unlock_file (const char *fname);
|
||||
|
||||
#endif
|
@ -225,7 +225,7 @@ edit_drop_menu_cmd (WEdit * e, int which)
|
||||
{
|
||||
WMenuBar *menubar;
|
||||
|
||||
menubar = find_menubar (e->widget.parent);
|
||||
menubar = find_menubar (e->widget.owner);
|
||||
|
||||
if (!menubar->is_active)
|
||||
{
|
||||
@ -234,7 +234,7 @@ edit_drop_menu_cmd (WEdit * e, int which)
|
||||
if (which >= 0)
|
||||
menubar->selected = which;
|
||||
|
||||
menubar->previous_widget = e->widget.parent->current->dlg_id;
|
||||
menubar->previous_widget = dlg_get_current_widget_id (e->widget.owner);
|
||||
dlg_select_widget (menubar);
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,7 @@
|
||||
|
||||
#include "lib/tty/tty.h" /* LINES, COLS */
|
||||
#include "lib/tty/key.h" /* is_idle() */
|
||||
#include "lib/strutil.h" /* str_term_trim() */
|
||||
|
||||
#include "edit-impl.h"
|
||||
#include "edit-widget.h"
|
||||
@ -53,8 +54,6 @@
|
||||
#include "src/cmddef.h"
|
||||
#include "src/keybind.h"
|
||||
|
||||
int column_highlighting = 0;
|
||||
|
||||
static cb_ret_t edit_callback (Widget *, widget_msg_t msg, int parm);
|
||||
|
||||
static char *
|
||||
@ -76,6 +75,20 @@ edit_get_shortcut (unsigned long command)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char *
|
||||
edit_get_title (const Dlg_head *h, size_t len)
|
||||
{
|
||||
const WEdit *edit = (const WEdit *) find_widget_type (h, edit_callback);
|
||||
const char *modified = edit->modified ? "(*) " : " ";
|
||||
const char *file_label;
|
||||
|
||||
len -= 4;
|
||||
|
||||
file_label = str_term_trim (edit->filename, len - str_term_width1 (_("Edit: ")));
|
||||
|
||||
return g_strconcat (_("Edit: "), modified, file_label, (char *) NULL);
|
||||
}
|
||||
|
||||
static int
|
||||
edit_event (Gpm_Event * event, void *data)
|
||||
{
|
||||
@ -90,7 +103,7 @@ edit_event (Gpm_Event * event, void *data)
|
||||
{
|
||||
WMenuBar *menubar;
|
||||
|
||||
menubar = find_menubar (edit->widget.parent);
|
||||
menubar = find_menubar (edit->widget.owner);
|
||||
|
||||
return menubar->widget.mouse (event, menubar);
|
||||
}
|
||||
@ -231,7 +244,9 @@ edit_dialog_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, vo
|
||||
|
||||
case DLG_VALIDATE:
|
||||
if (!edit_ok_to_exit (edit))
|
||||
h->running = 1;
|
||||
h->state = DLG_ACTIVE;
|
||||
else
|
||||
h->state = DLG_CLOSED;
|
||||
return MSG_HANDLED;
|
||||
|
||||
default:
|
||||
@ -261,10 +276,12 @@ edit_file (const char *_file, int line)
|
||||
|
||||
/* Create a new dialog and add it widgets to it */
|
||||
edit_dlg =
|
||||
create_dlg (0, 0, LINES, COLS, NULL, edit_dialog_callback,
|
||||
create_dlg (FALSE, 0, 0, LINES, COLS, NULL, edit_dialog_callback,
|
||||
"[Internal File Editor]", NULL, DLG_WANT_TAB);
|
||||
|
||||
edit_dlg->get_shortcut = edit_get_shortcut;
|
||||
edit_dlg->get_title = edit_get_title;
|
||||
|
||||
menubar = menubar_new (0, 0, COLS, NULL);
|
||||
add_widget (edit_dlg, menubar);
|
||||
edit_init_menu (menubar);
|
||||
@ -278,7 +295,8 @@ edit_file (const char *_file, int line)
|
||||
|
||||
run_dlg (edit_dlg);
|
||||
|
||||
destroy_dlg (edit_dlg);
|
||||
if (edit_dlg->state == DLG_CLOSED)
|
||||
destroy_dlg (edit_dlg);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
28
src/ext.c
28
src/ext.c
@ -52,6 +52,7 @@
|
||||
#include "charsets.h" /* get_codepage_index */
|
||||
#include "selcodepage.h" /* do_set_codepage */
|
||||
#endif
|
||||
#include "dialog-switch.h"
|
||||
#include "ext.h"
|
||||
|
||||
/* If set, we execute the file command to check the file type */
|
||||
@ -283,6 +284,8 @@ exec_extension (const char *filename, const char *lc_data, int *move_dir, int st
|
||||
|
||||
if (run_view)
|
||||
{
|
||||
mcview_ret_t ret;
|
||||
|
||||
mcview_altered_hex_mode = 0;
|
||||
mcview_altered_nroff_flag = 0;
|
||||
if (def_hex_mode != mcview_default_hex_mode)
|
||||
@ -295,18 +298,31 @@ exec_extension (const char *filename, const char *lc_data, int *move_dir, int st
|
||||
*/
|
||||
if (written_nonspace)
|
||||
{
|
||||
mcview_viewer (cmd, filename, move_dir, start_line);
|
||||
ret = mcview_viewer (cmd, filename, start_line);
|
||||
unlink (file_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
mcview_viewer (NULL, filename, move_dir, start_line);
|
||||
}
|
||||
ret = mcview_viewer (NULL, filename, start_line);
|
||||
|
||||
if (move_dir != NULL)
|
||||
switch (ret)
|
||||
{
|
||||
case MCVIEW_WANT_NEXT:
|
||||
*move_dir = 1;
|
||||
break;
|
||||
case MCVIEW_WANT_PREV:
|
||||
*move_dir = -1;
|
||||
break;
|
||||
default:
|
||||
*move_dir = 0;
|
||||
}
|
||||
|
||||
if (changed_hex_mode && !mcview_altered_hex_mode)
|
||||
mcview_default_hex_mode = def_hex_mode;
|
||||
if (changed_nroff_flag && !mcview_altered_nroff_flag)
|
||||
mcview_default_nroff_flag = def_nroff_flag;
|
||||
repaint_screen ();
|
||||
|
||||
dialog_switch_process_pending ();
|
||||
}
|
||||
else if (is_cd)
|
||||
{
|
||||
@ -331,11 +347,9 @@ exec_extension (const char *filename, const char *lc_data, int *move_dir, int st
|
||||
{
|
||||
handle_console (CONSOLE_SAVE);
|
||||
if (output_lines && keybar_visible)
|
||||
{
|
||||
show_console_contents (output_start_y,
|
||||
LINES - keybar_visible -
|
||||
output_lines - 1, LINES - keybar_visible - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1570,7 +1570,7 @@ compute_dir_size_create_ui (void)
|
||||
|
||||
ui = g_new (ComputeDirSizeUI, 1);
|
||||
|
||||
ui->dlg = create_dlg (0, 0, 8, COLS / 2, dialog_colors, NULL,
|
||||
ui->dlg = create_dlg (TRUE, 0, 0, 8, COLS / 2, dialog_colors, NULL,
|
||||
NULL, _("Directory scanning"), DLG_CENTER);
|
||||
ui->dirname = label_new (3, 3, "");
|
||||
add_widget (ui->dlg, ui->dirname);
|
||||
|
@ -298,7 +298,7 @@ file_op_context_create_ui_without_init (FileOpContext * ctx, gboolean with_eta,
|
||||
ui->showing_bps = with_eta;
|
||||
|
||||
ui->op_dlg =
|
||||
create_dlg (0, 0, WY - minus + 1 + total_reserve, dlg_width,
|
||||
create_dlg (TRUE, 0, 0, WY - minus + 1 + total_reserve, dlg_width,
|
||||
dialog_colors, NULL, NULL, op_names[ctx->operation], DLG_CENTER | DLG_REVERSE);
|
||||
|
||||
last_hint_line = the_hint->widget.y;
|
||||
@ -363,7 +363,6 @@ file_op_context_create_ui (FileOpContext * ctx, gboolean with_eta,
|
||||
/* We will manage the dialog without any help, that's why
|
||||
we have to call init_dlg */
|
||||
init_dlg (ui->op_dlg);
|
||||
ui->op_dlg->running = 1;
|
||||
}
|
||||
|
||||
void
|
||||
@ -778,7 +777,7 @@ overwrite_query_dialog (FileOpContext * ctx, enum OperationMode mode)
|
||||
|
||||
/* FIXME - missing help node */
|
||||
ui->replace_dlg =
|
||||
create_dlg (0, 0, rd_ylen, rd_xlen, alarm_colors, NULL, "[Replace]",
|
||||
create_dlg (TRUE, 0, 0, rd_ylen, rd_xlen, alarm_colors, NULL, "[Replace]",
|
||||
title, DLG_CENTER | DLG_REVERSE);
|
||||
|
||||
/* prompt -- centered */
|
||||
|
@ -325,7 +325,7 @@ find_parm_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void
|
||||
{
|
||||
message (D_ERROR, MSG_ERROR, _("Malformed regular expression"));
|
||||
dlg_select_widget (in_name);
|
||||
h->running = 1; /* Don't stop the dialog */
|
||||
h->state = DLG_ACTIVE; /* Don't stop the dialog */
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
|
||||
@ -335,7 +335,7 @@ find_parm_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void
|
||||
{
|
||||
message (D_ERROR, MSG_ERROR, _("Malformed regular expression"));
|
||||
dlg_select_widget (in_with);
|
||||
h->running = 1; /* Don't stop the dialog */
|
||||
h->state = DLG_ACTIVE; /* Don't stop the dialog */
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
|
||||
@ -425,7 +425,7 @@ find_parameters (char **start_dir, char **pattern, char **content)
|
||||
|
||||
find_par_start:
|
||||
find_dlg =
|
||||
create_dlg (0, 0, FIND_Y, FIND_X, dialog_colors,
|
||||
create_dlg (TRUE, 0, 0, FIND_Y, FIND_X, dialog_colors,
|
||||
find_parm_callback, "[Find File]", _("Find File"), DLG_CENTER | DLG_REVERSE);
|
||||
|
||||
add_widget (find_dlg,
|
||||
@ -1226,7 +1226,7 @@ setup_gui (void)
|
||||
}
|
||||
|
||||
find_dlg =
|
||||
create_dlg (0, 0, FIND2_Y, FIND2_X, dialog_colors, find_callback,
|
||||
create_dlg (TRUE, 0, 0, FIND2_Y, FIND2_X, dialog_colors, find_callback,
|
||||
"[Find File]", _("Find File"), DLG_CENTER | DLG_REVERSE);
|
||||
|
||||
add_widget (find_dlg,
|
||||
|
@ -570,7 +570,7 @@ help_event (Gpm_Event * event, void *vp)
|
||||
if (history_ptr < 0)
|
||||
history_ptr = HISTORY_SIZE - 1;
|
||||
|
||||
help_callback (w->parent, NULL, DLG_DRAW, 0, NULL);
|
||||
help_callback (w->owner, NULL, DLG_DRAW, 0, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -616,7 +616,7 @@ help_event (Gpm_Event * event, void *vp)
|
||||
move_forward (1);
|
||||
|
||||
/* Show the new node */
|
||||
help_callback (w->parent, NULL, DLG_DRAW, 0, NULL);
|
||||
help_callback (w->owner, NULL, DLG_DRAW, 0, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1027,7 +1027,7 @@ interactive_display (const char *filename, const char *node)
|
||||
help_lines = min (LINES - 4, max (2 * LINES / 3, 18));
|
||||
|
||||
whelp =
|
||||
create_dlg (0, 0, help_lines + 4, HELP_WINDOW_WIDTH + 4,
|
||||
create_dlg (TRUE, 0, 0, help_lines + 4, HELP_WINDOW_WIDTH + 4,
|
||||
help_colors, help_callback, "[Help]", _("Help"),
|
||||
DLG_TRYUP | DLG_CENTER | DLG_WANT_TAB);
|
||||
|
||||
|
@ -199,7 +199,7 @@ update_path_name (void)
|
||||
const char *text = "";
|
||||
char *p;
|
||||
WListbox *list = hotlist_state.moving ? l_movelist : l_hotlist;
|
||||
Dlg_head *dlg = list->widget.parent;
|
||||
Dlg_head *dlg = list->widget.owner;
|
||||
|
||||
if (list->count != 0)
|
||||
{
|
||||
@ -555,7 +555,7 @@ hotlist_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *
|
||||
static int
|
||||
l_call (WListbox * list)
|
||||
{
|
||||
Dlg_head *dlg = list->widget.parent;
|
||||
Dlg_head *dlg = list->widget.owner;
|
||||
|
||||
if (list->count != 0)
|
||||
{
|
||||
@ -699,7 +699,7 @@ init_hotlist (int list_type)
|
||||
}
|
||||
|
||||
hotlist_dlg =
|
||||
create_dlg (0, 0, LINES - 2, hotlist_cols, dialog_colors,
|
||||
create_dlg (TRUE, 0, 0, LINES - 2, hotlist_cols, dialog_colors,
|
||||
hotlist_callback, help_node, title, DLG_CENTER | DLG_REVERSE);
|
||||
|
||||
for (i = 0; i < BUTTONS; i++)
|
||||
@ -761,7 +761,7 @@ init_movelist (int list_type, struct hotlist *item)
|
||||
do_refresh ();
|
||||
|
||||
movelist_dlg =
|
||||
create_dlg (0, 0, LINES - 6, movelist_cols, dialog_colors,
|
||||
create_dlg (TRUE, 0, 0, LINES - 6, movelist_cols, dialog_colors,
|
||||
hotlist_callback, "[Hotlist]", hdr, DLG_CENTER | DLG_REVERSE);
|
||||
g_free (hdr);
|
||||
|
||||
|
@ -64,7 +64,7 @@ info_box (struct WInfo *info)
|
||||
tty_set_normal_attrs ();
|
||||
tty_setcolor (NORMAL_COLOR);
|
||||
widget_erase (&info->widget);
|
||||
draw_box (info->widget.parent, info->widget.y, info->widget.x,
|
||||
draw_box (info->widget.owner, info->widget.y, info->widget.x,
|
||||
info->widget.lines, info->widget.cols, FALSE);
|
||||
|
||||
widget_move (&info->widget, 0, (info->widget.cols - len - 2)/2);
|
||||
|
@ -405,6 +405,9 @@ static name_keymap_t command_names[] = {
|
||||
#ifdef USE_DIFF_VIEW
|
||||
{ "CmdDiffView", CK_DiffViewCmd},
|
||||
#endif
|
||||
{ "CmdDialogList", CK_DialogListCmd },
|
||||
{ "CmdDialogNext", CK_DialogNextCmd },
|
||||
{ "CmdDialogPrev", CK_DialogPrevCmd },
|
||||
|
||||
/* panel */
|
||||
{ "PanelChdirOtherPanel", CK_PanelChdirOtherPanel },
|
||||
@ -944,9 +947,14 @@ const global_keymap_t default_main_map[] = {
|
||||
{ ALT (','), CK_TogglePanelsSplit, "M-," },
|
||||
{ XCTRL ('x'), CK_StartExtMap1, "C-x" },
|
||||
/* Select/unselect group */
|
||||
{ KEY_KP_ADD, CK_SelectCmd, "+" },
|
||||
{ KEY_KP_SUBTRACT, CK_UnselectCmd, "-" },
|
||||
{ ALT ('*'), CK_ReverseSelectionCmd, "*" },
|
||||
{ KEY_KP_ADD, CK_SelectCmd, "+" },
|
||||
{ KEY_KP_SUBTRACT, CK_UnselectCmd, "-" },
|
||||
{ ALT ('*'), CK_ReverseSelectionCmd, "*" },
|
||||
|
||||
{ ALT ('`'), CK_DialogListCmd, "M-`"},
|
||||
{ ALT ('}'), CK_DialogNextCmd, "M-}"},
|
||||
{ ALT ('{'), CK_DialogPrevCmd, "M-{"},
|
||||
|
||||
{ 0, CK_Ignore_Key, "" }
|
||||
};
|
||||
|
||||
|
25
src/layout.c
25
src/layout.c
@ -55,6 +55,7 @@
|
||||
#include "lib/strutil.h"
|
||||
|
||||
#include "dialog.h"
|
||||
#include "dialog-switch.h" /* dialog_switch_got_winch() */
|
||||
#include "widget.h"
|
||||
#include "command.h"
|
||||
#include "main-widgets.h"
|
||||
@ -456,7 +457,7 @@ init_layout (void)
|
||||
}
|
||||
|
||||
layout_dlg =
|
||||
create_dlg (0, 0, 14, first_width * 2 + 9,
|
||||
create_dlg (TRUE, 0, 0, 14, first_width * 2 + 9,
|
||||
dialog_colors, layout_callback, "[Layout]",
|
||||
_("Layout"), DLG_CENTER | DLG_REVERSE);
|
||||
|
||||
@ -734,6 +735,15 @@ low_level_change_screen_size (void)
|
||||
#endif /* defined(HAVE_SLANG) || NCURSES_VERSION_MAJOR >= 4 */
|
||||
}
|
||||
|
||||
static void
|
||||
dlg_resize_cb (void *data, void *user_data)
|
||||
{
|
||||
Dlg_head *d = data;
|
||||
|
||||
(void) user_data;
|
||||
d->callback (d, NULL, DLG_RESIZE, 0, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
sigwinch_handler (int dummy)
|
||||
{
|
||||
@ -747,8 +757,6 @@ sigwinch_handler (int dummy)
|
||||
void
|
||||
change_screen_size (void)
|
||||
{
|
||||
Dlg_head *d;
|
||||
|
||||
winch_flag = 0;
|
||||
#if defined(HAVE_SLANG) || NCURSES_VERSION_MAJOR >= 4
|
||||
#if defined TIOCGWINSZ
|
||||
@ -771,13 +779,10 @@ change_screen_size (void)
|
||||
tty_nodelay (FALSE);
|
||||
#endif
|
||||
|
||||
/* Inform all suspending dialogs */
|
||||
dialog_switch_got_winch ();
|
||||
/* Inform all running dialogs */
|
||||
d = current_dlg;
|
||||
while (d != NULL)
|
||||
{
|
||||
(*d->callback) (d, NULL, DLG_RESIZE, 0, NULL);
|
||||
d = d->parent;
|
||||
}
|
||||
g_list_foreach (top_dlg, (GFunc) dlg_resize_cb, NULL);
|
||||
|
||||
/* Now, force the redraw */
|
||||
repaint_screen ();
|
||||
@ -817,7 +822,7 @@ print_vfs_message (const char *msg, ...)
|
||||
if (midnight_shutdown)
|
||||
return;
|
||||
|
||||
if (!message_visible || !the_hint || !the_hint->widget.parent)
|
||||
if (!message_visible || !the_hint || !the_hint->widget.owner)
|
||||
{
|
||||
int col, row;
|
||||
|
||||
|
@ -135,7 +135,7 @@ static int learn_move (int right)
|
||||
|
||||
totalcols = (learn_total - 1) / ROWS + 1;
|
||||
for (i = 0; i < learn_total; i++)
|
||||
if (learnkeys [i].button == learn_dlg->current) {
|
||||
if (learnkeys [i].button == (Widget *) learn_dlg->current->data) {
|
||||
if (right) {
|
||||
if (i < learn_total - ROWS)
|
||||
i += ROWS;
|
||||
@ -252,7 +252,7 @@ init_learn (void)
|
||||
do_refresh ();
|
||||
|
||||
learn_dlg =
|
||||
create_dlg (0, 0, 23, 78, dialog_colors, learn_callback,
|
||||
create_dlg (TRUE, 0, 0, 23, 78, dialog_colors, learn_callback,
|
||||
"[Learn keys]", learn_title, DLG_CENTER | DLG_REVERSE);
|
||||
|
||||
for (i = 0; i < BUTTONS; i++)
|
||||
|
@ -171,7 +171,7 @@ init_listmode (char *oldlistformat)
|
||||
do_refresh ();
|
||||
|
||||
listmode_dlg =
|
||||
create_dlg (0, 0, 22, 74, dialog_colors, NULL, listmode_section,
|
||||
create_dlg (TRUE, 0, 0, 22, 74, dialog_colors, NULL, listmode_section,
|
||||
"Listing format edit", DLG_CENTER | DLG_REVERSE);
|
||||
|
||||
add_widget (listmode_dlg,
|
||||
|
112
src/main.c
112
src/main.c
@ -90,6 +90,7 @@
|
||||
#include "wtools.h"
|
||||
#include "cmddef.h" /* CK_ cmd name const */
|
||||
#include "user.h" /* user_file_menu_cmd() */
|
||||
#include "dialog-switch.h"
|
||||
|
||||
#include "chmod.h"
|
||||
#include "chown.h"
|
||||
@ -324,31 +325,39 @@ change_panel (void)
|
||||
static void
|
||||
stop_dialogs (void)
|
||||
{
|
||||
midnight_dlg->running = 0;
|
||||
if (current_dlg)
|
||||
{
|
||||
current_dlg->running = 0;
|
||||
}
|
||||
midnight_dlg->state = DLG_CLOSED;
|
||||
|
||||
if ((top_dlg != NULL) && (top_dlg->data != NULL))
|
||||
((Dlg_head *) top_dlg->data)->state = DLG_CLOSED;
|
||||
}
|
||||
|
||||
static int
|
||||
quit_cmd_internal (int quiet)
|
||||
{
|
||||
int q = quit;
|
||||
size_t n = dialog_switch_num () - 1;
|
||||
|
||||
if (quiet || !confirm_exit)
|
||||
if (n != 0)
|
||||
{
|
||||
q = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (query_dialog
|
||||
(_("The Midnight Commander"),
|
||||
_("Do you really want to quit the Midnight Commander?"), D_NORMAL,
|
||||
2, _("&Yes"), _("&No")) == 0)
|
||||
char msg[BUF_MEDIUM];
|
||||
|
||||
g_snprintf (msg, sizeof (msg),
|
||||
ngettext ("You have %zd opened screen. Quit anyway?",
|
||||
"You have %zd opened screens. Quit anyway?", n),
|
||||
n);
|
||||
|
||||
if (query_dialog (_("The Midnight Commander"), msg,
|
||||
D_NORMAL, 2, _("&Yes"), _("&No")) == 0)
|
||||
q = 1;
|
||||
}
|
||||
if (q)
|
||||
|
||||
} else if (quiet || !confirm_exit)
|
||||
q = 1;
|
||||
else if (query_dialog (_("The Midnight Commander"),
|
||||
_("Do you really want to quit the Midnight Commander?"),
|
||||
D_NORMAL, 2, _("&Yes"), _("&No")) == 0)
|
||||
q = 1;
|
||||
|
||||
if (q != 0)
|
||||
{
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
if (!use_subshell)
|
||||
@ -357,7 +366,8 @@ quit_cmd_internal (int quiet)
|
||||
#endif
|
||||
stop_dialogs ();
|
||||
}
|
||||
if (q)
|
||||
|
||||
if (q != 0)
|
||||
quit |= 1;
|
||||
return quit;
|
||||
}
|
||||
@ -573,7 +583,7 @@ load_prompt (int fd, void *unused)
|
||||
return 0;
|
||||
|
||||
/* Don't actually change the prompt if it's invisible */
|
||||
if (current_dlg == midnight_dlg && command_prompt)
|
||||
if (((Dlg_head *) top_dlg->data == midnight_dlg) && command_prompt)
|
||||
{
|
||||
char *tmp_prompt;
|
||||
int prompt_len;
|
||||
@ -584,8 +594,8 @@ load_prompt (int fd, void *unused)
|
||||
/* Check for prompts too big */
|
||||
if (COLS > 8 && prompt_len > COLS - 8)
|
||||
{
|
||||
tmp_prompt[COLS - 8] = '\0';
|
||||
prompt_len = COLS - 8;
|
||||
tmp_prompt[prompt_len] = '\0';
|
||||
}
|
||||
mc_prompt = tmp_prompt;
|
||||
label_set_text (the_prompt, mc_prompt);
|
||||
@ -757,6 +767,7 @@ create_command_menu (void)
|
||||
#ifdef WITH_BACKGROUND
|
||||
entries = g_list_append (entries, menu_entry_create (_("&Background jobs"), CK_JobsCmd));
|
||||
#endif
|
||||
entries = g_list_append (entries, menu_entry_create (_("Screen lis&t"), CK_DialogListCmd));
|
||||
entries = g_list_append (entries, menu_separator_create ());
|
||||
#ifdef USE_EXT2FSLIB
|
||||
entries =
|
||||
@ -827,7 +838,7 @@ menu_last_selected_cmd (void)
|
||||
{
|
||||
the_menubar->is_active = TRUE;
|
||||
the_menubar->is_dropped = (drop_menus != 0);
|
||||
the_menubar->previous_widget = midnight_dlg->current->dlg_id;
|
||||
the_menubar->previous_widget = dlg_get_current_widget_id (midnight_dlg);
|
||||
dlg_select_widget (the_menubar);
|
||||
}
|
||||
|
||||
@ -867,6 +878,41 @@ midnight_get_shortcut (unsigned long command)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char *
|
||||
midnight_get_title (const Dlg_head *h, size_t len)
|
||||
{
|
||||
/* TODO: share code with update_xterm_title_path() */
|
||||
|
||||
const char *path;
|
||||
char host[BUF_TINY];
|
||||
char *p;
|
||||
struct passwd *pw = NULL;
|
||||
char *login = NULL;
|
||||
int res = 0;
|
||||
|
||||
(void) h;
|
||||
|
||||
path = strip_home_and_password (current_panel->cwd);
|
||||
res = gethostname (host, sizeof (host));
|
||||
if (res != 0)
|
||||
host[0] = '\0';
|
||||
else
|
||||
host [sizeof (host) - 1] = '\0';
|
||||
|
||||
pw = getpwuid (getuid ());
|
||||
if (pw != NULL)
|
||||
login = g_strdup_printf ("%s@%s", pw->pw_name, host);
|
||||
else
|
||||
login = g_strdup (host);
|
||||
|
||||
p = g_strdup_printf ("%s [%s]:%s", _("Panels:"), login, path);
|
||||
path = str_trunc (p, len - 4);
|
||||
g_free (login);
|
||||
g_free (p);
|
||||
|
||||
return g_strdup (path);
|
||||
}
|
||||
|
||||
void
|
||||
toggle_show_hidden (void)
|
||||
{
|
||||
@ -1180,6 +1226,9 @@ midnight_execute_cmd (Widget * sender, unsigned long command)
|
||||
case CK_DeleteCmd:
|
||||
delete_cmd ();
|
||||
break;
|
||||
case CK_DialogListCmd:
|
||||
dialog_switch_list ();
|
||||
break;
|
||||
#ifdef USE_DIFF_VIEW
|
||||
case CK_DiffViewCmd:
|
||||
diff_view_cmd ();
|
||||
@ -1535,15 +1584,6 @@ done_mc (void)
|
||||
vfs_add_current_stamps ();
|
||||
}
|
||||
|
||||
/* This should be called after destroy_dlg since panel widgets
|
||||
* save their state on the profiles
|
||||
*/
|
||||
static void
|
||||
done_mc_profile (void)
|
||||
{
|
||||
done_setup ();
|
||||
}
|
||||
|
||||
static cb_ret_t
|
||||
midnight_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *data)
|
||||
{
|
||||
@ -1739,12 +1779,15 @@ midnight_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void
|
||||
void
|
||||
update_xterm_title_path (void)
|
||||
{
|
||||
/* TODO: share code with midnight_get_title () */
|
||||
|
||||
const char *path;
|
||||
char host[BUF_TINY];
|
||||
char *p;
|
||||
struct passwd *pw = NULL;
|
||||
char *login = NULL;
|
||||
int res = 0;
|
||||
|
||||
if (xterm_flag && xterm_title)
|
||||
{
|
||||
path = strip_home_and_password (current_panel->cwd);
|
||||
@ -1785,7 +1828,7 @@ load_hint (int force)
|
||||
{
|
||||
char *hint;
|
||||
|
||||
if (!the_hint->widget.parent)
|
||||
if (!the_hint->widget.owner)
|
||||
return;
|
||||
|
||||
if (!message_visible)
|
||||
@ -1815,6 +1858,7 @@ static void
|
||||
create_panels_and_run_mc (void)
|
||||
{
|
||||
midnight_dlg->get_shortcut = midnight_get_shortcut;
|
||||
midnight_dlg->get_title = midnight_get_title;
|
||||
|
||||
create_panels ();
|
||||
|
||||
@ -1884,7 +1928,6 @@ mc_maybe_editor_or_viewer (void)
|
||||
break;
|
||||
}
|
||||
midnight_shutdown = 1;
|
||||
done_mc ();
|
||||
}
|
||||
|
||||
/* Run the main dialog that occupies the whole screen */
|
||||
@ -1899,7 +1942,7 @@ do_nc (void)
|
||||
|
||||
panel_init ();
|
||||
|
||||
midnight_dlg = create_dlg (0, 0, LINES, COLS, midnight_colors, midnight_callback,
|
||||
midnight_dlg = create_dlg (FALSE, 0, 0, LINES, COLS, midnight_colors, midnight_callback,
|
||||
"[main]", NULL, DLG_WANT_IDLE);
|
||||
|
||||
if (mc_run_mode == MC_RUN_FULL)
|
||||
@ -1924,13 +1967,14 @@ do_nc (void)
|
||||
if (mc_args__last_wd_file && vfs_current_is_local ())
|
||||
last_wd_string = g_strdup (current_panel->cwd);
|
||||
|
||||
done_mc ();
|
||||
}
|
||||
|
||||
dialog_switch_shutdown ();
|
||||
done_mc ();
|
||||
destroy_dlg (midnight_dlg);
|
||||
panel_deinit ();
|
||||
current_panel = 0;
|
||||
done_mc_profile ();
|
||||
done_setup ();
|
||||
}
|
||||
|
||||
/* POSIX version. The only version we support. */
|
||||
|
12
src/menu.c
12
src/menu.c
@ -201,7 +201,7 @@ menubar_draw_drop (WMenuBar * menubar)
|
||||
column = menubar->widget.cols - menu->max_entry_len - 5;
|
||||
|
||||
tty_setcolor (MENU_ENTRY_COLOR);
|
||||
draw_box (menubar->widget.parent,
|
||||
draw_box (menubar->widget.owner,
|
||||
menubar->widget.y + 1, menubar->widget.x + column,
|
||||
count + 2, menu->max_entry_len + 5, FALSE);
|
||||
|
||||
@ -300,7 +300,7 @@ menubar_finish (WMenuBar * menubar)
|
||||
menubar->widget.lines = 1;
|
||||
widget_want_hotkey (menubar->widget, 0);
|
||||
|
||||
dlg_select_by_id (menubar->widget.parent, menubar->previous_widget);
|
||||
dlg_select_by_id (menubar->widget.owner, menubar->previous_widget);
|
||||
do_refresh ();
|
||||
}
|
||||
|
||||
@ -322,8 +322,8 @@ menubar_execute (WMenuBar * menubar)
|
||||
{
|
||||
is_right = (menubar->selected != 0);
|
||||
menubar_finish (menubar);
|
||||
menubar->widget.parent->callback (menubar->widget.parent, &menubar->widget,
|
||||
DLG_ACTION, entry->command, NULL);
|
||||
menubar->widget.owner->callback (menubar->widget.owner, &menubar->widget,
|
||||
DLG_ACTION, entry->command, NULL);
|
||||
do_refresh ();
|
||||
}
|
||||
}
|
||||
@ -608,7 +608,7 @@ menubar_event (Gpm_Event * event, void *data)
|
||||
|
||||
if (!menubar->is_dropped)
|
||||
{
|
||||
menubar->previous_widget = menubar->widget.parent->current->dlg_id;
|
||||
menubar->previous_widget = dlg_get_current_widget_id (menubar->widget.owner);
|
||||
menubar->is_active = TRUE;
|
||||
menubar->is_dropped = TRUE;
|
||||
was_active = FALSE;
|
||||
@ -747,7 +747,7 @@ menubar_add_menu (WMenuBar * menubar, Menu * menu)
|
||||
{
|
||||
if (menu != NULL)
|
||||
{
|
||||
menu_arrange (menu, menubar->widget.parent->get_shortcut);
|
||||
menu_arrange (menu, menubar->widget.owner->get_shortcut);
|
||||
menubar->menu = g_list_append (menubar->menu, menu);
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,6 @@
|
||||
|
||||
#include "option.h"
|
||||
|
||||
|
||||
void
|
||||
configure_box (void)
|
||||
{
|
||||
|
@ -171,7 +171,7 @@ init_panelize (void)
|
||||
do_refresh ();
|
||||
|
||||
panelize_dlg =
|
||||
create_dlg (0, 0, 22, panelize_cols, dialog_colors,
|
||||
create_dlg (TRUE, 0, 0, 22, panelize_cols, dialog_colors,
|
||||
panelize_callback, "[External panelize]",
|
||||
_("External panelize"), DLG_CENTER | DLG_REVERSE);
|
||||
|
||||
|
@ -969,7 +969,7 @@ show_dir (WPanel * panel)
|
||||
{
|
||||
gchar *tmp;
|
||||
set_colors (panel);
|
||||
draw_box (panel->widget.parent,
|
||||
draw_box (panel->widget.owner,
|
||||
panel->widget.y, panel->widget.x, panel->widget.lines, panel->widget.cols, FALSE);
|
||||
|
||||
if (show_mini_info)
|
||||
@ -2509,7 +2509,7 @@ do_enter_on_file_entry (file_entry * fe)
|
||||
}
|
||||
|
||||
/* Try associated command */
|
||||
if (regex_command (fe->fname, "Open", 0) != 0)
|
||||
if (regex_command (fe->fname, "Open", NULL) != 0)
|
||||
return 1;
|
||||
|
||||
/* Check if the file is executable */
|
||||
@ -3081,7 +3081,7 @@ panel_callback (Widget * w, widget_msg_t msg, int parm)
|
||||
paint_dir (panel);
|
||||
panel->dirty = 0;
|
||||
|
||||
bb = find_buttonbar (panel->widget.parent);
|
||||
bb = find_buttonbar (panel->widget.owner);
|
||||
midnight_set_buttonbar (bb);
|
||||
buttonbar_redraw (bb);
|
||||
return MSG_HANDLED;
|
||||
|
@ -187,7 +187,7 @@ load_tree (WTree * tree)
|
||||
static void
|
||||
tree_show_mini_info (WTree * tree, int tree_lines, int tree_cols)
|
||||
{
|
||||
Dlg_head *h = tree->widget.parent;
|
||||
Dlg_head *h = tree->widget.owner;
|
||||
int line;
|
||||
|
||||
/* Show mini info */
|
||||
@ -223,7 +223,7 @@ tree_show_mini_info (WTree * tree, int tree_lines, int tree_cols)
|
||||
static void
|
||||
show_tree (WTree * tree)
|
||||
{
|
||||
Dlg_head *h = tree->widget.parent;
|
||||
Dlg_head *h = tree->widget.owner;
|
||||
tree_entry *current;
|
||||
int i, j, topsublevel;
|
||||
int x = 0, y = 0;
|
||||
@ -908,7 +908,7 @@ static void
|
||||
tree_toggle_navig (WTree * tree)
|
||||
{
|
||||
tree_navigation_flag = !tree_navigation_flag;
|
||||
buttonbar_set_label (find_buttonbar (tree->widget.parent), 4,
|
||||
buttonbar_set_label (find_buttonbar (tree->widget.owner), 4,
|
||||
tree_navigation_flag ? Q_ ("ButtonBar|Static")
|
||||
: Q_ ("ButtonBar|Dynamc"), tree_map, (Widget *) tree);
|
||||
}
|
||||
@ -1059,7 +1059,7 @@ static cb_ret_t
|
||||
tree_callback (Widget * w, widget_msg_t msg, int parm)
|
||||
{
|
||||
WTree *tree = (WTree *) w;
|
||||
Dlg_head *h = tree->widget.parent;
|
||||
Dlg_head *h = tree->widget.owner;
|
||||
WButtonBar *b = find_buttonbar (h);
|
||||
|
||||
switch (msg)
|
||||
|
@ -47,9 +47,8 @@
|
||||
#include "setup.h"
|
||||
#include "history.h"
|
||||
|
||||
|
||||
/* For the simple listbox manager */
|
||||
#include "dialog.h"
|
||||
#include "dialog-switch.h"
|
||||
#include "widget.h"
|
||||
#include "wtools.h"
|
||||
|
||||
@ -776,8 +775,8 @@ execute_menu_command (WEdit * edit_widget, const char *commands)
|
||||
chmod (file_name, S_IRWXU);
|
||||
if (run_view)
|
||||
{
|
||||
run_view = 0;
|
||||
mcview_viewer (file_name, NULL, &run_view, 0);
|
||||
mcview_viewer (file_name, NULL, 0);
|
||||
dialog_switch_process_pending ();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -53,6 +53,7 @@
|
||||
|
||||
#include "lib/tty/tty.h"
|
||||
#include "lib/tty/key.h"
|
||||
#include "lib/lock.h" /* lock_file() */
|
||||
|
||||
#include "src/dialog.h" /* cb_ret_t */
|
||||
#include "src/panel.h"
|
||||
@ -65,6 +66,7 @@
|
||||
#include "src/help.h"
|
||||
#include "src/keybind.h"
|
||||
#include "src/cmddef.h" /* CK_ cmd name const */
|
||||
#include "src/main.h" /* midnight_shutdown */
|
||||
|
||||
#include "internal.h"
|
||||
#include "mcviewer.h"
|
||||
@ -258,19 +260,19 @@ mcview_handle_editkey (mcview_t * view, int key)
|
||||
{
|
||||
struct hexedit_change_node *node;
|
||||
int byte_val;
|
||||
|
||||
/* Has there been a change at this position? */
|
||||
node = view->change_list;
|
||||
while (node && (node->offset != view->hex_cursor))
|
||||
while ((node != NULL) && (node->offset != view->hex_cursor))
|
||||
node = node->next;
|
||||
|
||||
if (!view->hexview_in_text)
|
||||
{
|
||||
/* Hex editing */
|
||||
unsigned int hexvalue = 0;
|
||||
|
||||
if (key >= '0' && key <= '9')
|
||||
{
|
||||
hexvalue = 0 + (key - '0');
|
||||
}
|
||||
else if (key >= 'A' && key <= 'F')
|
||||
hexvalue = 10 + (key - 'A');
|
||||
else if (key >= 'a' && key <= 'f')
|
||||
@ -278,19 +280,15 @@ mcview_handle_editkey (mcview_t * view, int key)
|
||||
else
|
||||
return MSG_NOT_HANDLED;
|
||||
|
||||
if (node)
|
||||
if (node != NULL)
|
||||
byte_val = node->value;
|
||||
else
|
||||
mcview_get_byte (view, view->hex_cursor, &byte_val);
|
||||
|
||||
if (view->hexedit_lownibble)
|
||||
{
|
||||
byte_val = (byte_val & 0xf0) | (hexvalue);
|
||||
}
|
||||
else
|
||||
{
|
||||
byte_val = (byte_val & 0x0f) | (hexvalue << 4);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -300,7 +298,12 @@ mcview_handle_editkey (mcview_t * view, int key)
|
||||
else
|
||||
return MSG_NOT_HANDLED;
|
||||
}
|
||||
if (!node)
|
||||
|
||||
if ((view->filename != NULL) && (view->filename[0] != '\0')
|
||||
&& (view->change_list == NULL))
|
||||
view->locked = mcview_lock_file (view);
|
||||
|
||||
if (node == NULL)
|
||||
{
|
||||
node = g_new (struct hexedit_change_node, 1);
|
||||
node->offset = view->hex_cursor;
|
||||
@ -308,11 +311,11 @@ mcview_handle_editkey (mcview_t * view, int key)
|
||||
mcview_enqueue_change (&view->change_list, node);
|
||||
}
|
||||
else
|
||||
{
|
||||
node->value = byte_val;
|
||||
}
|
||||
|
||||
view->dirty++;
|
||||
mcview_move_right (view, 1);
|
||||
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
|
||||
@ -437,8 +440,8 @@ mcview_execute_cmd (mcview_t * view, unsigned long command)
|
||||
view->move_dir = (command == CK_ViewNextFile) ? 1 : -1;
|
||||
/* fallthrough */
|
||||
case CK_ViewQuit:
|
||||
if (mcview_ok_to_quit (view))
|
||||
view->want_to_quit = TRUE;
|
||||
if (!mcview_is_in_panel (view))
|
||||
dlg_stop (view->widget.owner);
|
||||
break;
|
||||
default:
|
||||
res = MSG_NOT_HANDLED;
|
||||
@ -522,7 +525,6 @@ mcview_callback (Widget * w, widget_msg_t msg, int parm)
|
||||
{
|
||||
mcview_t *view = (mcview_t *) w;
|
||||
cb_ret_t i;
|
||||
Dlg_head *h = view->widget.parent;
|
||||
|
||||
mcview_compute_areas (view);
|
||||
mcview_update_bytes_per_line (view);
|
||||
@ -547,18 +549,12 @@ mcview_callback (Widget * w, widget_msg_t msg, int parm)
|
||||
|
||||
case WIDGET_KEY:
|
||||
i = mcview_handle_key (view, parm);
|
||||
if (view->want_to_quit && !mcview_is_in_panel (view))
|
||||
dlg_stop (h);
|
||||
else
|
||||
mcview_update (view);
|
||||
mcview_update (view);
|
||||
return i;
|
||||
|
||||
case WIDGET_COMMAND:
|
||||
i = mcview_execute_cmd (view, parm);
|
||||
if (view->want_to_quit && !mcview_is_in_panel (view))
|
||||
dlg_stop (h);
|
||||
else
|
||||
mcview_update (view);
|
||||
mcview_update (view);
|
||||
return i;
|
||||
|
||||
case WIDGET_FOCUS:
|
||||
@ -567,9 +563,14 @@ mcview_callback (Widget * w, widget_msg_t msg, int parm)
|
||||
return MSG_HANDLED;
|
||||
|
||||
case WIDGET_DESTROY:
|
||||
mcview_done (view);
|
||||
if (mcview_is_in_panel (view))
|
||||
{
|
||||
delete_hook (&select_file_hook, mcview_hook);
|
||||
|
||||
if (midnight_shutdown)
|
||||
mcview_ok_to_quit (view);
|
||||
}
|
||||
mcview_done (view);
|
||||
return MSG_HANDLED;
|
||||
|
||||
default:
|
||||
@ -582,7 +583,7 @@ mcview_callback (Widget * w, widget_msg_t msg, int parm)
|
||||
cb_ret_t
|
||||
mcview_dialog_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *data)
|
||||
{
|
||||
mcview_t *view = data;
|
||||
mcview_t *view;
|
||||
|
||||
switch (msg)
|
||||
{
|
||||
@ -592,8 +593,20 @@ mcview_dialog_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm,
|
||||
|
||||
case DLG_ACTION:
|
||||
/* command from buttonbar */
|
||||
view = (mcview_t *) data;
|
||||
return send_message ((Widget *) view, WIDGET_COMMAND, parm);
|
||||
|
||||
case DLG_VALIDATE:
|
||||
view = (mcview_t *) find_widget_type (h, mcview_callback);
|
||||
if (mcview_ok_to_quit (view))
|
||||
h->state = DLG_CLOSED;
|
||||
else
|
||||
{
|
||||
h->state = DLG_ACTIVE;
|
||||
mcview_update (view);
|
||||
}
|
||||
return MSG_HANDLED;
|
||||
|
||||
default:
|
||||
return default_dlg_callback (h, sender, msg, parm, data);
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ static enum ruler_type
|
||||
static void
|
||||
mcview_set_buttonbar (mcview_t * view)
|
||||
{
|
||||
Dlg_head *h = view->widget.parent;
|
||||
Dlg_head *h = view->widget.owner;
|
||||
WButtonBar *b = find_buttonbar (h);
|
||||
const global_keymap_t *keymap = view->hex_mode ? view->hex_map : view->plain_map;
|
||||
|
||||
@ -188,7 +188,7 @@ mcview_update (mcview_t * view)
|
||||
{
|
||||
view->dpy_bbar_dirty = FALSE;
|
||||
mcview_set_buttonbar (view);
|
||||
buttonbar_redraw (find_buttonbar (view->widget.parent));
|
||||
buttonbar_redraw (find_buttonbar (view->widget.owner));
|
||||
}
|
||||
|
||||
if (view->dirty > dirt_limit)
|
||||
|
@ -43,12 +43,12 @@
|
||||
#include "lib/global.h"
|
||||
#include "lib/tty/tty.h"
|
||||
#include "lib/skin.h"
|
||||
#include "lib/vfs/mc-vfs/vfs.h"
|
||||
|
||||
#include "src/main.h"
|
||||
#include "src/wtools.h"
|
||||
#include "src/charsets.h"
|
||||
|
||||
#include "lib/vfs/mc-vfs/vfs.h"
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
@ -69,8 +69,11 @@ typedef enum
|
||||
|
||||
static const char hex_char[] = "0123456789ABCDEF";
|
||||
|
||||
/*** file scope functions ************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
utf8_to_int (char * str, int * char_width, gboolean * result)
|
||||
utf8_to_int (char *str, int *char_width, gboolean * result)
|
||||
{
|
||||
int res = -1;
|
||||
gunichar ch;
|
||||
@ -112,10 +115,8 @@ utf8_to_int (char * str, int * char_width, gboolean * result)
|
||||
return ch;
|
||||
}
|
||||
|
||||
/*** file scope functions ************************************************************************/
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** public functions ****************************************************************************/
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
@ -375,6 +376,11 @@ mcview_hexedit_save_changes (mcview_t * view)
|
||||
g_free (curr);
|
||||
}
|
||||
|
||||
view->change_list = NULL;
|
||||
|
||||
if (view->locked)
|
||||
view->locked = mcview_unlock_file (view);
|
||||
|
||||
if (mc_close (fp) == -1)
|
||||
message (D_ERROR, _("Save file"),
|
||||
_("Error while closing the file:\n%s\n"
|
||||
@ -418,6 +424,10 @@ mcview_hexedit_free_change_list (mcview_t * view)
|
||||
g_free (curr);
|
||||
}
|
||||
view->change_list = NULL;
|
||||
|
||||
if (view->locked)
|
||||
view->locked = mcview_unlock_file (view);
|
||||
|
||||
view->dirty++;
|
||||
}
|
||||
|
||||
|
@ -95,6 +95,7 @@ typedef struct mcview_struct
|
||||
Widget widget;
|
||||
|
||||
char *filename; /* Name of the file */
|
||||
char *workdir; /* Name of the working directory */
|
||||
char *command; /* Command used to pipe data in */
|
||||
|
||||
enum view_ds datasource; /* Where the displayed data comes from */
|
||||
@ -131,10 +132,11 @@ typedef struct mcview_struct
|
||||
gboolean text_nroff_mode; /* Nroff-style highlighting */
|
||||
gboolean text_wrap_mode; /* Wrap text lines to fit them on the screen */
|
||||
gboolean magic_mode; /* Preprocess the file using external programs */
|
||||
gboolean hexedit_lownibble; /* Are we editing the last significant nibble? */
|
||||
gboolean locked; /* We hold lock on current file */
|
||||
|
||||
gboolean utf8; /* It's multibyte file codeset */
|
||||
|
||||
/* Additional editor state */
|
||||
gboolean hexedit_lownibble; /* Are we editing the last significant nibble? */
|
||||
coord_cache_t *coord_cache; /* Cache for mapping offsets to cursor positions */
|
||||
|
||||
/* Display information */
|
||||
@ -161,9 +163,6 @@ typedef struct mcview_struct
|
||||
off_t search_start; /* First character to start searching from */
|
||||
off_t search_end; /* Length of found string or 0 if none was found */
|
||||
|
||||
/* Pointer to the last search command */
|
||||
gboolean want_to_quit; /* Prepare for cleanup ... */
|
||||
|
||||
/* Markers */
|
||||
int marker; /* mark to use */
|
||||
off_t marks[10]; /* 10 marks: 0..9 */
|
||||
@ -293,6 +292,9 @@ void mcview_set_codeset (mcview_t * view);
|
||||
void mcview_show_error (mcview_t * view, const char *error);
|
||||
off_t mcview_bol (mcview_t * view, off_t current);
|
||||
off_t mcview_eol (mcview_t * view, off_t current);
|
||||
char *mcview_get_title (const Dlg_head * h, size_t len);
|
||||
gboolean mcview_lock_file (mcview_t * view);
|
||||
gboolean mcview_unlock_file (mcview_t * view);
|
||||
|
||||
/* move.c */
|
||||
void mcview_move_up (mcview_t *, off_t);
|
||||
|
@ -46,6 +46,7 @@
|
||||
|
||||
#include "src/wtools.h"
|
||||
#include "src/main.h"
|
||||
#include "lib/lock.h" /* unlock_file() */
|
||||
#include "src/charsets.h"
|
||||
#include "src/selcodepage.h"
|
||||
|
||||
@ -146,15 +147,27 @@ mcview_ok_to_quit (mcview_t * view)
|
||||
if (view->change_list == NULL)
|
||||
return TRUE;
|
||||
|
||||
r = query_dialog (_("Quit"),
|
||||
_("File was modified, Save with exit?"), D_NORMAL, 3,
|
||||
_("&Cancel quit"), _("&Yes"), _("&No"));
|
||||
if (!midnight_shutdown)
|
||||
{
|
||||
r = query_dialog (_("Quit"),
|
||||
_("File was modified. Save with exit?"), D_NORMAL, 3,
|
||||
_("&Yes"), _("&No"), _("&Cancel quit"));
|
||||
}
|
||||
else
|
||||
{
|
||||
r = query_dialog (_("Quit"),
|
||||
_("Midnight Commander is being shut down.\nSave modified file?"),
|
||||
D_NORMAL, 2, _("&Yes"), _("&No"));
|
||||
/* Esc is No */
|
||||
if (r == -1)
|
||||
r = 1;
|
||||
}
|
||||
|
||||
switch (r)
|
||||
{
|
||||
case 1:
|
||||
return mcview_hexedit_save_changes (view);
|
||||
case 2:
|
||||
case 0: /* Yes */
|
||||
return mcview_hexedit_save_changes (view) || midnight_shutdown;
|
||||
case 1: /* No */
|
||||
mcview_hexedit_free_change_list (view);
|
||||
return TRUE;
|
||||
default:
|
||||
@ -170,6 +183,7 @@ mcview_init (mcview_t * view)
|
||||
size_t i;
|
||||
|
||||
view->filename = NULL;
|
||||
view->workdir = NULL;
|
||||
view->command = NULL;
|
||||
view->search_nroff_seq = NULL;
|
||||
|
||||
@ -179,6 +193,7 @@ mcview_init (mcview_t * view)
|
||||
/* leave the other growbuf fields uninitialized */
|
||||
|
||||
view->hexedit_lownibble = FALSE;
|
||||
view->locked = FALSE;
|
||||
view->coord_cache = NULL;
|
||||
|
||||
view->dpy_start = 0;
|
||||
@ -198,8 +213,6 @@ mcview_init (mcview_t * view)
|
||||
view->search_start = 0;
|
||||
view->search_end = 0;
|
||||
|
||||
view->want_to_quit = FALSE;
|
||||
|
||||
view->marker = 0;
|
||||
for (i = 0; i < sizeof (view->marks) / sizeof (view->marks[0]); i++)
|
||||
view->marks[i] = 0;
|
||||
@ -235,6 +248,8 @@ mcview_done (mcview_t * view)
|
||||
|
||||
g_free (view->filename);
|
||||
view->filename = NULL;
|
||||
g_free (view->workdir);
|
||||
view->workdir = NULL;
|
||||
g_free (view->command);
|
||||
view->command = NULL;
|
||||
|
||||
@ -352,6 +367,8 @@ mcview_bol (mcview_t * view, off_t current)
|
||||
return current;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* returns index of last char on line + width EOL */
|
||||
/* mcview_eol of the current line == mcview_bol next line */
|
||||
off_t
|
||||
@ -382,3 +399,52 @@ mcview_eol (mcview_t * view, off_t current)
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
char *
|
||||
mcview_get_title (const Dlg_head * h, size_t len)
|
||||
{
|
||||
const mcview_t *view = (const mcview_t *) find_widget_type (h, mcview_callback);
|
||||
const char *modified = view->hexedit_mode && (view->change_list != NULL) ? "(*) " : " ";
|
||||
const char *file_label;
|
||||
|
||||
len -= 4;
|
||||
|
||||
file_label = view->filename != NULL ? view->filename :
|
||||
view->command != NULL ? view->command : "";
|
||||
file_label = str_term_trim (file_label, len - str_term_width1 (_("View: ")));
|
||||
|
||||
return g_strconcat (_("View: "), modified, file_label, (char *) NULL);
|
||||
}
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
gboolean
|
||||
mcview_lock_file (mcview_t * view)
|
||||
{
|
||||
char *fullpath;
|
||||
gboolean ret;
|
||||
|
||||
fullpath = g_build_filename (view->workdir, view->filename, (char *) NULL);
|
||||
ret = lock_file (fullpath);
|
||||
g_free (fullpath);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
gboolean
|
||||
mcview_unlock_file (mcview_t * view)
|
||||
{
|
||||
char *fullpath;
|
||||
gboolean ret;
|
||||
|
||||
fullpath = g_build_filename (view->workdir, view->filename, (char *) NULL);
|
||||
ret = unlock_file (fullpath);
|
||||
g_free (fullpath);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -212,6 +212,7 @@ mcview_new (int y, int x, int lines, int cols, gboolean is_panel)
|
||||
|
||||
view->hex_mode = FALSE;
|
||||
view->hexedit_mode = FALSE;
|
||||
view->locked = FALSE;
|
||||
view->hexview_in_text = FALSE;
|
||||
view->text_nroff_mode = FALSE;
|
||||
view->text_wrap_mode = FALSE;
|
||||
@ -237,15 +238,16 @@ mcview_new (int y, int x, int lines, int cols, gboolean is_panel)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* Real view only */
|
||||
int
|
||||
mcview_viewer (const char *command, const char *file, int *move_dir_p, int start_line)
|
||||
mcview_ret_t
|
||||
mcview_viewer (const char *command, const char *file, int start_line)
|
||||
{
|
||||
gboolean succeeded;
|
||||
mcview_t *lc_mcview;
|
||||
Dlg_head *view_dlg;
|
||||
mcview_ret_t ret;
|
||||
|
||||
/* Create dialog and widgets, put them on the dialog */
|
||||
view_dlg = create_dlg (0, 0, LINES, COLS, NULL, mcview_dialog_callback,
|
||||
view_dlg = create_dlg (FALSE, 0, 0, LINES, COLS, NULL, mcview_dialog_callback,
|
||||
"[Internal File Viewer]", NULL, DLG_WANT_TAB);
|
||||
|
||||
lc_mcview = mcview_new (0, 0, LINES - 1, COLS, FALSE);
|
||||
@ -253,21 +255,27 @@ mcview_viewer (const char *command, const char *file, int *move_dir_p, int start
|
||||
|
||||
add_widget (view_dlg, buttonbar_new (TRUE));
|
||||
|
||||
view_dlg->get_title = mcview_get_title;
|
||||
|
||||
succeeded = mcview_load (lc_mcview, command, file, start_line);
|
||||
|
||||
if (succeeded)
|
||||
{
|
||||
run_dlg (view_dlg);
|
||||
if (move_dir_p)
|
||||
*move_dir_p = lc_mcview->move_dir;
|
||||
|
||||
ret = lc_mcview->move_dir == 0 ? MCVIEW_EXIT_OK :
|
||||
lc_mcview->move_dir > 0 ? MCVIEW_WANT_NEXT : MCVIEW_WANT_PREV;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (move_dir_p)
|
||||
*move_dir_p = 0;
|
||||
view_dlg->state = DLG_CLOSED;
|
||||
ret = MCVIEW_EXIT_FAILURE;
|
||||
}
|
||||
destroy_dlg (view_dlg);
|
||||
|
||||
return succeeded;
|
||||
if (view_dlg->state == DLG_CLOSED)
|
||||
destroy_dlg (view_dlg);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* {{{ Miscellaneous functions }}} */
|
||||
@ -283,6 +291,36 @@ mcview_load (mcview_t * view, const char *command, const char *file, int start_l
|
||||
|
||||
view->filename = g_strdup (file);
|
||||
|
||||
if ((view->workdir == NULL) && (file != NULL))
|
||||
{
|
||||
if (!g_path_is_absolute (file))
|
||||
{
|
||||
#ifdef ENABLE_VFS
|
||||
view->workdir = g_strdup (vfs_get_current_dir ());
|
||||
#else /* ENABLE_VFS */
|
||||
view->workdir = g_get_current_dir ();
|
||||
#endif /* ENABLE_VFS */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* try extract path form filename */
|
||||
char *dirname;
|
||||
|
||||
dirname = g_path_get_dirname (file);
|
||||
if (strcmp (dirname, ".") != 0)
|
||||
view->workdir = dirname;
|
||||
else
|
||||
{
|
||||
g_free (dirname);
|
||||
#ifdef ENABLE_VFS
|
||||
view->workdir = g_strdup (vfs_get_current_dir ());
|
||||
#else /* ENABLE_VFS */
|
||||
view->workdir = g_get_current_dir ();
|
||||
#endif /* ENABLE_VFS */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!mcview_is_in_panel (view))
|
||||
view->dpy_text_column = 0;
|
||||
|
||||
@ -305,6 +343,8 @@ mcview_load (mcview_t * view, const char *command, const char *file, int start_l
|
||||
mcview_show_error (view, tmp);
|
||||
g_free (view->filename);
|
||||
view->filename = NULL;
|
||||
g_free (view->workdir);
|
||||
view->workdir = NULL;
|
||||
goto finish;
|
||||
}
|
||||
|
||||
@ -317,6 +357,8 @@ mcview_load (mcview_t * view, const char *command, const char *file, int start_l
|
||||
mcview_show_error (view, tmp);
|
||||
g_free (view->filename);
|
||||
view->filename = NULL;
|
||||
g_free (view->workdir);
|
||||
view->workdir = NULL;
|
||||
goto finish;
|
||||
}
|
||||
|
||||
@ -326,6 +368,8 @@ mcview_load (mcview_t * view, const char *command, const char *file, int start_l
|
||||
mcview_show_error (view, _("Cannot view: not a regular file"));
|
||||
g_free (view->filename);
|
||||
view->filename = NULL;
|
||||
g_free (view->workdir);
|
||||
view->workdir = NULL;
|
||||
goto finish;
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,14 @@
|
||||
|
||||
struct mcview_struct;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
MCVIEW_EXIT_FAILURE = -1,
|
||||
MCVIEW_EXIT_OK = 0,
|
||||
MCVIEW_WANT_NEXT,
|
||||
MCVIEW_WANT_PREV
|
||||
} mcview_ret_t;
|
||||
|
||||
/*** enums *************************************************************/
|
||||
|
||||
/*** structures declarations (and typedefs of structures)***************/
|
||||
@ -41,11 +49,9 @@ extern struct mcview_struct *mcview_new (int y, int x, int lines, int cols, gboo
|
||||
|
||||
|
||||
/* Shows {file} or the output of {command} in the internal viewer,
|
||||
* starting in line {start_line}. {move_dir_p} may be NULL or
|
||||
* point to a variable that will receive the direction in which the user
|
||||
* wants to move (-1 = previous file, 1 = next file, 0 = do nothing).
|
||||
* starting in line {start_line}.
|
||||
*/
|
||||
extern int mcview_viewer (const char *command, const char *file, int *move_dir_p, int start_line);
|
||||
extern mcview_ret_t mcview_viewer (const char *command, const char *file, int start_line);
|
||||
|
||||
extern gboolean mcview_load (struct mcview_struct *, const char *, const char *, int);
|
||||
|
||||
|
64
src/widget.c
64
src/widget.c
@ -66,7 +66,7 @@
|
||||
static void
|
||||
widget_selectcolor (Widget * w, gboolean focused, gboolean hotkey)
|
||||
{
|
||||
Dlg_head *h = w->parent;
|
||||
Dlg_head *h = w->owner;
|
||||
|
||||
tty_setcolor (hotkey
|
||||
? (focused
|
||||
@ -173,7 +173,7 @@ button_callback (Widget * w, widget_msg_t msg, int parm)
|
||||
WButton *b = (WButton *) w;
|
||||
int stop = 0;
|
||||
int off = 0;
|
||||
Dlg_head *h = b->widget.parent;
|
||||
Dlg_head *h = b->widget.owner;
|
||||
|
||||
switch (msg)
|
||||
{
|
||||
@ -184,7 +184,7 @@ button_callback (Widget * w, 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' && h->current == &b->widget)
|
||||
if (parm == '\n' && (Widget *) h->current->data == &b->widget)
|
||||
{
|
||||
button_callback (w, WIDGET_KEY, ' ');
|
||||
return MSG_HANDLED;
|
||||
@ -298,7 +298,7 @@ button_event (Gpm_Event * event, void *data)
|
||||
|
||||
if (event->type & (GPM_DOWN | GPM_UP))
|
||||
{
|
||||
Dlg_head *h = b->widget.parent;
|
||||
Dlg_head *h = b->widget.owner;
|
||||
dlg_select_widget (b);
|
||||
if (event->type & GPM_UP)
|
||||
{
|
||||
@ -366,7 +366,7 @@ button_set_text (WButton * b, const char *text)
|
||||
release_hotkey (b->text);
|
||||
b->text = parse_hotkey (text);
|
||||
b->widget.cols = button_get_len (b);
|
||||
dlg_redraw (b->widget.parent);
|
||||
dlg_redraw (b->widget.owner);
|
||||
}
|
||||
|
||||
|
||||
@ -378,7 +378,7 @@ radio_callback (Widget * w, widget_msg_t msg, int parm)
|
||||
{
|
||||
WRadio *r = (WRadio *) w;
|
||||
int i;
|
||||
Dlg_head *h = r->widget.parent;
|
||||
Dlg_head *h = r->widget.owner;
|
||||
|
||||
switch (msg)
|
||||
{
|
||||
@ -472,7 +472,7 @@ radio_event (Gpm_Event * event, void *data)
|
||||
|
||||
if (event->type & (GPM_DOWN | GPM_UP))
|
||||
{
|
||||
Dlg_head *h = r->widget.parent;
|
||||
Dlg_head *h = r->widget.owner;
|
||||
|
||||
r->pos = event->y - 1;
|
||||
dlg_select_widget (r);
|
||||
@ -524,7 +524,7 @@ static cb_ret_t
|
||||
check_callback (Widget * w, widget_msg_t msg, int parm)
|
||||
{
|
||||
WCheck *c = (WCheck *) w;
|
||||
Dlg_head *h = c->widget.parent;
|
||||
Dlg_head *h = c->widget.owner;
|
||||
|
||||
switch (msg)
|
||||
{
|
||||
@ -579,7 +579,7 @@ check_event (Gpm_Event * event, void *data)
|
||||
|
||||
if (event->type & (GPM_DOWN | GPM_UP))
|
||||
{
|
||||
Dlg_head *h = c->widget.parent;
|
||||
Dlg_head *h = c->widget.owner;
|
||||
|
||||
dlg_select_widget (c);
|
||||
if (event->type & GPM_UP)
|
||||
@ -726,7 +726,7 @@ static cb_ret_t
|
||||
label_callback (Widget * w, widget_msg_t msg, int parm)
|
||||
{
|
||||
WLabel *l = (WLabel *) w;
|
||||
Dlg_head *h = l->widget.parent;
|
||||
Dlg_head *h = l->widget.owner;
|
||||
|
||||
switch (msg)
|
||||
{
|
||||
@ -806,7 +806,7 @@ label_set_text (WLabel * label, const char *text)
|
||||
else
|
||||
label->text = NULL;
|
||||
|
||||
if (label->widget.parent)
|
||||
if (label->widget.owner)
|
||||
label_callback ((Widget *) label, WIDGET_DRAW, 0);
|
||||
|
||||
if (newcols < label->widget.cols)
|
||||
@ -836,7 +836,7 @@ static cb_ret_t
|
||||
hline_callback (Widget * w, widget_msg_t msg, int parm)
|
||||
{
|
||||
WHLine *l = (WHLine *) w;
|
||||
Dlg_head *h = l->widget.parent;
|
||||
Dlg_head *h = l->widget.owner;
|
||||
|
||||
switch (msg)
|
||||
{
|
||||
@ -844,15 +844,15 @@ hline_callback (Widget * w, widget_msg_t msg, int parm)
|
||||
case WIDGET_RESIZED:
|
||||
if (l->auto_adjust_cols)
|
||||
{
|
||||
if (((w->parent->flags & DLG_COMPACT) != 0))
|
||||
if (((w->owner->flags & DLG_COMPACT) != 0))
|
||||
{
|
||||
w->x = w->parent->x;
|
||||
w->cols = w->parent->cols;
|
||||
w->x = w->owner->x;
|
||||
w->cols = w->owner->cols;
|
||||
}
|
||||
else
|
||||
{
|
||||
w->x = w->parent->x + 1;
|
||||
w->cols = w->parent->cols - 2;
|
||||
w->x = w->owner->x + 1;
|
||||
w->cols = w->owner->cols - 2;
|
||||
}
|
||||
}
|
||||
|
||||
@ -906,7 +906,7 @@ static cb_ret_t
|
||||
gauge_callback (Widget * w, widget_msg_t msg, int parm)
|
||||
{
|
||||
WGauge *g = (WGauge *) w;
|
||||
Dlg_head *h = g->widget.parent;
|
||||
Dlg_head *h = g->widget.owner;
|
||||
|
||||
if (msg == WIDGET_INIT)
|
||||
return MSG_HANDLED;
|
||||
@ -1016,7 +1016,7 @@ gauge_new (int y, int x, int shown, int max, int current)
|
||||
#endif
|
||||
|
||||
#define should_show_history_button(in) \
|
||||
(in->history && in->field_width > HISTORY_BUTTON_WIDTH * 2 + 1 && in->widget.parent)
|
||||
(in->history && in->field_width > HISTORY_BUTTON_WIDTH * 2 + 1 && in->widget.owner)
|
||||
|
||||
static void
|
||||
draw_history_button (WInput * in)
|
||||
@ -1027,7 +1027,7 @@ draw_history_button (WInput * in)
|
||||
#ifdef LARGE_HISTORY_BUTTON
|
||||
{
|
||||
Dlg_head *h;
|
||||
h = in->widget.parent;
|
||||
h = in->widget.owner;
|
||||
tty_setcolor (NORMAL_COLOR);
|
||||
tty_print_string ("[ ]");
|
||||
/* Too distracting: tty_setcolor (MARKED_COLOR); */
|
||||
@ -1419,7 +1419,7 @@ show_hist (GList ** history, Widget * widget)
|
||||
hist_data.maxlen = maxlen;
|
||||
|
||||
query_dlg =
|
||||
create_dlg (0, 0, 4, 4, dialog_colors, dlg_hist_callback,
|
||||
create_dlg (TRUE, 0, 0, 4, 4, dialog_colors, dlg_hist_callback,
|
||||
"[History-query]", i18n_htitle (), DLG_COMPACT);
|
||||
query_dlg->data = &hist_data;
|
||||
|
||||
@ -1513,7 +1513,7 @@ input_destroy (WInput * in)
|
||||
|
||||
if (in->history != NULL)
|
||||
{
|
||||
if (!in->is_password && (((Widget *) in)->parent->ret_value != B_CANCEL))
|
||||
if (!in->is_password && (((Widget *) in)->owner->ret_value != B_CANCEL))
|
||||
history_put (in->history_name, in->history);
|
||||
|
||||
in->history = g_list_first (in->history);
|
||||
@ -2439,7 +2439,7 @@ listbox_drawscroll (WListbox * l)
|
||||
static void
|
||||
listbox_draw (WListbox * l, gboolean focused)
|
||||
{
|
||||
const Dlg_head *h = l->widget.parent;
|
||||
const Dlg_head *h = l->widget.owner;
|
||||
const int normalc = DLG_NORMALC (h);
|
||||
int selc = focused ? DLG_HOT_FOCUSC (h) : DLG_FOCUSC (h);
|
||||
|
||||
@ -2739,7 +2739,7 @@ static cb_ret_t
|
||||
listbox_callback (Widget * w, widget_msg_t msg, int parm)
|
||||
{
|
||||
WListbox *l = (WListbox *) w;
|
||||
Dlg_head *h = l->widget.parent;
|
||||
Dlg_head *h = l->widget.owner;
|
||||
cb_ret_t ret_code;
|
||||
|
||||
switch (msg)
|
||||
@ -2810,7 +2810,7 @@ listbox_event (Gpm_Event * event, void *data)
|
||||
WListbox *l = data;
|
||||
int i;
|
||||
|
||||
Dlg_head *h = l->widget.parent;
|
||||
Dlg_head *h = l->widget.owner;
|
||||
|
||||
/* Single click */
|
||||
if (event->type & GPM_DOWN)
|
||||
@ -3011,9 +3011,9 @@ buttonbar_call (WButtonBar * bb, int i)
|
||||
cb_ret_t ret = MSG_NOT_HANDLED;
|
||||
|
||||
if ((bb != NULL) && (bb->labels[i].command != CK_Ignore_Key))
|
||||
ret = bb->widget.parent->callback (bb->widget.parent,
|
||||
(Widget *) bb, DLG_ACTION,
|
||||
bb->labels[i].command, bb->labels[i].receiver);
|
||||
ret = bb->widget.owner->callback (bb->widget.owner,
|
||||
(Widget *) bb, DLG_ACTION,
|
||||
bb->labels[i].command, bb->labels[i].receiver);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -3234,12 +3234,12 @@ groupbox_callback (Widget * w, widget_msg_t msg, int parm)
|
||||
|
||||
case WIDGET_DRAW:
|
||||
tty_setcolor (COLOR_NORMAL);
|
||||
draw_box (g->widget.parent, g->widget.y - g->widget.parent->y,
|
||||
g->widget.x - g->widget.parent->x, g->widget.lines, g->widget.cols, TRUE);
|
||||
draw_box (g->widget.owner, g->widget.y - g->widget.owner->y,
|
||||
g->widget.x - g->widget.owner->x, g->widget.lines, g->widget.cols, TRUE);
|
||||
|
||||
tty_setcolor (COLOR_HOT_NORMAL);
|
||||
dlg_move (g->widget.parent, g->widget.y - g->widget.parent->y,
|
||||
g->widget.x - g->widget.parent->x + 1);
|
||||
dlg_move (g->widget.owner, g->widget.y - g->widget.owner->y,
|
||||
g->widget.x - g->widget.owner->x + 1);
|
||||
tty_print_string (g->title);
|
||||
return MSG_HANDLED;
|
||||
|
||||
|
@ -97,7 +97,7 @@ create_listbox_window_centered (int center_y, int center_x, int lines, int cols,
|
||||
listbox = g_new (Listbox, 1);
|
||||
|
||||
listbox->dlg =
|
||||
create_dlg (ypos, xpos, lines + space, cols + space,
|
||||
create_dlg (TRUE, ypos, xpos, lines + space, cols + space,
|
||||
listbox_colors, NULL,
|
||||
help, title, DLG_REVERSE | DLG_TRYUP);
|
||||
|
||||
@ -188,7 +188,7 @@ query_dialog (const char *header, const char *text, int flags, int count, ...)
|
||||
|
||||
/* prepare dialog */
|
||||
query_dlg =
|
||||
create_dlg (0, 0, lines, cols, query_colors, default_query_callback,
|
||||
create_dlg (TRUE, 0, 0, lines, cols, query_colors, default_query_callback,
|
||||
"[QueryBox]", header, DLG_NONE);
|
||||
|
||||
if (count > 0) {
|
||||
@ -377,11 +377,11 @@ quick_dialog_skip (QuickDialog *qd, int nskip)
|
||||
I18N (qd->title);
|
||||
|
||||
if ((qd->xpos == -1) || (qd->ypos == -1))
|
||||
dd = create_dlg (0, 0, qd->ylen, qd->xlen,
|
||||
dd = create_dlg (TRUE, 0, 0, qd->ylen, qd->xlen,
|
||||
dialog_colors, NULL, qd->help, qd->title,
|
||||
DLG_CENTER | DLG_TRYUP | DLG_REVERSE);
|
||||
else
|
||||
dd = create_dlg (qd->ypos, qd->xpos, qd->ylen, qd->xlen,
|
||||
dd = create_dlg (TRUE, qd->ypos, qd->xpos, qd->ylen, qd->xlen,
|
||||
dialog_colors, NULL, qd->help, qd->title,
|
||||
DLG_REVERSE);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user