1
1

Renamed keybind-related functions:

* lookup_action          -> keybind_lookup_action
* lookup_keymap_shortcut -> keybind_lookup_keymap_shortcut
* lookup_keymap_command  -> keybind_lookup_keymap_command

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
Этот коммит содержится в:
Slava Zanko 2010-11-18 10:43:23 +02:00 коммит произвёл Andrew Borodin
родитель 045debaa8a
Коммит 62f3c368c9
20 изменённых файлов: 377 добавлений и 30 удалений

151
lib/keybind/TODO.txt Обычный файл
Просмотреть файл

@ -0,0 +1,151 @@
/*
== кеймапы работают как: ==
клавиша - название
название вполне может быть Event!
mc.hotkeys
[Группа]
действие=клавиша
Это должно быть преобразовано в Event как:
mcevent_add_cb ("Группа.действие", ...)
при этом спец. группа 'mc.*'(и дочерние) должны быть проигнорированы в файле привязок
главная группа [core]
Инициализируется по дефолту. остальные группы описывают дополнительные назначения клавиш.
Спец.случаи. Панель и командная строка.
[panel]
- тут кейбиндинги панели.
[panel-commandline]
- тут кейбиндинги комстроки.
признак того, что необходимо включить или выключить "panel-commandline.*" - не пустая или пустая комстрока.
При непустой комстроке делаем просто mckeybind_push ("panel-commandline"), а как только строка очищается -
делаем mckeybind_pop();
То есть. выглядит всё так:
mckeybind_init("core"); // инициализируем некие базовые(одинаковые для всех) хоткеи.
switch (args)
{
case 'editor':
mckeybind_push("editor");
case 'viewer'
mckeybind_push("viewer");
default:
mckeybind_push("panel");
}
...
if (cmd_active())
mckeybind_push("panel-commandline");
...
if (cmd_inactive())
mckeybind_pop();
== КЕЙБИНДИНГИ ПО УМОЛЧАНИЮ ==
Должны содержать минимально необходимый для работы минимум. Если действие доступно через меню,
hardcoded-кейбиндинга быть не должно.
=== как инициальзировать ===
Ну... mckeybind_push("editor", g_hash_array *default(or NULL)) ?
== Хранение в памяти ==
храним в памяти в виде "хоткей" -> "event". Чтобы после чтения с клавы был быстрый доступ к mcevent_raise('action')
== Дубликаты хоткеев ==
наверное, надо предупреждать. что в конфиге есть конфликт...
[group]
action1 = ctrl-v
action2 = ctrl-v
в момент... гм. наверное. в момент mckeybind_push
ибо конфиг читаем целиком, но весь сразу не парсим...
== "Многоэтажные" хоткеи ==
=== Дубликаты: ===
action1 = ctrl-v
action2 = ctrl-v, w
Это ошибка. Выдать алерт.
=== Нормальная обработка ===
action1 = ctrl-v, q
action2 = ctrl-v, w
action3 = ctrl-v, e, 1
action4 = ctrl-v, e, 2
варианты использования.
mckeybind_push() должна добавить новые хоткеи к уже существующим (заменить существующие привязки клавиш).
mckeybind_pop() должна воостановить на предыдущее значение!
При этом должна быть возможность как бы временно "скрыть" существующие привязки. Для многоэтажных хоткеев.
//При парсинге видим многоэтажный хоткей и сразу создаём Event вида "mc.hotkey.<hotkey>".
// где <hotkey> - это <modificator>-<key> или просто <key>.
//mc_event_add_cb ("mc.hotkey.ctrl-v", );
нет. Надо предусмотреть временное замещение всех действующих хоткеев на только хоткеи "второго эшелона".
то есть, из примера надо после нажатия ctrl-v задейтвовать:
{
q -> action1
w -> action2
e -> !!!!!!! (ещё раз очищаем хоткеи и ждём 1 или 2 !!!)
}
После всего этого возвращаемся в обычный режим работы.
делаем это созданием псевдогруппы привязок вида "mc.hotkey.<hotkey>".
где <hotkey> - это <modificator>-<key> или просто <key>.
затем привязываем "ctrl-v" к спецкейбиндингу:
ctrl-v -> "mc.hotkey.processMulti('ctrl-v')"
привязывать к именам хоткеев нужно структуру вида:
{
char *action;
char *param; /* для всех равен NULL, для многоэтажных равен названию группы хоткеев второго эшелона*/
}
при вызове этого Event начинаем искать группу хоткеев "mc.hotkey.ctrl-v"
находим и заменяем активные привязки на таблицу:
{
q -> action1
w -> action2
e -> mc.hotkey.processMulti('ctrl-v,e')
}
NB: При парсинге файла привязок если встречаем мультихоткей, то ищем в списке групп - есть уже или нету.
"ctrl-v, e, 1" = ищем по группе "mc.hotkey.ctrl-v,e"
нашли - гуд. Добавляем.
== Порядок обработки файлов привязок ==
традиционно:
1) комстрока
2) переменная окружения
3) конфиг в дом.каталоге
4) конфиг в /etc/mc
*/
init
deinit
push
pop

0
lib/keybind/keybind.c Обычный файл
Просмотреть файл

0
lib/keybind/keybind.h Обычный файл
Просмотреть файл

2
lib/keybind/keymap.c Обычный файл
Просмотреть файл

@ -0,0 +1,2 @@

0
lib/keybind/keymap.h Обычный файл
Просмотреть файл

16
lib/keybind/readme.txt Обычный файл
Просмотреть файл

@ -0,0 +1,16 @@
= Обработка хоткеев =
Используются "карты хоткеев" (keybindings), которые содержат множество пар "хоткей - событие".
В зависимости от того, какой элемент интерфейса сейчас активирован. карты хоткеев могут дополняться или замещаться.
Должна быть возможность отмены текущей карты хоткеев и возврата на предыдущую карту. Это реализовывается стековой
моделью.
Замещение карты хоткеев происходит при:
* работе модального диалога. Хоткеи основного интерфейса должны быть "спрятаны";
*
Дополнение происходит при:
* назначении клавиш быстрого доступа к опциям. В таком случае основная карта хоткеев дополняется хоткеями из
меток (labels) диалогов;
*

178
lib/vfs/mc-vfs/fish/README.fish~HEAD Обычный файл
Просмотреть файл

@ -0,0 +1,178 @@
FIles transferred over SHell protocol (V 0.0.2)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This protocol was designed for transferring files over a remote shell
connection (rsh and compatibles). It can be as well used for transfers over
rsh, and there may be other uses.
Client sends requests of following form:
#FISH_COMMAND
equivalent shell commands,
which may be multiline
Only fish commands are defined here, shell equivalents are for your
information only and will probably vary from implementation to
implementation. Fish commands always have priority: server is
expected to execute fish command if it understands it. If it does not,
however, it can try the luck and execute shell command.
Server's reply is multiline, but always ends with
### 000<optional text>
line. ### is prefix to mark this line, 000 is return code. Return
codes are superset to those used in ftp.
There are few new exit codes defined:
000 don't know; if there were no previous lines, this marks COMPLETE
success, if they were, it marks failure.
001 don't know; if there were no previous lines, this marks
PRELIMinary success, if they were, it marks failure
Connecting
~~~~~~~~~~
Client uses "echo FISH:;/bin/sh" as command executed on remote
machine. This should make it possible for server to distinguish FISH
connections from normal rsh/ssh.
Commands
~~~~~~~~
#FISH
echo; start_fish_server; echo '### 200'
This command is sent at the beginning. It marks that client wishes to
talk via FISH protocol. #VER command must follow. If server
understands FISH protocol, it has option to put FISH server somewhere
on system path and name it start_fish_server.
#VER 0.0.2 <feature1> <feature2> <...>
echo '### 000'
This command is the second one. It sends client version and extensions
to the server. Server should reply with protocol version to be used,
and list of extensions accepted.
VER 0.0.0 <feature2>
### 200
#PWD
pwd; echo '### 200'
Server should reply with current directory (in form /abc/def/ghi)
followed by line indicating success.
#LIST /directory
ls -lLa $1 | grep '^[^cbt]' | ( while read p x u g s m d y n; do echo "P$p $u.$g
S$s
d$m $d $y
:$n
"; done )
ls -lLa $1 | grep '^[cb]' | ( while read p x u g a i m d y n; do echo "P$p $u.$g
E$a$i
dD$m $d $y
:$n
"; done )
echo '### 200'
This allows client to list directory or get status information about
single file. Output is in following form (any line except :<filename>
may be omitted):
P<unix permissions> <owner>.<group>
S<size>
d<3-letters month name> <day> <year or HH:MM>
D<year> <month> <day> <hour> <minute> <second>[.1234]
E<major-of-device>,<minor>
:<filename>
L<filename symlink points to>
<blank line to separate items>
Unix permissions are of form X--------- where X is type of
file. Currently, '-' means regular file, 'd' means directory, 'c', 'b'
means character and block device, 'l' means symbolic link, 'p' means
FIFO and 's' means socket.
'd' has three fields: month (one of strings Jan Feb Mar Apr May Jun
Jul Aug Sep Oct Nov Dec), day of month, and third is either single
number indicating year, or HH:MM field (assume current year in such
case). As you've probably noticed, this is pretty broken; it is for
compatibility with ls listing.
#RETR /some/name
ls -l /some/name | ( read a b c d x e; echo $x ); echo '### 100'; cat /some/name; echo '### 200'
Server sends line with filesize on it, followed by line with ### 100
indicating partial success, then it sends binary data (exactly
filesize bytes) and follows them with (with no preceding newline) ###
200.
Note that there's no way to abort running RETR command - except
closing the connection.
#STOR <size> /file/name
> /file/name; echo '### 001'; ( dd bs=4096 count=<size/4096>; dd bs=<size%4096> count=1 ) 2>/dev/null | ( cat > %s; cat > /dev/null ); echo '### 200'
This command is for storing /file/name, which is exactly size bytes
big. You probably think I went crazy. Well, I did not: that strange
cat > /dev/null has purpose to discard any extra data which was not
written to disk (due to for example out of space condition).
[Why? Imagine uploading file with "rm -rf /" line in it.]
#CWD /somewhere
cd /somewhere; echo '### 000'
It is specified here, but I'm not sure how wise idea is to use this
one: it breaks stateless-ness of the protocol.
Following commands should be rather self-explanatory:
#CHMOD 1234 file
chmod 1234 file; echo '### 000'
#DELE /some/path
rm -f /some/path; echo '### 000'
#MKD /some/path
mkdir /some/path; echo '### 000'
#RMD /some/path
rmdir /some/path; echo '### 000'
#RENAME /path/a /path/b
mv /path/a /path/b; echo '### 000'
#LINK /path/a /path/b
ln /path/a /path/b; echo '### 000'
#SYMLINK /path/a /path/b
ln -s /path/a /path/b; echo '### 000'
#CHOWN user /file/name
chown user /file/name; echo '### 000'
#CHGRP group /file/name
chgrp group /file/name; echo '### 000'
#READ <offset> <size> /path/and/filename
cat /path/and/filename | ( dd bs=4096 count=<offset/4096> > /dev/null;
dd bs=<offset%4096> count=1 > /dev/null;
dd bs=4096 count=<offset/4096>;
dd bs=<offset%4096> count=1; )
Returns ### 200 on successful exit, ### 291 on successful exit when
reading ended at eof, ### 292 on successfull exit when reading did not
end at eof.
#WRITE <offset> <size> /path/and/filename
Hmm, shall we define these ones if we know our client is not going to
use them?
That's all, folks!
pavel@ucw.cz

Просмотреть файл

@ -262,7 +262,7 @@ buttonbar_set_label (WButtonBar * bb, int idx, const char *text,
unsigned long command = CK_Ignore_Key;
if (keymap != NULL)
command = lookup_keymap_command (keymap, KEY_F (idx));
command = keybind_lookup_keymap_command (keymap, KEY_F (idx));
if ((text == NULL) || (text[0] == '\0'))
set_label_text (bb, idx, "");

Просмотреть файл

@ -306,7 +306,7 @@ static cb_ret_t
dlg_handle_key (Dlg_head * h, int d_key)
{
unsigned long command;
command = lookup_keymap_command (dialog_map, d_key);
command = keybind_lookup_keymap_command (dialog_map, d_key);
if ((command == CK_Ignore_Key) || (dlg_execute_cmd (h, command) == MSG_NOT_HANDLED))
return MSG_NOT_HANDLED;
else

Просмотреть файл

@ -1131,7 +1131,7 @@ input_handle_char (WInput * in, int key)
return v;
}
command = lookup_keymap_command (input_map, key);
command = keybind_lookup_keymap_command (input_map, key);
if (command == CK_Ignore_Key)
{
@ -1166,7 +1166,7 @@ input_key_is_in_map (WInput * in, int key)
{
unsigned long command;
command = lookup_keymap_command (input_map, key);
command = keybind_lookup_keymap_command (input_map, key);
if (command == CK_Ignore_Key)
return 0;

Просмотреть файл

@ -305,7 +305,7 @@ listbox_key (WListbox * l, int key)
return MSG_HANDLED;
}
command = lookup_keymap_command (listbox_map, key);
command = keybind_lookup_keymap_command (listbox_map, key);
if (command == CK_Ignore_Key)
return MSG_NOT_HANDLED;
return listbox_execute_cmd (l, command);

Просмотреть файл

@ -3141,7 +3141,7 @@ dview_handle_key (WDiff * dview, int key)
key = convert_from_input_c (key);
command = lookup_keymap_command (diff_map, key);
command = keybind_lookup_keymap_command (diff_map, key);
if ((command != CK_Ignore_Key) && (dview_execute_cmd (dview, command) == MSG_HANDLED))
return MSG_HANDLED;

Просмотреть файл

@ -51,7 +51,7 @@
#include "editcmd_dialogs.h"
#include "src/cmddef.h" /* list of commands */
#include "src/keybind.h" /* lookup_keymap_command() */
#include "src/keybind.h" /* keybind_lookup_keymap_command() */
#include "src/main.h" /* display_codepage */
/*** global variables ****************************************************************************/
@ -186,10 +186,10 @@ edit_translate_key (WEdit * edit, long x_key, int *cmd, int *ch)
if (edit->extmod)
{
edit->extmod = 0;
command = lookup_keymap_command (editor_x_map, x_key);
command = keybind_lookup_keymap_command (editor_x_map, x_key);
}
else
command = lookup_keymap_command (editor_map, x_key);
command = keybind_lookup_keymap_command (editor_map, x_key);
if (command == CK_Ignore_Key)
command = CK_Insert_Char;

Просмотреть файл

@ -74,13 +74,13 @@ edit_get_shortcut (unsigned long command)
const char *ext_map;
const char *shortcut = NULL;
shortcut = lookup_keymap_shortcut (editor_map, command);
shortcut = keybind_lookup_keymap_shortcut (editor_map, command);
if (shortcut != NULL)
return g_strdup (shortcut);
ext_map = lookup_keymap_shortcut (editor_map, CK_Ext_Mode);
ext_map = keybind_lookup_keymap_shortcut (editor_map, CK_Ext_Mode);
if (ext_map != NULL)
shortcut = lookup_keymap_shortcut (editor_x_map, command);
shortcut = keybind_lookup_keymap_shortcut (editor_x_map, command);
if (shortcut != NULL)
return g_strdup_printf ("%s %s", ext_map, shortcut);

Просмотреть файл

@ -918,7 +918,7 @@ help_handle_key (Dlg_head * h, int c)
{
unsigned long command;
command = lookup_keymap_command (help_map, c);
command = keybind_lookup_keymap_command (help_map, c);
if ((command == CK_Ignore_Key) || (help_execute_cmd (command) == MSG_NOT_HANDLED))
return MSG_NOT_HANDLED;

Просмотреть файл

@ -1277,7 +1277,7 @@ keybind_cmd_bind (GArray * keymap, const char *keybind, unsigned long action)
/* --------------------------------------------------------------------------------------------- */
unsigned long
lookup_action (const char *name)
keybind_lookup_action (const char *name)
{
const name_keymap_t key = { name, 0 };
name_keymap_t *res;
@ -1293,7 +1293,7 @@ lookup_action (const char *name)
/* --------------------------------------------------------------------------------------------- */
const char *
lookup_keymap_shortcut (const global_keymap_t * keymap, unsigned long action)
keybind_lookup_keymap_shortcut (const global_keymap_t * keymap, unsigned long action)
{
size_t i;
@ -1307,7 +1307,7 @@ lookup_keymap_shortcut (const global_keymap_t * keymap, unsigned long action)
/* --------------------------------------------------------------------------------------------- */
unsigned long
lookup_keymap_command (const global_keymap_t * keymap, long key)
keybind_lookup_keymap_command (const global_keymap_t * keymap, long key)
{
size_t i;

Просмотреть файл

@ -107,9 +107,9 @@ extern const global_keymap_t default_diff_keymap[];
/*** declarations of public functions ************************************************************/
void keybind_cmd_bind (GArray * keymap, const char *keybind, unsigned long action);
unsigned long lookup_action (const char *name);
const char *lookup_keymap_shortcut (const global_keymap_t * keymap, unsigned long action);
unsigned long lookup_keymap_command (const global_keymap_t * keymap, long key);
unsigned long keybind_lookup_action (const char *name);
const char *keybind_lookup_keymap_shortcut (const global_keymap_t * keymap, unsigned long action);
unsigned long keybind_lookup_keymap_command (const global_keymap_t * keymap, long key);
/*** inline functions ****************************************************************************/
#endif /* MC__KEYBIND_H */

Просмотреть файл

@ -598,17 +598,17 @@ midnight_get_shortcut (unsigned long command)
const char *ext_map;
const char *shortcut = NULL;
shortcut = lookup_keymap_shortcut (main_map, command);
shortcut = keybind_lookup_keymap_shortcut (main_map, command);
if (shortcut != NULL)
return g_strdup (shortcut);
shortcut = lookup_keymap_shortcut (panel_map, command);
shortcut = keybind_lookup_keymap_shortcut (panel_map, command);
if (shortcut != NULL)
return g_strdup (shortcut);
ext_map = lookup_keymap_shortcut (main_map, CK_StartExtMap1);
ext_map = keybind_lookup_keymap_shortcut (main_map, CK_StartExtMap1);
if (ext_map != NULL)
shortcut = lookup_keymap_shortcut (main_x_map, command);
shortcut = keybind_lookup_keymap_shortcut (main_x_map, command);
if (shortcut != NULL)
return g_strdup_printf ("%s %s", ext_map, shortcut);
@ -1392,7 +1392,7 @@ midnight_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void
if (ctl_x_map_enabled)
{
ctl_x_map_enabled = FALSE;
command = lookup_keymap_command (main_x_map, parm);
command = keybind_lookup_keymap_command (main_x_map, parm);
if (command != CK_Ignore_Key)
return midnight_execute_cmd (NULL, command);
}
@ -1509,10 +1509,10 @@ midnight_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void
if (ctl_x_map_enabled)
{
ctl_x_map_enabled = FALSE;
command = lookup_keymap_command (main_x_map, parm);
command = keybind_lookup_keymap_command (main_x_map, parm);
}
else
command = lookup_keymap_command (main_map, parm);
command = keybind_lookup_keymap_command (main_map, parm);
return (command == CK_Ignore_Key) ? MSG_NOT_HANDLED : midnight_execute_cmd (NULL, command);

Просмотреть файл

@ -61,7 +61,7 @@
#include "layout.h"
#include "cmd.h"
#include "file.h" /* safe_delete */
#include "keybind.h" /* lookup_action */
#include "keybind.h" /* keybind_lookup_action */
#ifdef USE_INTERNAL_EDIT
@ -569,7 +569,7 @@ load_keymap_from_section (const char *section_name, GArray * keymap, mc_config_t
curr_values = values =
mc_config_get_string_list (cfg, section_name, *profile_keys, &values_len);
action = lookup_action (*profile_keys);
action = keybind_lookup_action (*profile_keys);
if (action > 0)
{

Просмотреть файл

@ -397,12 +397,12 @@ mcview_handle_key (mcview_t * view, int key)
if (view->hexedit_mode && (mcview_handle_editkey (view, key) == MSG_HANDLED))
return MSG_HANDLED;
command = lookup_keymap_command (view->hex_map, key);
command = keybind_lookup_keymap_command (view->hex_map, key);
if ((command != CK_Ignore_Key) && (mcview_execute_cmd (view, command) == MSG_HANDLED))
return MSG_HANDLED;
}
command = lookup_keymap_command (view->plain_map, key);
command = keybind_lookup_keymap_command (view->plain_map, key);
if ((command != CK_Ignore_Key) && (mcview_execute_cmd (view, command) == MSG_HANDLED))
return MSG_HANDLED;