Merge branch '380_skins'

* 380_skins:
  Added new installed files into mc.spec.in
  Added Russian and English docs for skins.
  Add octets into array of lines instread of utf-8 string.
  Reidentation of code and changes for compile with CFLAGS="-pedantic -Wall -Wextra -Werror -Wno-long-long"
  Continue development of skins
  continue develop of skins.
  Add handle '-b' command line option.
  Box lines drawing. Now reading from skins. With ncurses don't work!
  Add hardcoded skins.
  Base support of skins.
This commit is contained in:
Slava Zanko 2009-09-18 12:07:05 +03:00
commit b5c2386551
80 changed files with 4156 additions and 2099 deletions

View File

@ -556,12 +556,14 @@ contrib/dist/pkginfo
contrib/dist/prototype
misc/Makefile
misc/skins/Makefile
misc/mc.ext
src/Makefile
src/filehighlight/Makefile
src/mcconfig/Makefile
src/search/Makefile
src/skin/Makefile
src/tty/Makefile
src/viewer/Makefile

View File

@ -150,6 +150,7 @@ rm -rf $RPM_BUILD_ROOT
%dir %{_datadir}/mc
%{_datadir}/mc/*
%{_datadir}/mc/skins/*
%dir %{_libexecdir}/mc

View File

@ -36,6 +36,14 @@ Colors
.\"Colors"
section.
.TP
.I \-S arg
Specify a name of skin in the command line. Technology of skins is
documented in the
.\"LINK2"
Skins\&.
.\"Skins"
section.
.TP
.I \-d, \-\-nomouse
Disable mouse support.
.TP
@ -1853,7 +1861,6 @@ according to rules described in /etc/mc/filehighlight.ini file. See
Filenames Highlight
.\"Filenames Highlight"
for more info.
.PP
If the
.I Show Mini\-Status
@ -3150,13 +3157,347 @@ used for background color. Example:
base_color=normal=white,default:marked=magenta,default
.fi
.\"NODE "Skins"
.SH "Skins"
You can change the appearance of Midhight Commander.
To do this, you must specify a file that contain descriptions of colors
and lines to draw boxes. Redefining of the colors is entirely compatible
with the assignment of colors, as described in Section
.\"LINK2"
Colors\&.
.\"Colors"
.PP
A skin\-file is searched on the following algorithm (to the first one found):
.IP
.br
1) command line option
.BR \-S
.BR \<skin\>
or
.BR \-\-skin=\<skin\>
.br
2) Environment variable
.BR MC_SKIN
.br
3) In config file parameter
.BR skin
in section
.BR \[Midhight
.BR Commander\]
.br
4) File
.BR /etc/mc/skins/default.ini
.br
5) File
.BR @prefix@/share/mc/skins/default.ini
.PP
Command line option, environment variable and parameter in config file may
contain the absolute path to the skin\-file (with the extension \.ini
or without it). Search of skin\-file will occur in (to the first one found):
.IP
1)
.BR ~/.mc/skins/
.br
2)
.BR /etc/mc/skins/
.br
3)
.BR @prefix@/share/mc/skins/
.br
.PP
For getting extended info, refer to:
.IP
.\"LINK2"
Description of section and parameters
.\"Skins sections"
.br
.\"LINK2"
Color pair definitions
.\"Skins colors"
.br
.\"LINK2"
Draw lines
.\"Skins lines"
.br
.\"LINK2"
Compability
.\"Skins oldcolors"
.br
.\"NODE " Skins sections"
.SH " Description of section and parameters"
Section
.BR [skin]
contain metainfo for skin\-file. Paramter
.I description
contain short text about skin.
.PP
Section
.BR [filehighlight]
contain descriptions of color pairs for filenames highlighting.
Name of parameters must be equal to names of sections into
filehighlight.ini file.
See
.\"LINK2"
Filenames Highlight
.\"Filenames Highlight"
for getting more info.
.PP
Section
.BR [core]
describes the elements that are used everywhere.
.TP
.I _default_
Default color pair. Used in all other sections if they not contain
color definitions
.TP
.I selected
cursor
.TP
.I marked
selected data
.TP
.I markselect
cursor on selected data
.TP
.I gauge
color of the filled part of the progress bar
.TP
.I input
color of input lines used in query dialogs.
.TP
.I reverse
reverse color
.PP
Section
.BR [dialog]
describes the elements that are placed on dialog windows (except error dialogs).
.TP
.I _default_
Default color for this section. Used [core]._default_ if not specified
.TP
.I dfocus
Color of active element (in focus)
.TP
.I dhotnormal
Color of hotkeys
.TP
.I dhotfocus
Color of hotkeys in focused element
.PP
Section
.BR [error]
describes the elements that are placed on error dialog windows
.TP
.I _default_
Default color for this section. Used [core]._default_ if not specified
.TP
.I errdhotnormal
Color of hotkeys
.TP
.I errdhotfocus
Color of hotkeys in focused element
.PP
Section
.BR [menu]
describes the elements that are placed on menu. This section describes
system menu (called by F9) and user-defined menus (called by F2 in panels
and by F11 in editor).
.TP
.I _default_
Default color for this section. Used [core]._default_ if not specified
.TP
.I entry
Color of menu items
.TP
.I menuhot
Color of menu hotkeys
.TP
.I menusel
Color of active menu item (in focus)
.TP
.I menuhotsel
Color of menu hotkeys in focused menu item
.PP
Section
.BR [help]
describes the elements that are placed on help window.
.TP
.I _default_
Default color for this section. Used [core]._default_ if not specified
.TP
.I helpitalic
Color pair for element with
.BR italic
attribute
.TP
.I helpbold
Color pair for element with
.BR bold
attribute
.TP
.I helplink
Color of links
.TP
.I helpslink
Color of active link (on focus)
.PP
Section
.BR [editor]
describes the colors of elements plased in editor.
.TP
.I _default_
Default color for this section. Used [core]._default_ if not specified
.TP
.I editbold
Color pair for element with
.BR bold
attribute
.TP
.I editmarked
Color of selected text
.TP
.I editwhitespace
Color of tabs and trailing spaces highlighting
.TP
.I linestate
Color for line state area
.PP
Section
.BR [viewer]
describes the colors of elements plased in viewer.
.TP
.I viewunderline
Color pair for element with
.BR underline
attribute
.\"NODE " Skins colors"
.SH " Color pair definitions"
Any parameter in skin\-file contain definition of color pair.
.PP
Color pairs described as two color separated by ';'. First color
sets the foreground color, second color sets background color.
One of the colors may be omitted, in this case color will be
taken from default color pair (global color pair or
from default color pair of this section).
.PP
Example:
.br
.nf
[core]
# green on black
_default_=green;black
# green(default) on blue
selected=;blue
# yellow on black(default)
marked=yellow;
.fi
.PP
Possible colors (names) described in
.\"LINK2"
Colors\&.
.\"Colors"
section.
.\"NODE " Skins lines"
.SH " Draw lines"
Lines sets in section
.BR [Lines]
into skin\-file. By default used single lines, but you may redefine
to usage of any utf\-8 symbols (like to lines, for example).
.PP
.I WARNING!!!
When you build Midnight Commander with the Ncurses screen library
usage of drawing lines is limited!
Possible only drawing a single lines.
For all questions and comments please contact the developers of Ncurses.
.PP
Descriptions of parameters
.BR [Lines] :
.TP
.I lefttop
left-top line fragment.
.TP
.I righttop
right-top line fragment.
.TP
.I centertop
down branch of horizontal line
.TP
.I centerbottom
up branch of horizontal line
.TP
.I leftbottom
left-bottom line fragment
.TP
.I rightbottom
right-bottom line fragment
.TP
.I leftmiddle
right branch of vertical line
.TP
.I rightmiddle
left branch of vertical line
.TP
.I centermiddle
cross of lines
.TP
.I horiz
horizontal line
.TP
.I vert
vertical line
.TP
.I thinhoriz
thin horizontal line
.TP
.I thinvert
thin vertical line
.\"NODE " Skins oldcolors"
.SH " Compability"
Appointment of color by skin\-files fully compatible with
the appointment of the colors described in
.\"LINK2"
Colors\&.
.\"Colors"
section.
.PP
In this case, reassignment of colors has priority over the skin files and is
complementary.
.\"NODE "Filenames Highlight"
.SH "Filenames Highlight"
Rules of filenames highlight placed in /etc/mc/filehighlight.ini file.
Section [filehighlight] from current skin\-file contain key names as
highlight groups and values as color pairs. Color pairs is documented
into
.\"LINK2"
Skins
.\"Skins"
section.
.PP
Main section [filehighlight] contain key names as highlight groups and values as color pairs.
Color pairs described as 'foreground;background'. 'background' may be omited.
Other sections describe filegroup of highlight. Keys in these groups:
Rules of filenames highlight placed in /etc/mc/filehighlight.ini file
(~/.mc/filehighlight.ini).
Name of section in this file must be equal to parameters names into
[filehighlight] section (in current skin\-file)
.PP
Keys in these groups:
.TP
.I type
file type. if present, all other option ignored
@ -3185,6 +3526,7 @@ list of extensions of files. Separated by ';' sign.
\- SPECIAL_FIFO
\- SPECIAL_DOOR
.fi
.PP
.\"NODE "Special Settings"
.SH "Special Settings"

View File

@ -40,6 +40,13 @@ UNIX\-подобных операционных системах.
Цвета\&.
.\"Colors"
.TP
.I \-S arg
Используется для того, чтобы задать другой скин в командной
строке. Технология скинов описана в разделе
.\"LINK2"
Внешний вид\&.
.\"Skins"
.TP
.I \-d
Отключает поддержку мыши.
.TP
@ -2003,13 +2010,13 @@ Commander. Вы можете вывести на экран или отмени
.\"Listing Mode..."
показывающие права пользователя, запустившего программу Midnight
Commander, выделены цветом, определенным ключевым словом
.I selected
(смотрите раздел
.I selected.
Если разрешено, подсветка имён файлов производится на основании
правил из файла /etc/mc/filehighlight.ini. Смотрите
.\"LINK2"
Цвета\&).
.\"Colors"
Если включено выделение цветом типов файлов, то разными цветами
выделяются каталоги, дампы памяти (файлы core), исполняемые файлы и т.д.
Подсветка имён файлов
.\"Filenames Highlight"
для получения большей информации.
.PP
При включенной опции
.IR Линейка меню
@ -3449,28 +3456,6 @@ editmarked.
.I helpslink
\- для выделения активной в данный момент гиперссылки.
.PP
Специальные цвета подсветки используются для отображения имен файлов
разных типов и выделения цветом прав доступа (если выделение цветом этих
элементов задано в настройках программы, смотрите раздел
.\"LINK2"
Внешний вид\&):
.\"Layout"
.I directory
используется для каталогов и символических ссылок на каталоги;
.I executable
\- для исполняемых файлов;
.I link
\- для символических ссылок, которые указывает НЕ на каталоги или
оборванные (stale) символические ссылки;
.I stalelink
\- для оборванных (stale) символических ссылок;
.I device
\- для файлов устройств;
.I special
\- для специальных файлов типа FIFO и IPC sockets;
.I core
\- для файлов с дампами (core).
.PP
Возможные цвета: black, gray, red, brightred, green, brightgreen, brown,
yellow, blue, brightblue, magenta, brightmagenta, cyan, brightcyan,
lightgray и white.
@ -3483,6 +3468,373 @@ lightgray и white.
[Colors]
base_color=normal=white,default:marked=magenta,default
.fi
.\"NODE "Skins"
.SH "Внешний вид"
Вы можете изменить внешний вид Midhight Commander'а. Для этого необходимо
указать файл, в котором указаны цвета и линии для отрисовки рамок. Такой
файл называется далее скин\-файл. переопределение внешнего вида полностью
совместимо с заданием цветов, описанным в секции
.\"LINK2"
Цвета\&.
.\"Colors"
.PP
Поиск скин\-файла производится по следующему алгоритму (до
первого нахождения файла):
.IP
.br
1) параметр командной строки
.BR \-S
.BR \<скин\>
или
.BR \-\-skin=\<скин\>
.br
2) Переменная окружения
.BR MC_SKIN
.br
3) В конфигурационном файле параметр
.BR skin
в секции
.BR \[Midhight
.BR Commander\]
.br
4) Файл
.BR /etc/mc/skins/default.ini
.br
5) Файл
.BR @prefix@/share/mc/skins/default.ini
.PP
Параметры в трёх первых случаях могут содержать абсолютный путь к скин\-файлу
либо просто название скина (с расширением \.ini либо без него). В данном
случае поиск скин\-файла будет происходить по следующим каталогам (до первого
нахождения):
.IP
1)
.BR ~/.mc/skins/
.br
2)
.BR /etc/mc/skins/
.br
3)
.BR @prefix@/share/mc/skins/
.br
.PP
Для получения расширенной информации, обратитесь к подразделам:
.IP
.\"LINK2"
Описание секций и параметров
.\"Skins sections"
.br
.\"LINK2"
Опеределения цветовых пар
.\"Skins colors"
.br
.\"LINK2"
Линии для отрисовки рамок
.\"Skins lines"
.br
.\"LINK2"
Совместимость
.\"Skins oldcolors"
.br
.\"NODE " Skins sections"
.SH " Описание секций"
Секция
.BR [skin]
содержит информацию, относящуюся к самому скин\-файлу. Параметр
.I description
кратко описывает скин.
.PP
Секция
.BR [filehighlight]
содержит описания цветовых пар для групп подсветок имен файлов.
Названия параметров в секции должно совпадать с названиями секций в файле подсветки.
Смотрите раздел
.\"LINK2"
Подсветка имён файлов
.\"Filenames Highlight"
для получения подробной информации.
.PP
Секция
.BR [core]
содержит описание элементов, используемых повсеместно.
.TP
.I _default_
Цвет по умолчанию. Используется во всех остальных секциях (глобальный параметр), если в них нет переопределения
.TP
.I selected
курсор
.TP
.I marked
отмеченные данные
.TP
.I markselect
курсор на отмеченных данных
.TP
.I gauge
цвет заполненной части полоски (progress bar)
.TP
.I input
элемент ввода данных
.TP
.I reverse
инвертированный цвет
.PP
Секция
.BR [dialog]
содержит описания элементов диалоговых окон (кроме сообщений об ошибках).
.TP
.I _default_
Цвет по умолчанию для данной секции. Если не указан, то используется [core]._default_
.TP
.I dfocus
Цвет элемента, находящегося в фокусе
.TP
.I dhotnormal
Цвет хоткеев
.TP
.I dhotfocus
Цвет хоткеев, находящихся в фокусе
.PP
Секция
.BR [error]
содержит описания элементов диалога об ошибках.
.TP
.I _default_
Цвет по умолчанию для данной секции. Если не указан, то используется [core]._default_
.TP
.I errdhotnormal
Цвет хоткеев
.TP
.I errdhotfocus
Цвет хоткеев, находящихся в фокусе
.PP
Секция
.BR [menu]
содержит описание элементов, отображающихся в меню. Это касается как системного меню
(вызываемого клавишей F9), так и пользовательских меню (F2 в панелях или F11 в редакторе).
.TP
.I _default_
Цвет по умолчанию для данной секции. Если не указан, то используется [core]._default_
.TP
.I entry
Цвет пунктов меню
.TP
.I menuhot
Цвет хоткеев
.TP
.I menusel
Цвет выделенного пункта меню
.TP
.I menuhotsel
Цвет хоткеев, находящихся в фокусе
.PP
Секция
.BR [help]
содержит описания цветов для окна отображения помощи.
.TP
.I _default_
Цвет по умолчанию для данной секции. Если не указан, то используется [core]._default_
.TP
.I helpitalic
Цветовыделение элементов с атрибутом
.BR italic
.TP
.I helpbold
Цветовыделение элементов с атрибутом
.BR bold
.TP
.I helplink
Цвет ссылок
.TP
.I helpslink
Цвет ссылки, находящейся под курсором
.PP
Секция
.BR [editor]
содержит описания элементов редактора
.TP
.I _default_
Цвет по умолчанию для данной секции. Если не указан, то используется [core]._default_
.TP
.I editbold
Цветовыделение элементов с атрибутом
.BR bold
.TP
.I editmarked
Цвет выделенного текста
.TP
.I editwhitespace
Подсветка знаков табуляции и "висящих" пробелов
.TP
.I linestate
Цвет области отображения состояния строки.
.PP
Секция
.BR [viewer]
содержит описания элементов редактора
.TP
.I viewunderline
Цветовыделение элементов с атрибутом
.BR underline
.\"NODE " Skins colors"
.SH " Цветовые пары"
Каждый параметр в скин\-файле содержит цветовые пары
.PP
Цветовые пары описываются как два цвета, разделённых символом ';'
первый цвет задаёт цвет написания символов, второй \- цвет фона.
Один из цветов может быть пропущен, в этом случае будет взят цвет
по умолчанию (глобальный или для данной секции).
.PP
Например:
.br
.nf
[core]
# зелёным по чёрному
_default_=green;black
# зелёным (умолч.) по синему
selected=;blue
# жёлтым по чёрному(умолч.)
marked=yellow;
.fi
.PP
Возможные цвета (названия) описаны в секции
.\"LINK2"
Цвета\&.
.\"Colors"
.\"NODE " Skins lines"
.SH " Линии для отрисовки рамок"
Линии задаются в секции
.BR [Lines]
в скин\-файле. По умолчанию используются одинарные линии, но возможно
переназначить на использование любых utf\-8 символов, похожих на линии
.PP
.I ВНИМАНИЕ!!!
При сборке Midnight Commander с библиотекой Ncurses использование
линий ограничено! Возможна только отрисовка одинарных линий. По всем
вопросам и предложениям обращайтесь к разработчикам Ncurses.
.PP
Описание параметров секции
.BR [Lines] :
.TP
.I lefttop
изображение левого верхнего угла рамки
.TP
.I righttop
изображение правого верхнего угла рамки
.TP
.I centertop
изображение ответвления горизонтальной линии вниз
.TP
.I centerbottom
изображение ответвления горизонтальной линии вверх
.TP
.I leftbottom
изображение левого нижнего угла рамки
.TP
.I rightbottom
изображение правого нижнего угла рамки
.TP
.I leftmiddle
изображение ответвления вертикальной линии вправо
.TP
.I rightmiddle
изображение ответвления вертикальной линии влево
.TP
.I centermiddle
изображение пересечения вертикальной и горизонтальной линий
.TP
.I horiz
изображение горизонтальной линии
.TP
.I vert
изображение вертикальной линии
.TP
.I thinhoriz
изображение тонкой горизонтальной линии
.TP
.I thinvert
изображение тонкой вертикальной линии
.\"NODE " Skins oldcolors"
.SH " Совместимость"
Назначение цветов элементов посредством скин\-файлов полностью совместимо
с назначением цветов, описанном в секции
.\"LINK2"
Цвета\&.
.\"Colors"
.PP
В данном случае переназначение цветов имеет приоритет над скин-файлами и носит
дополняющий характер.
.\"NODE "Filenames Highlight"
.SH "Подсветка имён файлов"
Секция [filehighlight] из текущего скин\-файла содержит имена параметров
(в качестве групп подсветки) и значения параметров как цветовые пары.
Описания цветовых пар смотрите в разделе
.\"LINK2"
Внешний вид
.\"Skins"
.PP
Правила подсветки находятся в файле /etc/mc/filehighlight.ini
(~/.mc/filehighlight.ini).
Названия групп должны совпадать с названиями параметров в секции
[filehighlight] в текущем скин\-файле.
.PP
Ключи в группах могут принимать следующие значения:
.TP
.I type
Тип файла. Если параметр присутствует, остальные опции игнорируются
.TP
.I regexp
Регулярное выражение. Если присутствует, параметр 'extensions' игнорируется.
.TP
.I extensions
Список расширений файлов. Раасширения разделяются символом ';'.
.PP
Параметр 'type' (тип файла) может принимать значения:
.nf
\- FILE (все файлы)
\- FILE_EXE
\- DIR (все каталоги)
\- LINK_DIR
\- LINK (все ссылки (линки), исключая "битые" линки)
\- HARDLINK
\- SYMLINK
\- STALE_LINK
\- DEVICE (все файлы устройств)
\- DEVICE_BLOCK
\- DEVICE_CHAR
\- SPECIAL (все специальные файлы)
\- SPECIAL_SOCKET
\- SPECIAL_FIFO
\- SPECIAL_DOOR
.fi
.\"NODE "Special Settings"
.SH "Специальные установки (Special Settings)"
Большинство установок Midnight Commander может быть изменено путем

View File

@ -29,7 +29,7 @@
#include "../src/global.h"
#include "../src/tty/tty.h"
#include "../src/tty/color.h" /* INPUT_COLOR */
#include "../src/skin/skin.h" /* INPUT_COLOR */
#include "../src/tty/key.h"
#include "../src/search/search.h"

View File

@ -46,7 +46,7 @@
#define MAX_LINE_LEN 1024
#include "../src/tty/tty.h" /* tty_printf() */
#include "../src/tty/color.h"
#include "../src/skin/skin.h"
#include "../src/tty/key.h" /* is_idle() */
#include "../src/widget.h" /* buttonbar_redraw() */

View File

@ -53,7 +53,7 @@
#include "../src/search/search.h" /* search engine */
#include "../src/tty/color.h"
#include "../src/skin/skin.h"
#include "edit-impl.h"
#include "edit-widget.h"
@ -504,7 +504,7 @@ void edit_get_syntax_color (WEdit * edit, long byte_index, int *color)
option_syntax_highlighting && tty_use_colors ()) {
translate_rule_to_color (edit, edit_get_rule (edit, byte_index), color);
} else {
*color = tty_use_colors () ? EDITOR_NORMAL_COLOR_INDEX : 0;
*color = tty_use_colors () ? mc_skin_color_get("editor", "_default_") : 0;
}
}
@ -1024,6 +1024,7 @@ void edit_free_syntax_rules (WEdit * edit)
}
MC_PTR_FREE (edit->rules);
tty_color_free_all_tmp();
}
/* returns -1 on file error, line number on error in file syntax */

View File

@ -1,5 +1,7 @@
## Process this file with automake to create Makefile.in.
SUBDIRS = skins
LIBFILES_OUT = mc.ext
noinst_DATA = xterm.ad

View File

@ -1,31 +1,15 @@
[filehighlight]
directory=white;
executable=brightgreen;
stalelink=brightred;
symlink=lightgray;
device=brightmagenta;
special=black;
core=red;
temp=gray;
archive=brightmagenta;
doc=brown;
source=cyan;
media=green;
graph=brightcyan;
database=brightred;
[executable]
type=FILE_EXE
[directory]
type=DIR
[stalelink]
type=STALE_LINK
[symlink]
type=SYMLINK
[stalelink]
type=STALE_LINK
[device]
type=DEVICE
@ -43,9 +27,6 @@
[archive]
extensions=gz;bz2;tar;tgz;rpm;Z;rar;zip;arj;cab;lzh;lha;zoo;arc;ark;xz;tbz;tbz2;
[hidden]
regexp=^\\..*
[doc]
extensions=txt;doc;rtf;diz;ctl;me;ps;pdf;xml;xsd;xslt;dtd;html;shtml;htm;mail;msg;lsm;po;nroff;man;tex;sgml;css;text;letter;chm

6
misc/skins/Makefile.am Normal file
View File

@ -0,0 +1,6 @@
skindir = $(pkgdatadir)/skins
skin_DATA = \
default.ini \
double-lines.ini

78
misc/skins/default.ini Normal file
View File

@ -0,0 +1,78 @@
[skin]
description=Standart skin
[Lines]
lefttop=
righttop=
centertop=
centerbottom=
leftbottom=
rightbottom=
leftmiddle=
rightmiddle=
centermiddle=
horiz=
vert=
thinhoriz=
thinvert=
[core]
_default_=lightgray;blue
selected=black;cyan
marked=yellow;blue
markselect=yellow;cyan;
gauge=white;black
input=black;cyan
reverse=black;lightgray
[dialog]
_default_=black;lightgray
dfocus=black;cyan
dhotnormal=blue;lightgray
dhotfocus=blue;cyan
[error]
_default_=white;red
errdhotnormal=yellow;red
errdhotfocus=yellow;lightgray
[filehighlight]
directory=white;
executable=brightgreen;
symlink=lightgray;
stalelink=brightred;
device=brightmagenta;
special=black;
core=red;
temp=gray;
archive=brightmagenta;
doc=brown;
source=cyan;
media=green;
graph=brightcyan;
database=brightred;
[menu]
_default_=white;cyan
entry=white;cyan
menuhot=yellow;cyan
menusel=white;black
menuhotsel=yellow;black
[help]
_default_=black;lightgray
helpitalic=red;lightgray
helpbold=blue;lightgray
helplink=black;cyan
helpslink=yellow;blue
[editor]
_default_=lightgray;blue
editbold=yellow;blue
editmarked=black;cyan
editwhitespace=brightblue;blue
linestate=white;cyan
[viewer]
viewunderline=brightred;blue

View File

@ -0,0 +1,78 @@
[skin]
description=Far-like skin
[Lines]
lefttop=
righttop=
centertop=
centerbottom=
leftbottom=
rightbottom=
leftmiddle=
rightmiddle=
centermiddle=
horiz=
vert=
thinhoriz=
thinvert=
[core]
_default_=lightgray;blue
selected=black;cyan
marked=yellow;blue
markselect=yellow;cyan;
gauge=white;black
input=black;cyan
reverse=black;lightgray
[dialog]
_default_=black;lightgray
dfocus=black;cyan
dhotnormal=blue;lightgray
dhotfocus=blue;cyan
[error]
_default_=white;red
errdhotnormal=yellow;red
errdhotfocus=yellow;lightgray
[filehighlight]
directory=white;
executable=brightgreen;
symlink=lightgray;
stalelink=brightred;
device=brightmagenta;
special=black;
core=red;
temp=gray;
archive=brightmagenta;
doc=brown;
source=cyan;
media=green;
graph=brightcyan;
database=brightred;
[menu]
_default_=white;cyan
entry=white;cyan
menuhot=yellow;cyan
menusel=white;black
menuhotsel=yellow;black
[help]
_default_=black;lightgray
helpitalic=red;lightgray
helpbold=blue;lightgray
helplink=black;cyan
helpslink=yellow;blue
[editor]
_default_=lightgray;blue
editbold=yellow;blue
editmarked=black;cyan
editwhitespace=brightblue;blue
linestate=white;cyan
[viewer]
viewunderline=brightred;blue

View File

@ -1,4 +1,4 @@
SUBDIRS = mcconfig search tty viewer filehighlight
SUBDIRS = mcconfig search tty viewer filehighlight skin
AM_CFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir) $(PCRE_CFLAGS)
@ -44,8 +44,9 @@ SEARCHLIB = search/libsearch.la
TTYLIB = tty/libmctty.la
VIEWERLIB = viewer/libmcviewer.la
FILEHIGHLIGHTLIB=filehighlight/libmcfilehighlight.la
SKINLIB = skin/libmcskin.la
mc_LDADD = $(EDITLIB) $(VFSLIB) $(FILEHIGHLIGHTLIB) \
mc_LDADD = $(EDITLIB) $(VFSLIB) $(FILEHIGHLIGHTLIB) $(SKINLIB) \
$(MCCONFIGLIB) $(SEARCHLIB) $(TTYLIB) $(VIEWERLIB) \
$(INTLLIBS) $(MCLIBS) $(SLANGLIB) $(LIBICONV) $(GLIB_LIBS)

View File

@ -37,7 +37,7 @@
#include "../src/tty/tty.h"
#include "../src/tty/key.h" /* XCTRL and ALT macros */
#include "../src/tty/color.h"
#include "../src/skin/skin.h"
#include "dialog.h"
#include "widget.h"

View File

@ -69,6 +69,9 @@ gboolean mc_args__disable_colors = FALSE;
/* Force colors, only used by Slang */
gboolean mc_args__force_colors = FALSE;
/* Show in specified skin */
char *mc_args__skin = NULL;
char *mc_args__last_wd_file = NULL;
/* when enabled NETCODE, use folowing file as logfile */
@ -246,6 +249,13 @@ static const GOptionEntry argument_color_table[] = {
"<string>"
},
{
"skin", 'S', ARGS_COLOR_OPTIONS, G_OPTION_ARG_STRING,
&mc_args__skin,
N_("Show mc with specified skin"),
"<string>"
},
{NULL}
};
#undef ARGS_COLOR_OPTIONS

View File

@ -15,6 +15,7 @@ extern gboolean mc_args__slow_terminal;
extern gboolean mc_args__ugly_line_drawing;
extern gboolean mc_args__disable_colors;
extern gboolean mc_args__force_colors;
extern char *mc_args__skin;
extern gboolean mc_args__version;
extern char *mc_args__last_wd_file;
extern char *mc_args__netfs_logfile;

View File

@ -37,7 +37,7 @@
#include "global.h"
#include "../src/tty/tty.h"
#include "../src/tty/color.h" /* INPUT_COLOR */
#include "../src/skin/skin.h" /* INPUT_COLOR */
#include "../src/tty/key.h" /* XCTRL and ALT macros */
#include "../src/mcconfig/mcconfig.h" /* Load/save user formats */

View File

@ -34,7 +34,7 @@
#include "global.h"
#include "../src/tty/tty.h"
#include "../src/tty/color.h"
#include "../src/skin/skin.h"
#include "dialog.h" /* add_widget() */
#include "widget.h" /* NORMAL_BUTTON */

View File

@ -35,7 +35,7 @@
#include "global.h"
#include "../src/tty/tty.h"
#include "../src/tty/color.h"
#include "../src/skin/skin.h"
#include "dialog.h"
#include "widget.h"

View File

@ -43,7 +43,7 @@
#include "user.h" /* expand_format */
#include "subshell.h" /* SUBSHELL_EXIT */
#include "tree.h" /* for tree_chdir */
#include "../src/tty/color.h" /* DEFAULT_COLOR */
#include "../src/skin/skin.h" /* DEFAULT_COLOR */
#include "execute.h" /* shell_execute */
#include "../src/strescape.h"

View File

@ -37,7 +37,7 @@
#include "global.h"
#include "../src/tty/tty.h"
#include "../src/tty/color.h" /* tty_set_normal_attrs */
#include "../src/skin/skin.h" /* tty_set_normal_attrs */
#include "../src/tty/win.h"
#include "cons.saver.h"

View File

@ -32,7 +32,7 @@
#include "global.h"
#include "../src/tty/tty.h"
#include "../src/tty/color.h"
#include "../src/skin/skin.h"
#include "../src/tty/mouse.h"
#include "../src/tty/key.h"

View File

@ -89,7 +89,7 @@ mc_fhl_new (gboolean need_auto_fill)
return NULL;
}
if (!mc_fhl_parce_ini_file (fhl)) {
if (!mc_fhl_parse_ini_file (fhl)) {
mc_fhl_free (&fhl);
return NULL;
}

View File

@ -28,7 +28,7 @@ void mc_fhl_free (mc_fhl_t **);
int mc_fhl_get_color (mc_fhl_t *, file_entry *);
gboolean mc_fhl_read_ini_file (mc_fhl_t *, const gchar *);
gboolean mc_fhl_parce_ini_file (mc_fhl_t *);
gboolean mc_fhl_parse_ini_file (mc_fhl_t *);
void mc_fhl_clear (mc_fhl_t *);
#endif

View File

@ -31,7 +31,7 @@
#include "../src/global.h"
#include "../src/util.h"
#include "../src/tty/color.h"
#include "../src/skin/skin.h"
#include "../src/filehighlight/fhl.h"
#include "internal.h"
@ -225,7 +225,6 @@ mc_fhl_get_color (mc_fhl_t * fhl, file_entry * fe)
mc_fhl_filter_t *mc_filter;
int ret;
if (fhl == NULL)
return NORMAL_COLOR;

View File

@ -1,6 +1,6 @@
/*
File highlight plugin.
Reading and parce rules from ini-files
Reading and parse rules from ini-files
Copyright (C) 2009 The Free Software Foundation, Inc.
@ -31,12 +31,14 @@
#include "../src/global.h"
#include "../src/main.h"
#include "../src/strescape.h"
#include "../src/tty/color.h"
#include "../src/skin/skin.h"
#include "fhl.h"
#include "internal.h"
/*** global variables ****************************************************************************/
extern mc_skin_t mc_skin__default;
/*** file scope macro definitions ****************************************************************/
/*** file scope type declarations ****************************************************************/
@ -47,37 +49,16 @@
/* --------------------------------------------------------------------------------------------- */
static void
mc_fhl_parce_fill_color_info (mc_fhl_filter_t * mc_filter, mc_fhl_t * fhl, const gchar * group_name)
mc_fhl_parse_fill_color_info (mc_fhl_filter_t * mc_filter, mc_fhl_t * fhl, const gchar * group_name)
{
gchar **colors;
gsize colors_size;
colors = mc_config_get_string_list (fhl->config, "filehighlight", group_name, &colors_size);
if (colors == NULL)
return;
if (colors[0] == NULL) {
g_strfreev (colors);
return;
}
mc_filter->fgcolor = g_strdup (colors[0]);
if (colors[1] == NULL)
mc_filter->bgcolor = NULL;
else
mc_filter->bgcolor = g_strdup (colors[1]);
g_strfreev (colors);
mc_filter->color_pair_index = tty_try_alloc_color_pair (mc_filter->fgcolor, mc_filter->bgcolor);
(void) fhl;
mc_filter->color_pair_index = mc_skin_color_get("filehighlight", group_name);
}
/* --------------------------------------------------------------------------------------------- */
static gboolean
mc_fhl_parce_get_file_type_id (mc_fhl_t * fhl, const gchar * group_name)
mc_fhl_parse_get_file_type_id (mc_fhl_t * fhl, const gchar * group_name)
{
mc_fhl_filter_t *mc_filter;
@ -109,7 +90,7 @@ mc_fhl_parce_get_file_type_id (mc_fhl_t * fhl, const gchar * group_name)
mc_filter = g_new0 (mc_fhl_filter_t, 1);
mc_filter->type = MC_FLHGH_T_FTYPE;
mc_filter->file_type = (mc_flhgh_ftype_type) i;
mc_fhl_parce_fill_color_info (mc_filter, fhl, group_name);
mc_fhl_parse_fill_color_info (mc_filter, fhl, group_name);
g_ptr_array_add (fhl->filters, (gpointer) mc_filter);
return TRUE;
@ -118,7 +99,7 @@ mc_fhl_parce_get_file_type_id (mc_fhl_t * fhl, const gchar * group_name)
/* --------------------------------------------------------------------------------------------- */
static gboolean
mc_fhl_parce_get_regexp (mc_fhl_t * fhl, const gchar * group_name)
mc_fhl_parse_get_regexp (mc_fhl_t * fhl, const gchar * group_name)
{
mc_fhl_filter_t *mc_filter;
gchar *regexp = mc_config_get_string (fhl->config, group_name, "regexp", "");
@ -134,7 +115,7 @@ mc_fhl_parce_get_regexp (mc_fhl_t * fhl, const gchar * group_name)
mc_filter->search_condition->is_case_sentitive = TRUE;
mc_filter->search_condition->search_type = MC_SEARCH_T_REGEX;
mc_fhl_parce_fill_color_info (mc_filter, fhl, group_name);
mc_fhl_parse_fill_color_info (mc_filter, fhl, group_name);
g_ptr_array_add (fhl->filters, (gpointer) mc_filter);
g_free (regexp);
return TRUE;
@ -144,7 +125,7 @@ mc_fhl_parce_get_regexp (mc_fhl_t * fhl, const gchar * group_name)
/* --------------------------------------------------------------------------------------------- */
static gboolean
mc_fhl_parce_get_extensions (mc_fhl_t * fhl, const gchar * group_name)
mc_fhl_parse_get_extensions (mc_fhl_t * fhl, const gchar * group_name)
{
mc_fhl_filter_t *mc_filter;
gchar **exts, **exts_orig;
@ -184,7 +165,7 @@ mc_fhl_parce_get_extensions (mc_fhl_t * fhl, const gchar * group_name)
mc_filter->search_condition->is_case_sentitive = TRUE;
mc_filter->search_condition->search_type = MC_SEARCH_T_REGEX;
mc_fhl_parce_fill_color_info (mc_filter, fhl, group_name);
mc_fhl_parse_fill_color_info (mc_filter, fhl, group_name);
g_ptr_array_add (fhl->filters, (gpointer) mc_filter);
g_string_free (buf, TRUE);
return TRUE;
@ -258,43 +239,36 @@ mc_fhl_init_from_standart_files (mc_fhl_t * fhl)
/* --------------------------------------------------------------------------------------------- */
gboolean
mc_fhl_parce_ini_file (mc_fhl_t * fhl)
mc_fhl_parse_ini_file (mc_fhl_t * fhl)
{
gchar **ftype_names, **orig_ftype_names;
gchar **group_names, **orig_group_names;
gsize ftype_names_size;
mc_fhl_array_free (fhl);
fhl->filters = g_ptr_array_new ();
if (!mc_config_has_group (fhl->config, "filehighlight"))
orig_group_names = group_names =
mc_config_get_groups (fhl->config, &ftype_names_size);
if (group_names == NULL)
return FALSE;
orig_ftype_names = ftype_names =
mc_config_get_keys (fhl->config, "filehighlight", &ftype_names_size);
while (*group_names) {
while (*ftype_names) {
if (!mc_config_has_group (fhl->config, *ftype_names)) {
ftype_names++;
continue;
if (mc_config_has_param (fhl->config, *group_names, "type")) {
/* parse filetype filter */
mc_fhl_parse_get_file_type_id (fhl, *group_names);
} else if (mc_config_has_param (fhl->config, *group_names, "regexp")) {
/* parse regexp filter */
mc_fhl_parse_get_regexp (fhl, *group_names);
} else if (mc_config_has_param (fhl->config, *group_names, "extensions")) {
/* parse extensions filter */
mc_fhl_parse_get_extensions (fhl, *group_names);
}
group_names++;
}
if (mc_config_has_param (fhl->config, *ftype_names, "type")) {
/* parce filetype filter */
mc_fhl_parce_get_file_type_id (fhl, *ftype_names);
} else if (mc_config_has_param (fhl->config, *ftype_names, "regexp")) {
/* parce regexp filter */
mc_fhl_parce_get_regexp (fhl, *ftype_names);
} else if (mc_config_has_param (fhl->config, *ftype_names, "extensions")) {
/* parce extensions filter */
mc_fhl_parce_get_extensions (fhl, *ftype_names);
}
ftype_names++;
}
g_strfreev (orig_ftype_names);
g_strfreev (orig_group_names);
return TRUE;
}

View File

@ -35,7 +35,7 @@
#include "global.h"
#include "../src/tty/tty.h"
#include "../src/tty/color.h"
#include "../src/skin/skin.h"
#include "../src/tty/key.h"
#include "../src/search/search.h"

View File

@ -54,7 +54,7 @@
#include "global.h"
#include "../src/tty/tty.h"
#include "../src/tty/color.h"
#include "../src/skin/skin.h"
#include "../src/tty/mouse.h"
#include "../src/tty/key.h"

View File

@ -43,7 +43,7 @@
#include "global.h"
#include "../src/tty/tty.h" /* COLS */
#include "../src/tty/color.h"
#include "../src/skin/skin.h"
#include "../src/tty/key.h" /* KEY_M_CTRL */
#include "dialog.h"

View File

@ -29,7 +29,7 @@
#include "../src/tty/tty.h"
#include "../src/tty/key.h" /* is_idle() */
#include "../src/tty/mouse.h" /* Gpm_Event */
#include "../src/tty/color.h"
#include "../src/skin/skin.h"
#include "dialog.h"
#include "widget.h" /* default_proc*/

View File

@ -49,7 +49,7 @@
#include "global.h"
#include "../src/tty/tty.h"
#include "../src/tty/color.h"
#include "../src/skin/skin.h"
#include "../src/tty/key.h"
#include "../src/tty/mouse.h"
#include "../src/tty/win.h" /* do_enter_ca_mode() */

View File

@ -42,13 +42,14 @@
#include "global.h"
#include "../src/tty/tty.h"
#include "../src/tty/color.h"
#include "../src/skin/skin.h"
#include "../src/tty/mouse.h"
#include "../src/tty/key.h" /* For init_key() */
#include "../src/tty/win.h" /* xterm_flag */
#include "../src/mcconfig/mcconfig.h"
#include "../src/args.h"
#include "../src/skin/skin.h"
#include "../src/filehighlight/fhl.h"
#include "dir.h"
@ -1666,13 +1667,11 @@ mc_maybe_editor_or_viewer (void)
static void
do_nc (void)
{
const int midnight_colors[DLG_COLOR_NUM] =
{
NORMAL_COLOR, /* NORMALC */
REVERSE_COLOR, /* FOCUSC */
INPUT_COLOR, /* HOT_NORMALC */
NORMAL_COLOR /* HOT_FOCUSC */
};
int midnight_colors[DLG_COLOR_NUM];
midnight_colors[0] = mc_skin_color_get("dialog", "_default_");
midnight_colors[1] = mc_skin_color_get("dialog", "focus");
midnight_colors[2] = mc_skin_color_get("dialog", "hotnormal");
midnight_colors[3] = mc_skin_color_get("dialog", "hotfocus");
midnight_dlg = create_dlg (0, 0, LINES, COLS, midnight_colors, midnight_callback,
"[main]", NULL, DLG_WANT_IDLE);
@ -1959,6 +1958,10 @@ main (int argc, char *argv[])
load_setup ();
tty_init_colors (mc_args__disable_colors, mc_args__force_colors);
mc_skin_init();
mc_filehighlight = mc_fhl_new (TRUE);
dlg_set_default_colors ();
/* create home directory */
@ -1998,12 +2001,11 @@ main (int argc, char *argv[])
#endif /* HAVE_SUBSHELL_SUPPORT */
prompt = (geteuid () == 0) ? "# " : "$ ";
mc_filehighlight = mc_fhl_new (TRUE);
/* Program main loop */
if (!midnight_shutdown)
do_nc ();
mc_fhl_free (&mc_filehighlight);
/* Save the tree store */
tree_store_save ();
@ -2012,6 +2014,9 @@ main (int argc, char *argv[])
flush_extension_file (); /* does only free memory */
mc_fhl_free (&mc_filehighlight);
mc_skin_deinit();
tty_shutdown ();
if (console_flag && !(quit & SUBSHELL_EXIT))

View File

@ -87,6 +87,7 @@ mc_config_get_string (mc_config_t * mc_config, const gchar * group,
GIConv conv;
GString *buffer;
gchar *ret;
const char *_system_codepage = str_detect_termencoding();
if (!mc_config || !group || !param)
return def ? g_strdup (def) : NULL;
@ -102,10 +103,10 @@ mc_config_get_string (mc_config_t * mc_config, const gchar * group,
if (!ret)
ret = def ? g_strdup (def) : NULL;
if (utf8_display)
if (str_isutf8 (_system_codepage))
return ret;
conv = str_crt_conv_from ("UTF-8");
conv = g_iconv_open (_system_codepage, "UTF-8");
if (conv == INVALID_CONV)
return ret;
@ -126,6 +127,31 @@ mc_config_get_string (mc_config_t * mc_config, const gchar * group,
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
gchar *
mc_config_get_string_raw (mc_config_t * mc_config, const gchar * group,
const gchar * param, const gchar * def)
{
gchar *ret;
if (!mc_config || !group || !param)
return def ? g_strdup (def) : NULL;
if (! mc_config_has_param(mc_config, group, param))
{
mc_config_set_string (mc_config, group, param, def ? def : "");
return def ? g_strdup (def) : NULL;
}
ret = g_key_file_get_string (mc_config->handle, group, param, NULL);
if (!ret)
ret = def ? g_strdup (def) : NULL;
return ret;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
gboolean
mc_config_get_bool (mc_config_t * mc_config, const gchar * group,
const gchar * param, gboolean def)

View File

@ -49,6 +49,9 @@ gchar **mc_config_get_keys (mc_config_t *, const gchar *, gsize *);
gchar *mc_config_get_string (mc_config_t *, const gchar *, const gchar *,
const gchar *);
gchar *mc_config_get_string_raw (mc_config_t *, const gchar *, const gchar *,
const gchar *);
gboolean mc_config_get_bool (mc_config_t *, const gchar *, const gchar *,
gboolean);

View File

@ -30,7 +30,7 @@
#include "global.h"
#include "../src/tty/tty.h"
#include "../src/tty/color.h"
#include "../src/skin/skin.h"
#include "../src/tty/mouse.h"
#include "../src/tty/key.h" /* key macros */

View File

@ -35,7 +35,7 @@
#include "global.h"
#include "../src/tty/color.h"
#include "../src/skin/skin.h"
#include "dialog.h"
#include "widget.h"

View File

@ -34,7 +34,7 @@
#include "global.h"
#include "../src/tty/tty.h"
#include "../src/tty/color.h"
#include "../src/skin/skin.h"
#include "../src/tty/mouse.h" /* For Gpm_Event */
#include "../src/tty/key.h" /* XCTRL and ALT macros */
#include "../src/filehighlight/fhl.h"

View File

@ -552,48 +552,6 @@ setup__move_panels_config_into_separate_file(const char*profile)
}
static int
setup_srt_to_char (char* str)
{
int res = -1;
if (!str)
return (int) ' ';
res = g_utf8_get_char_validated (str, -1);
if ( res < 0 ) {
return (int) *str;
} else {
return res;
}
}
static inline int
setup_load_lines_frm(const char *name)
{
int ret;
char *frm_val = NULL;
frm_val = mc_config_get_string(mc_main_config, "Lines", name, " ");
ret = setup_srt_to_char (frm_val);
g_free (frm_val);
return ret;
}
static void
setup_load_lines_tty(void)
{
mc_tty_ugly_frm[MC_TTY_FRM_horiz] = setup_load_lines_frm("horiz");
mc_tty_ugly_frm[MC_TTY_FRM_vert] = setup_load_lines_frm("vert");
mc_tty_ugly_frm[MC_TTY_FRM_lefttop] = setup_load_lines_frm("lefttop");
mc_tty_ugly_frm[MC_TTY_FRM_righttop] = setup_load_lines_frm("righttop");
mc_tty_ugly_frm[MC_TTY_FRM_leftbottom] = setup_load_lines_frm("leftbottom");
mc_tty_ugly_frm[MC_TTY_FRM_rightbottom] = setup_load_lines_frm("rightbottom");
mc_tty_ugly_frm[MC_TTY_FRM_thinvert] = setup_load_lines_frm("thinvert");
mc_tty_ugly_frm[MC_TTY_FRM_thinhoriz] = setup_load_lines_frm("thinhoriz");
mc_tty_ugly_frm[MC_TTY_FRM_rightmiddle] = setup_load_lines_frm("rightmiddle");
mc_tty_ugly_frm[MC_TTY_FRM_leftmiddle] = setup_load_lines_frm("leftmiddle");
}
char *
setup_init (void)
{
@ -724,9 +682,6 @@ load_setup (void)
if ( get_codepage_id( display_codepage ) )
utf8_display = str_isutf8 (get_codepage_id( display_codepage ));
#endif /* HAVE_CHARSET */
if (!mc_args__ugly_line_drawing)
setup_load_lines_tty();
}
#if defined(USE_VFS) && defined (USE_NETCODE)

17
src/skin/Makefile.am Normal file
View File

@ -0,0 +1,17 @@
noinst_LTLIBRARIES = libmcskin.la
libmcskin_la_SOURCES = \
colors.c \
colors-old.c \
common.c \
hc-skins.c \
ini-file.c \
lines.c \
skin.h \
internal.h
libmcskin_la_CFLAGS=-I../ -I$(top_srcdir)/src \
$(GLIB_CFLAGS) $(PCRE_CFLAGS) \
-DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\"
libmcskin_la_LIBADD = $(PCRE_LIBS)

162
src/skin/colors-old.c Normal file
View File

@ -0,0 +1,162 @@
/*
Skins engine.
Work with colors - backward compability
Copyright (C) 2009 The Free Software Foundation, Inc.
Written by:
Slava Zanko <slavazanko@gmail.com>, 2009.
This file is part of the Midnight Commander.
The Midnight Commander is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Midnight Commander is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
*/
#include <config.h>
#include <stdlib.h>
#include <sys/types.h> /* size_t */
#include "../src/tty/color.h"
#include "../src/global.h"
#include "../src/setup.h"
#include "skin.h"
#include "internal.h"
/*** global variables ****************************************************************************/
/*** file scope macro definitions ****************************************************************/
/*** file scope type declarations ****************************************************************/
typedef struct mc_skin_colors_old_struct {
const char *old_color;
const char *group;
const char *key;
} mc_skin_colors_old_t;
/*** file scope variables ************************************************************************/
mc_skin_colors_old_t old_colors[] = {
{"normal", "core", "_default_"},
{"selected", "ore", "selected"},
{"marked", "core", "marked"},
{"markselect", "core", "markselect"},
{"errors", "error", "_default_"},
{"menu", "menu", "_default_"},
{"reverse", "core", "reverse"},
{"dnormal", "dialog", "_default_"},
{"dfocus", "dialog", "dfocus"},
{"dhotnormal", "dialog", "dhotnormal"},
{"dhotfocus", "dialog", "dhotfocus"},
{"viewunderline", "viewer", "viewunderline"},
{"menuhot", "menu", "menuhot"},
{"menusel", "menu", "menusel"},
{"menuhotsel", "menu", "menuhotsel"},
{"helpnormal", "help", "_default_"},
{"helpitalic", "help", "helpitalic"},
{"helpbold", "help", "helpbold"},
{"helplink", "help", "helplink"},
{"helpslink", "help", "helpslink"},
{"gauge", "core", "gauge"},
{"input", "core", "input"},
{"editnormal", "editor", "_default_"},
{"editbold", "editor", "editbold"},
{"editmarked", "editor", "editmarked"},
{"editwhitespace", "editor", "editwhitespace"},
{"editlinestate", "editor", "linestate"},
{"errdhotnormal", "error", "errdhotnormal"},
{"errdhotfocus", "error", "errdhotfocus"},
{NULL, NULL, NULL}
};
/*** file scope functions ************************************************************************/
/* --------------------------------------------------------------------------------------------- */
static gboolean
mc_skin_colors_old_transform (const char *old_color, const char **group, const char **key)
{
int index;
if (old_color != NULL)
for (index = 0; old_colors[index].old_color; index++) {
if (strcasecmp (old_color, old_colors[index].old_color) == 0) {
if (group != NULL)
*group = old_colors[index].group;
if (key != NULL)
*key = old_colors[index].key;
return TRUE;
}
}
return FALSE;
}
/* --------------------------------------------------------------------------------------------- */
static void
mc_skin_colors_old_configure_one (mc_skin_t * mc_skin, const char *the_color_string)
{
gchar **colors, **orig_colors;
gchar **key_val;
const gchar *skin_group, *skin_key;
gchar *skin_val;
if (the_color_string == NULL)
return;
orig_colors = colors = g_strsplit (the_color_string, ":", -1);
if (colors == NULL)
return;
for (; *colors; colors++) {
key_val = g_strsplit_set (*colors, "=,", 3);
if (!key_val)
continue;
if (key_val[1] == NULL
|| !mc_skin_colors_old_transform (key_val[0], &skin_group, &skin_key)) {
g_strfreev (key_val);
continue;
}
if (key_val[2] != NULL)
skin_val = g_strdup_printf ("%s;%s", key_val[1], key_val[2]);
else
skin_val = g_strdup_printf ("%s;", key_val[1]);
mc_config_set_string (mc_skin->config, skin_group, skin_key, skin_val);
g_free (skin_val);
g_strfreev (key_val);
}
g_strfreev (orig_colors);
}
/* --------------------------------------------------------------------------------------------- */
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */
void
mc_skin_colors_old_configure (mc_skin_t * mc_skin)
{
mc_skin_colors_old_configure_one (mc_skin, setup_color_string);
mc_skin_colors_old_configure_one (mc_skin, term_color_string);
mc_skin_colors_old_configure_one (mc_skin, getenv ("MC_COLOR_TABLE"));
mc_skin_colors_old_configure_one (mc_skin, command_line_colors);
}
/* --------------------------------------------------------------------------------------------- */

337
src/skin/colors.c Normal file
View File

@ -0,0 +1,337 @@
/*
Skins engine.
Work with colors
Copyright (C) 2009 The Free Software Foundation, Inc.
Written by:
Slava Zanko <slavazanko@gmail.com>, 2009.
This file is part of the Midnight Commander.
The Midnight Commander is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Midnight Commander is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
*/
#include <config.h>
#include <string.h>
#include "../src/global.h"
#include "../src/args.h"
#include "../src/tty/color.h"
#include "skin.h"
#include "internal.h"
/*** global variables ****************************************************************************/
int mc_skin_color__cache[MC_SKIN_COLOR_CACHE_COUNT];
/*** file scope macro definitions ****************************************************************/
/*** file scope type declarations ****************************************************************/
/*** file scope variables ************************************************************************/
/*** file scope functions ************************************************************************/
static mc_skin_color_t *
mc_skin_color_get_from_hash (mc_skin_t * mc_skin, const gchar * group, const gchar * key)
{
gchar key_name[BUF_TINY];
mc_skin_color_t *mc_skin_color;
if (group == NULL || key == NULL)
return NULL;
if (mc_skin == NULL)
mc_skin = &mc_skin__default;
g_snprintf (key_name, sizeof (key_name), "%s.%s", group, key);
mc_skin_color = (mc_skin_color_t *) g_hash_table_lookup (mc_skin->colors, (gpointer) key_name);
return mc_skin_color;
}
/* --------------------------------------------------------------------------------------------- */
#if 0
static void
mc_skin_color_remove_from_hash (mc_skin_t * mc_skin, const gchar * group, const gchar * key)
{
gchar key_name[BUF_TINY];
if (group == NULL || key == NULL)
return;
if (mc_skin == NULL)
mc_skin = &mc_skin__default;
g_snprintf (key_name, sizeof (key_name), "%s.%s", group, key);
g_hash_table_remove (mc_skin->colors, (gpointer) key_name);
}
#endif
/* --------------------------------------------------------------------------------------------- */
static void
mc_skin_color_add_to_hash (mc_skin_t * mc_skin, const gchar * group, const gchar * key,
mc_skin_color_t * mc_skin_color)
{
gchar *key_name;
key_name = g_strdup_printf ("%s.%s", group, key);
if (key_name == NULL)
return;
if (g_hash_table_lookup (mc_skin->colors, (gpointer) key_name) != NULL)
g_hash_table_remove (mc_skin->colors, (gpointer) key_name);
g_hash_table_insert (mc_skin->colors, (gpointer) key_name, (gpointer) mc_skin_color);
}
/* --------------------------------------------------------------------------------------------- */
static mc_skin_color_t *
mc_skin_color_get_with_defaults (const gchar * group, const gchar * name)
{
mc_skin_color_t *mc_skin_color;
mc_skin_color = mc_skin_color_get_from_hash (NULL, group, name);
if (mc_skin_color != NULL)
return mc_skin_color;
mc_skin_color = mc_skin_color_get_from_hash (NULL, group, "_default_");
if (mc_skin_color != NULL)
return mc_skin_color;
mc_skin_color = mc_skin_color_get_from_hash (NULL, "core", "_default_");
return mc_skin_color;
}
/* --------------------------------------------------------------------------------------------- */
static mc_skin_color_t *
mc_skin_color_get_from_ini_file (mc_skin_t * mc_skin, const gchar * group, const gchar * key)
{
gsize items_count;
gchar **values;
mc_skin_color_t *mc_skin_color, *tmp;
values = mc_config_get_string_list (mc_skin->config, group, key, &items_count);
if (values == NULL || *values == NULL) {
if (values != NULL)
g_strfreev (values);
return NULL;
}
mc_skin_color = g_new0 (mc_skin_color_t, 1);
if (mc_skin_color == NULL) {
g_strfreev (values);
return NULL;
}
switch (items_count) {
case 0:
tmp = mc_skin_color_get_with_defaults (group, "_default_");
if (tmp) {
mc_skin_color->fgcolor = g_strdup (tmp->fgcolor);
mc_skin_color->bgcolor = g_strdup (tmp->bgcolor);
} else {
g_strfreev (values);
g_free (mc_skin_color);
return NULL;
}
break;
case 1:
mc_skin_color->fgcolor = (values[0]) ? g_strdup (values[0]) : NULL;
tmp = mc_skin_color_get_with_defaults (group, "_default_");
mc_skin_color->bgcolor = (tmp != NULL) ? g_strdup (tmp->bgcolor) : NULL;
break;
case 2:
mc_skin_color->fgcolor = (values[0]) ? g_strdup (values[0]) : NULL;
mc_skin_color->bgcolor = (values[1]) ? g_strdup (values[1]) : NULL;
break;
}
g_strfreev (values);
mc_skin_color->pair_index =
tty_try_alloc_color_pair2 (mc_skin_color->fgcolor, mc_skin_color->bgcolor, FALSE);
return mc_skin_color;
}
/* --------------------------------------------------------------------------------------------- */
static void
mc_skin_color_set_default_for_terminal (mc_skin_t * mc_skin)
{
mc_skin_color_t *mc_skin_color;
mc_skin_color = g_new0 (mc_skin_color_t, 1);
if (mc_skin_color == NULL)
return;
mc_skin_color->fgcolor = g_strdup ("default");
mc_skin_color->bgcolor = g_strdup ("default");
mc_skin_color->pair_index =
tty_try_alloc_color_pair2 (mc_skin_color->fgcolor, mc_skin_color->bgcolor, FALSE);
mc_skin_color_add_to_hash (mc_skin, "skin", "terminal_default_color", mc_skin_color);
}
/* --------------------------------------------------------------------------------------------- */
static void
mc_skin_color_cache_init (void)
{
DEFAULT_COLOR = mc_skin_color_get ("skin", "terminal_default_color");
NORMAL_COLOR = mc_skin_color_get ("core", "_default_");
MARKED_COLOR = mc_skin_color_get ("core", "marked");
SELECTED_COLOR = mc_skin_color_get ("core", "selected");
REVERSE_COLOR = mc_skin_color_get ("core", "reverse");
MARKED_SELECTED_COLOR = mc_skin_color_get ("core", "markselect");
ERROR_COLOR = mc_skin_color_get ("error", "_default_");
MENU_ENTRY_COLOR = mc_skin_color_get ("menu", "_default_");
COLOR_NORMAL = mc_skin_color_get ("dialog", "_default_");
COLOR_FOCUS = mc_skin_color_get ("dialog", "dfocus");
COLOR_HOT_NORMAL = mc_skin_color_get ("dialog", "dhotnormal");
COLOR_HOT_FOCUS = mc_skin_color_get ("dialog", "dhotfocus");
VIEW_UNDERLINED_COLOR = mc_skin_color_get ("viewer", "viewunderline");
MENU_SELECTED_COLOR = mc_skin_color_get ("menu", "menusel");
MENU_HOT_COLOR = mc_skin_color_get ("menu", "menuhot");
MENU_HOTSEL_COLOR = mc_skin_color_get ("menu", "menuhotsel");
HELP_NORMAL_COLOR = mc_skin_color_get ("help", "_default_");
HELP_ITALIC_COLOR = mc_skin_color_get ("help", "helpitalic");
HELP_BOLD_COLOR = mc_skin_color_get ("help", "helpbold");
HELP_LINK_COLOR = mc_skin_color_get ("help", "helplink");
HELP_SLINK_COLOR = mc_skin_color_get ("help", "helpslink");
GAUGE_COLOR = mc_skin_color_get ("core", "gauge");
INPUT_COLOR = mc_skin_color_get ("core", "input");
EDITOR_NORMAL_COLOR = mc_skin_color_get ("editor", "_default_");
EDITOR_BOLD_COLOR = mc_skin_color_get ("editor", "editbold");
EDITOR_MARKED_COLOR = mc_skin_color_get ("editor", "editmarked");
EDITOR_WHITESPACE_COLOR = mc_skin_color_get ("editor", "editwhitespace");
ERROR_HOT_NORMAL = mc_skin_color_get ("error", "errdhotnormal");
ERROR_HOT_FOCUS = mc_skin_color_get ("error", "errdhotfocus");
LINE_STATE_COLOR = mc_skin_color_get ("editor", "linestate");
}
/* --------------------------------------------------------------------------------------------- */
static gboolean
mc_skin_color_check_inisection (const gchar * group)
{
if ((strcasecmp ("skin", group) == 0)
|| (strcasecmp ("lines", group) == 0))
return FALSE;
return TRUE;
}
/* --------------------------------------------------------------------------------------------- */
static void
mc_skin_color_check_bw_mode (mc_skin_t * mc_skin)
{
gsize items_count;
gchar **groups, **orig_groups;
if (!mc_args__disable_colors)
return;
orig_groups = groups = mc_config_get_groups (mc_skin->config, &items_count);
if (groups == NULL)
return;
for (; *groups != NULL; groups++) {
if (mc_skin_color_check_inisection (*groups))
mc_config_del_group (mc_skin->config, *groups);
}
g_strfreev (orig_groups);
mc_skin_hardcoded_blackwhite_colors (mc_skin);
}
/* --------------------------------------------------------------------------------------------- */
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */
gboolean
mc_skin_color_parse_ini_file (mc_skin_t * mc_skin)
{
gsize items_count;
gchar **groups, **orig_groups;
gchar **keys, **orig_keys;
mc_skin_color_t *mc_skin_color;
mc_skin_color_check_bw_mode (mc_skin);
orig_groups = groups = mc_config_get_groups (mc_skin->config, &items_count);
if (groups == NULL || *groups == NULL) {
if (groups != NULL)
g_strfreev (groups);
return FALSE;
}
/* as first, need to set up default colors */
mc_skin_color_set_default_for_terminal (mc_skin);
mc_skin_color = mc_skin_color_get_from_ini_file (mc_skin, "core", "_default_");
if (mc_skin_color == NULL)
return FALSE;
tty_color_set_defaults (mc_skin_color->fgcolor, mc_skin_color->bgcolor);
mc_skin_color_add_to_hash (mc_skin, "core", "_default_", mc_skin_color);
for (; *groups != NULL; groups++) {
if (!mc_skin_color_check_inisection (*groups))
continue;
orig_keys = keys = mc_config_get_keys (mc_skin->config, *groups, &items_count);
if (keys == NULL || *keys == NULL) {
if (keys != NULL)
g_strfreev (keys);
continue;
}
for (; *keys; keys++) {
mc_skin_color = mc_skin_color_get_from_ini_file (mc_skin, *groups, *keys);
if (mc_skin_color != NULL)
mc_skin_color_add_to_hash (mc_skin, *groups, *keys, mc_skin_color);
}
g_strfreev (orig_keys);
}
g_strfreev (orig_groups);
mc_skin_color_cache_init ();
return TRUE;
}
/* --------------------------------------------------------------------------------------------- */
int
mc_skin_color_get (const gchar * group, const gchar * name)
{
mc_skin_color_t *mc_skin_color;
mc_skin_color = mc_skin_color_get_with_defaults (group, name);
return (mc_skin_color != NULL) ? mc_skin_color->pair_index : 0;
}
/* --------------------------------------------------------------------------------------------- */

150
src/skin/common.c Normal file
View File

@ -0,0 +1,150 @@
/*
Skins engine.
Interface functions
Copyright (C) 2009 The Free Software Foundation, Inc.
Written by:
Slava Zanko <slavazanko@gmail.com>, 2009.
This file is part of the Midnight Commander.
The Midnight Commander is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Midnight Commander is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
*/
#include <config.h>
#include <stdlib.h>
#include "../src/global.h"
#include "../src/args.h"
#include "skin.h"
#include "internal.h"
/*** global variables ****************************************************************************/
mc_skin_t mc_skin__default;
/*** file scope macro definitions ****************************************************************/
/*** file scope type declarations ****************************************************************/
/*** file scope variables ************************************************************************/
static gboolean mc_skin_is_init = FALSE;
/* --------------------------------------------------------------------------------------------- */
/*** file scope functions ************************************************************************/
/* --------------------------------------------------------------------------------------------- */
static inline void
mc_skin_hash_destroy_key (gpointer data)
{
g_free (data);
}
/* --------------------------------------------------------------------------------------------- */
static void
mc_skin_hash_destroy_value (gpointer data)
{
mc_skin_color_t *mc_skin_color = (mc_skin_color_t *) data;
g_free (mc_skin_color->fgcolor);
g_free (mc_skin_color->bgcolor);
g_free (mc_skin_color);
}
/* --------------------------------------------------------------------------------------------- */
static char *
mc_skin_get_default_name (void)
{
char *tmp_str;
/* from command line */
if (mc_args__skin != NULL)
return g_strdup (mc_args__skin);
/* from envirovement variable */
tmp_str = getenv ("MC_SKIN");
if (tmp_str != NULL)
return g_strdup (tmp_str);
/* from config. Or 'default' if no present in config */
return mc_config_get_string (mc_main_config, CONFIG_APP_SECTION, "skin", "default");
}
/* --------------------------------------------------------------------------------------------- */
static void
mc_skin_reinit (void)
{
mc_skin_deinit ();
mc_skin__default.name = mc_skin_get_default_name ();
mc_skin__default.colors = g_hash_table_new_full (g_str_hash, g_str_equal,
mc_skin_hash_destroy_key,
mc_skin_hash_destroy_value);
}
/* --------------------------------------------------------------------------------------------- */
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */
void
mc_skin_init (void)
{
mc_skin__default.name = mc_skin_get_default_name ();
mc_skin__default.colors = g_hash_table_new_full (g_str_hash, g_str_equal,
mc_skin_hash_destroy_key,
mc_skin_hash_destroy_value);
if (!mc_skin_ini_file_load (&mc_skin__default)) {
mc_skin_reinit ();
mc_skin_set_hardcoded_skin (&mc_skin__default);
}
mc_skin_colors_old_configure (&mc_skin__default);
if (!mc_skin_ini_file_parse (&mc_skin__default)) {
mc_skin_reinit ();
mc_skin_set_hardcoded_skin (&mc_skin__default);
mc_skin_colors_old_configure (&mc_skin__default);
(void) mc_skin_ini_file_parse (&mc_skin__default);
}
mc_skin_is_init = TRUE;
}
/* --------------------------------------------------------------------------------------------- */
void
mc_skin_deinit (void)
{
g_free (mc_skin__default.name);
mc_skin__default.name = NULL;
g_hash_table_destroy (mc_skin__default.colors);
mc_skin__default.colors = NULL;
g_free (mc_skin__default.description);
mc_skin__default.description = NULL;
if (mc_skin__default.config) {
mc_config_deinit (mc_skin__default.config);
mc_skin__default.config = NULL;
}
mc_skin_is_init = FALSE;
}
/* --------------------------------------------------------------------------------------------- */

115
src/skin/hc-skins.c Normal file
View File

@ -0,0 +1,115 @@
/*
Skins engine.
Set of hardcoded skins
Copyright (C) 2009 The Free Software Foundation, Inc.
Written by:
Slava Zanko <slavazanko@gmail.com>, 2009.
This file is part of the Midnight Commander.
The Midnight Commander is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Midnight Commander is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
*/
#include <config.h>
#include "../src/global.h"
#include "skin.h"
#include "internal.h"
/*** global variables ****************************************************************************/
/*** file scope macro definitions ****************************************************************/
#define set_lines(x,y) mc_config_set_string(mc_skin->config, "Lines", x, y)
/*** file scope type declarations ****************************************************************/
/*** file scope variables ************************************************************************/
/*** file scope functions ************************************************************************/
/* --------------------------------------------------------------------------------------------- */
/* --------------------------------------------------------------------------------------------- */
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */
void
mc_skin_hardcoded_blackwhite_colors (mc_skin_t * mc_skin)
{
mc_config_set_string (mc_skin->config, "core", "_default_", "default;default");
mc_config_set_string (mc_skin->config, "core", "selected", "A_REVERSE");
mc_config_set_string (mc_skin->config, "core", "marked", "A_BOLD");
mc_config_set_string (mc_skin->config, "core", "markselect", "A_BOLD_REVERSE");
mc_config_set_string (mc_skin->config, "core", "reverse", "A_REVERSE");
mc_config_set_string (mc_skin->config, "dialog", "_default_", "A_REVERSE");
mc_config_set_string (mc_skin->config, "dialog", "focus", "A_BOLD");
mc_config_set_string (mc_skin->config, "menu", "entry", "A_REVERSE");
mc_config_set_string (mc_skin->config, "menu", "selected", "A_BOLD");
mc_config_set_string (mc_skin->config, "help", "_default_", "A_REVERSE");
mc_config_set_string (mc_skin->config, "help", "italic", "A_REVERSE");
mc_config_set_string (mc_skin->config, "help", "bold", "A_REVERSE");
mc_config_set_string (mc_skin->config, "help", "slink", "A_BOLD");
mc_config_set_string (mc_skin->config, "editor", "bold", "A_BOLD");
mc_config_set_string (mc_skin->config, "editor", "marked", "A_REVERSE");
mc_config_set_string (mc_skin->config, "viewer", "underline", "A_UNDERLINE");
mc_config_set_string (mc_skin->config, "error", "_default_", "A_BOLD");
}
/* --------------------------------------------------------------------------------------------- */
void
mc_skin_hardcoded_space_lines (mc_skin_t * mc_skin)
{
set_lines ("lefttop", " ");
set_lines ("righttop", " ");
set_lines ("centertop", " ");
set_lines ("centerbottom", " ");
set_lines ("leftbottom", " ");
set_lines ("rightbottom", " ");
set_lines ("leftmiddle", " ");
set_lines ("rightmiddle", " ");
set_lines ("centermiddle", " ");
set_lines ("horiz", " ");
set_lines ("vert", " ");
set_lines ("thinhoriz", " ");
set_lines ("thinvert", " ");
}
/* --------------------------------------------------------------------------------------------- */
void
mc_skin_hardcoded_ugly_lines (mc_skin_t * mc_skin)
{
set_lines ("lefttop", "+");
set_lines ("righttop", "+");
set_lines ("centertop", "-");
set_lines ("centerbottom", "-");
set_lines ("leftbottom", "+");
set_lines ("rightbottom", "+");
set_lines ("leftmiddle", "|");
set_lines ("rightmiddle", "|");
set_lines ("centermiddle", "+");
set_lines ("horiz", "-");
set_lines ("vert", "|");
set_lines ("thinhoriz", "-");
set_lines ("thinvert", "|");
}
/* --------------------------------------------------------------------------------------------- */

137
src/skin/ini-file.c Normal file
View File

@ -0,0 +1,137 @@
/*
Skins engine.
Reading and parse ini-files
Copyright (C) 2009 The Free Software Foundation, Inc.
Written by:
Slava Zanko <slavazanko@gmail.com>, 2009.
This file is part of the Midnight Commander.
The Midnight Commander is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Midnight Commander is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
*/
#include <config.h>
#include <string.h>
#include "../src/global.h"
#include "../src/main.h"
#include "skin.h"
#include "internal.h"
/*** global variables ****************************************************************************/
/*** file scope macro definitions ****************************************************************/
/*** file scope type declarations ****************************************************************/
/*** file scope variables ************************************************************************/
/*** file scope functions ************************************************************************/
/* --------------------------------------------------------------------------------------------- */
static gboolean
mc_skin_ini_file_load_search_in_dir (mc_skin_t * mc_skin, const gchar * base_dir)
{
char *file_name, *file_name2;
file_name = g_build_filename (base_dir, "skins", mc_skin->name, NULL);
if (exist_file (file_name)) {
mc_skin->config = mc_config_init (file_name);
g_free (file_name);
return (mc_skin->config != NULL);
}
g_free (file_name);
file_name2 = g_strdup_printf ("%s.ini", mc_skin->name);
file_name = g_build_filename (base_dir, "skins", file_name2, NULL);
g_free (file_name2);
if (exist_file (file_name)) {
mc_skin->config = mc_config_init (file_name);
g_free (file_name);
return (mc_skin->config != NULL);
}
g_free (file_name);
return FALSE;
}
/* --------------------------------------------------------------------------------------------- */
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */
gboolean
mc_skin_ini_file_load (mc_skin_t * mc_skin)
{
char *file_name, *user_home_dir;
file_name = g_path_get_basename (mc_skin->name);
if (strcmp (file_name, mc_skin->name) != 0) {
g_free (file_name);
if (!g_path_is_absolute (mc_skin->name))
return FALSE;
mc_skin->config = mc_config_init (mc_skin->name);
return (mc_skin->config != NULL);
}
g_free (file_name);
/* ~/.mc/skins/ */
user_home_dir = concat_dir_and_file (home_dir, MC_BASE);
if (mc_skin_ini_file_load_search_in_dir (mc_skin, user_home_dir)) {
g_free (user_home_dir);
return TRUE;
}
g_free (user_home_dir);
/* /etc/mc/skins/ */
if (mc_skin_ini_file_load_search_in_dir (mc_skin, mc_home))
return TRUE;
/* /usr/share/mc/skins/ */
return mc_skin_ini_file_load_search_in_dir (mc_skin, mc_home_alt);
}
/* --------------------------------------------------------------------------------------------- */
gboolean
mc_skin_ini_file_parse (mc_skin_t * mc_skin)
{
mc_skin->description =
mc_config_get_string (mc_skin->config, "skin", "description", "- no description -");
if (!mc_skin_color_parse_ini_file (mc_skin))
return FALSE;
mc_skin_lines_parse_ini_file (mc_skin);
return TRUE;
}
/* --------------------------------------------------------------------------------------------- */
void
mc_skin_set_hardcoded_skin (mc_skin_t * mc_skin)
{
mc_skin->config = mc_config_init (NULL);
mc_config_set_string (mc_skin->config, "skin", "description", "hardcoded skin");
mc_skin_hardcoded_ugly_lines (mc_skin);
mc_skin_hardcoded_blackwhite_colors (mc_skin);
}
/* --------------------------------------------------------------------------------------------- */

39
src/skin/internal.h Normal file
View File

@ -0,0 +1,39 @@
#ifndef MC__SKIN_INTERNAL_H
#define MC__SKIN_INTERNAL_H
#include "../../src/global.h"
#include "skin.h"
/*** typedefs(not structures) and defined constants **********************************************/
/*** enums ***************************************************************************************/
/*** structures declarations (and typedefs of structures)*****************************************/
typedef struct mc_skin_color_struct {
gchar *fgcolor;
gchar *bgcolor;
int pair_index;
} mc_skin_color_t;
/*** global variables defined in .c file *********************************************************/
extern mc_skin_t mc_skin__default;
/*** declarations of public functions ************************************************************/
gboolean mc_skin_ini_file_load (mc_skin_t *);
gboolean mc_skin_ini_file_parse (mc_skin_t *);
void mc_skin_set_hardcoded_skin (mc_skin_t *);
gboolean mc_skin_ini_file_parse_colors (mc_skin_t *);
gboolean mc_skin_color_parse_ini_file (mc_skin_t *);
void mc_skin_hardcoded_ugly_lines (mc_skin_t *);
void mc_skin_hardcoded_space_lines (mc_skin_t *);
void mc_skin_hardcoded_blackwhite_colors (mc_skin_t *);
void mc_skin_colors_old_configure (mc_skin_t *);
#endif

122
src/skin/lines.c Normal file
View File

@ -0,0 +1,122 @@
/*
Skins engine.
Work with line draving chars.
Copyright (C) 2009 The Free Software Foundation, Inc.
Written by:
Slava Zanko <slavazanko@gmail.com>, 2009.
This file is part of the Midnight Commander.
The Midnight Commander is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Midnight Commander is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
*/
#include <config.h>
#include <stdlib.h>
#include "../src/global.h"
#include "../src/args.h"
#include "../src/tty/tty.h"
#include "skin.h"
#include "internal.h"
/*** global variables ****************************************************************************/
/*** file scope macro definitions ****************************************************************/
/*** file scope type declarations ****************************************************************/
/*** file scope variables ************************************************************************/
/*** file scope functions ************************************************************************/
static int
mc_skin_lines_load_frm (mc_skin_t * mc_skin, const char *name)
{
int ret;
char *frm_val = NULL;
frm_val = mc_config_get_string_raw (mc_skin->config, "Lines", name, " ");
ret = mc_tty_normalize_lines_char (frm_val);
g_free (frm_val);
switch (ret) {
case 0x80:
ret = ACS_HLINE;
break;
case 0x81:
ret = ACS_VLINE;
break;
case 0x82:
ret = ACS_ULCORNER;
break;
case 0x83:
ret = ACS_URCORNER;
break;
case 0x84:
ret = ACS_LLCORNER;
break;
case 0x85:
ret = ACS_LRCORNER;
break;
case 0x86:
ret = ACS_LTEE;
break;
case 0x87:
ret = ACS_RTEE;
break;
case 0x8a:
ret = ACS_PLUS;
break;
default:
break;
}
return ret;
}
/* --------------------------------------------------------------------------------------------- */
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */
void
mc_skin_lines_parse_ini_file (mc_skin_t * mc_skin)
{
if (mc_args__slow_terminal) {
mc_skin_hardcoded_space_lines (mc_skin);
} else if (mc_args__ugly_line_drawing) {
mc_skin_hardcoded_ugly_lines (mc_skin);
}
mc_tty_ugly_frm[MC_TTY_FRM_horiz] = mc_skin_lines_load_frm (mc_skin, "horiz");
mc_tty_ugly_frm[MC_TTY_FRM_vert] = mc_skin_lines_load_frm (mc_skin, "vert");
mc_tty_ugly_frm[MC_TTY_FRM_lefttop] = mc_skin_lines_load_frm (mc_skin, "lefttop");
mc_tty_ugly_frm[MC_TTY_FRM_righttop] = mc_skin_lines_load_frm (mc_skin, "righttop");
mc_tty_ugly_frm[MC_TTY_FRM_leftbottom] = mc_skin_lines_load_frm (mc_skin, "leftbottom");
mc_tty_ugly_frm[MC_TTY_FRM_rightbottom] = mc_skin_lines_load_frm (mc_skin, "rightbottom");
mc_tty_ugly_frm[MC_TTY_FRM_thinvert] = mc_skin_lines_load_frm (mc_skin, "thinvert");
mc_tty_ugly_frm[MC_TTY_FRM_thinhoriz] = mc_skin_lines_load_frm (mc_skin, "thinhoriz");
mc_tty_ugly_frm[MC_TTY_FRM_rightmiddle] = mc_skin_lines_load_frm (mc_skin, "rightmiddle");
mc_tty_ugly_frm[MC_TTY_FRM_centertop] = mc_skin_lines_load_frm (mc_skin, "centertop");
mc_tty_ugly_frm[MC_TTY_FRM_centerbottom] = mc_skin_lines_load_frm (mc_skin, "centerbottom");
mc_tty_ugly_frm[MC_TTY_FRM_centermiddle] = mc_skin_lines_load_frm (mc_skin, "centermiddle");
mc_tty_ugly_frm[MC_TTY_FRM_leftmiddle] = mc_skin_lines_load_frm (mc_skin, "leftmiddle");
}
/* --------------------------------------------------------------------------------------------- */

95
src/skin/skin.h Normal file
View File

@ -0,0 +1,95 @@
#ifndef MC__SKIN_H
#define MC__SKIN_H
#include "../../src/global.h"
#include "../../src/mcconfig/mcconfig.h"
#include "../src/tty/color.h"
/*** typedefs(not structures) and defined constants **********************************************/
/* Beware! When using Slang with color, not all the indexes are free.
See color-slang.h (A_*) */
/* cache often used colors*/
#define DEFAULT_COLOR mc_skin_color__cache[0]
#define NORMAL_COLOR mc_skin_color__cache[1]
#define MARKED_COLOR mc_skin_color__cache[2]
#define SELECTED_COLOR mc_skin_color__cache[3]
#define MARKED_SELECTED_COLOR mc_skin_color__cache[4]
#define REVERSE_COLOR mc_skin_color__cache[5]
/* Dialog colors */
#define COLOR_NORMAL mc_skin_color__cache[6]
#define COLOR_FOCUS mc_skin_color__cache[7]
#define COLOR_HOT_NORMAL mc_skin_color__cache[8]
#define COLOR_HOT_FOCUS mc_skin_color__cache[9]
/* Error dialog colors */
#define ERROR_COLOR mc_skin_color__cache[10]
#define ERROR_HOT_NORMAL mc_skin_color__cache[11]
#define ERROR_HOT_FOCUS mc_skin_color__cache[12]
/* Menu colors */
#define MENU_ENTRY_COLOR mc_skin_color__cache[13]
#define MENU_SELECTED_COLOR mc_skin_color__cache[14]
#define MENU_HOT_COLOR mc_skin_color__cache[15]
#define MENU_HOTSEL_COLOR mc_skin_color__cache[16]
/*
* This should be selectable independently. Default has to be black background
* foreground does not matter at all.
*/
#define GAUGE_COLOR mc_skin_color__cache[17]
#define INPUT_COLOR mc_skin_color__cache[18]
#define HELP_NORMAL_COLOR mc_skin_color__cache[19]
#define HELP_ITALIC_COLOR mc_skin_color__cache[20]
#define HELP_BOLD_COLOR mc_skin_color__cache[21]
#define HELP_LINK_COLOR mc_skin_color__cache[22]
#define HELP_SLINK_COLOR mc_skin_color__cache[23]
#define VIEW_UNDERLINED_COLOR mc_skin_color__cache[24]
/*
* editor colors - only 4 for normal, search->found, select, and whitespace
* respectively
* Last is defined to view color.
*/
#define EDITOR_NORMAL_COLOR mc_skin_color__cache[25]
#define EDITOR_BOLD_COLOR mc_skin_color__cache[26]
#define EDITOR_MARKED_COLOR mc_skin_color__cache[27]
#define EDITOR_WHITESPACE_COLOR mc_skin_color__cache[28]
/* color of left 8 char status per line */
#define LINE_STATE_COLOR mc_skin_color__cache[29]
#define MC_SKIN_COLOR_CACHE_COUNT 30
/*** enums ***************************************************************************************/
/*** structures declarations (and typedefs of structures)*****************************************/
typedef struct mc_skin_struct {
gchar *name;
gchar *description;
mc_config_t *config;
GHashTable *colors;
} mc_skin_t;
/*** global variables defined in .c file *********************************************************/
extern int mc_skin_color__cache[];
extern mc_skin_t mc_skin__default;
/*** declarations of public functions ************************************************************/
void mc_skin_init (void);
void mc_skin_deinit (void);
int mc_skin_color_get (const gchar *, const gchar *);
void mc_skin_lines_parse_ini_file (mc_skin_t *);
#endif

View File

@ -41,7 +41,7 @@
#include "global.h"
#include "../src/tty/tty.h"
#include "../src/tty/color.h"
#include "../src/skin/skin.h"
#include "../src/tty/mouse.h"
#include "../src/tty/key.h"

View File

@ -7,12 +7,12 @@ if USE_SCREEN_SLANG
tty-slang.c tty-slang.h
else
TTY_SCREEN_SRC = \
color-ncurses.c color-ncurses.h \
color-ncurses.c \
tty-ncurses.c tty-ncurses.h
endif
TTY_SRC = \
color-internal.c color-internal.h\
color-internal.c color-internal.h \
color.c color.h \
key.c key.h keyxdef.c \
mouse.c mouse.h \

View File

@ -4,6 +4,7 @@
Written by:
Andrew Borodin <aborodin@vmail.ru>, 2009.
Slava Zanko <slavazanko@gmail.com>, 2009.
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
@ -25,12 +26,27 @@
#include <config.h>
#include <sys/types.h> /* size_t */
#include <string.h> /* strcmp */
#include "../../src/tty/color.h" /* colors and attributes */
#include "../../src/tty/color-internal.h"
struct color_table_s const color_table [] = {
/*** global variables ****************************************************************************/
gboolean mc_tty_color_disable;
/*** file scope macro definitions ****************************************************************/
/*** file scope type declarations ****************************************************************/
typedef struct mc_tty_color_table_struct {
const char *name;
int value;
} mc_tty_color_table_t;
/*** file scope variables ************************************************************************/
mc_tty_color_table_t const color_table[] = {
{ "black", COLOR_BLACK },
{ "gray", COLOR_BLACK | A_BOLD },
{ "red", COLOR_RED },
@ -47,63 +63,46 @@ struct color_table_s const color_table [] = {
{ "brightcyan", COLOR_CYAN | A_BOLD },
{ "lightgray", COLOR_WHITE },
{ "white", COLOR_WHITE | A_BOLD },
{ "default", 0 } /* default color of the terminal */
{ "default", -1 }, /* default color of the terminal */
/* special colors */
{ "A_REVERSE", SPEC_A_REVERSE },
{ "A_BOLD", SPEC_A_BOLD},
{ "A_BOLD_REVERSE", SPEC_A_BOLD_REVERSE },
{ "A_UNDERLINE", SPEC_A_UNDERLINE },
/* End of list */
{ NULL, 0}
};
struct colorpair color_map [] = {
{ "normal=", 0, 0 }, /* normal */ /* 1 */
{ "selected=", 0, 0 }, /* selected */
{ "marked=", 0, 0 }, /* marked */
{ "markselect=", 0, 0 }, /* marked/selected */
{ "errors=", 0, 0 }, /* errors */
{ "menu=", 0, 0 }, /* menu entry */
{ "reverse=", 0, 0 }, /* reverse */
/*** file scope functions ************************************************************************/
/* --------------------------------------------------------------------------------------------- */
/* Dialog colors */
{ "dnormal=", 0, 0 }, /* Dialog normal */ /* 8 */
{ "dfocus=", 0, 0 }, /* Dialog focused */
{ "dhotnormal=", 0, 0 }, /* Dialog normal/hot */
{ "dhotfocus=", 0, 0 }, /* Dialog focused/hot */
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */
{ "viewunderline=", 0, 0 }, /* _\b? sequence in view, underline in editor */
{ "menusel=", 0, 0 }, /* Menu selected color */ /* 13 */
{ "menuhot=", 0, 0 }, /* Color for menu hotkeys */
{ "menuhotsel=", 0, 0 }, /* Menu hotkeys/selected entry */
{ "helpnormal=", 0, 0 }, /* Help normal */ /* 16 */
{ "helpitalic=", 0, 0 }, /* Italic in help */
{ "helpbold=", 0, 0 }, /* Bold in help */
{ "helplink=", 0, 0 }, /* Not selected hyperlink */
{ "helpslink=", 0, 0 }, /* Selected hyperlink */
{ "gauge=", 0, 0 }, /* Color of the progress bar (percentage) *//* 21 */
{ "input=", 0, 0 },
{ 0, 0, 0 }, /* not usable (DEFAULT_COLOR_INDEX) *//* 23 */
{ 0, 0, 0 }, /* unused */
{ 0, 0, 0 }, /* not usable (A_REVERSE) */
{ 0, 0, 0 }, /* not usable (A_REVERSE_BOLD) */
/* editor colors start at 27 */
{ "editnormal=", 0, 0 }, /* normal */ /* 27 */
{ "editbold=", 0, 0 }, /* search->found */
{ "editmarked=", 0, 0 }, /* marked/selected */
{ "editwhitespace=", 0, 0 }, /* whitespace */
{ "editlinestate=", 0, 0 }, /* line number bar*/
/* error dialog colors start at 32 */
{ "errdhotnormal=", 0, 0 }, /* Error dialog normal/hot */ /* 32 */
{ "errdhotfocus=", 0, 0 }, /* Error dialog focused/hot */
};
size_t
color_table_len (void)
const char *
tty_color_get_valid_name (const char *color_name)
{
return sizeof (color_table)/sizeof(color_table [0]);
int i;
if (color_name != NULL)
for (i = 0; color_table[i].name != NULL; i++)
if (strcmp (color_name, color_table[i].name) == 0)
return color_table[i].name;
return NULL;
}
size_t
color_map_len (void)
/* --------------------------------------------------------------------------------------------- */
int
tty_color_get_index_by_name (const char *color_name)
{
return sizeof (color_map)/sizeof(color_map [0]);
int i;
if (color_name != NULL)
for (i = 0; color_table[i].name != NULL; i++)
if (strcmp (color_name, color_table[i].name) == 0)
return color_table[i].value;
return -1;
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -17,88 +17,30 @@
#endif /* HAVE_SLANG */
extern gboolean use_colors;
extern gboolean mc_tty_color_disable;
struct color_table_s {
const char *name;
int value;
};
typedef struct mc_color_pair_struct {
const char *cfg;
const char *cbg;
int ifg;
int ibg;
int pair_index;
gboolean is_temp;
} tty_color_pair_t;
extern const struct color_table_s color_table [];
typedef enum {
SPEC_A_REVERSE = -100,
SPEC_A_BOLD = -101,
SPEC_A_BOLD_REVERSE = -102,
SPEC_A_UNDERLINE = -103
} tty_special_color_t;
#ifdef HAVE_SLANG
# define CTYPE const char *
#else
# define CTYPE int
#endif /* HAVE_SLANG */
const char *tty_color_get_valid_name (const char *);
int tty_color_get_index_by_name (const char *);
struct colorpair {
const char *name; /* Name of the entry */
CTYPE fg; /* foreground color */
CTYPE bg; /* background color */
};
void tty_color_init_lib (gboolean, gboolean);
void tty_color_deinit_lib (void);
extern struct colorpair color_map [];
#ifdef HAVE_SLANG
# define color_value(i) color_table [i].name
# define color_name(i) color_table [i].name
# define color_map_fg(n) color_map [n].fg
# define color_map_bg(n) color_map [n].bg
#else
# define color_value(i) color_table [i].value
# define color_name(i) color_table [i].name
# define color_map_fg(n) (color_map [n].fg & COLOR_WHITE)
# define color_map_bg(n) (color_map [n].bg & COLOR_WHITE)
#endif /* HAVE_SLANG */
static const char default_colors[] = {
"normal=lightgray,blue:"
"selected=black,cyan:"
"marked=yellow,blue:"
"markselect=yellow,cyan:"
"errors=white,red:"
"menu=white,cyan:"
"reverse=black,lightgray:"
"dnormal=black,lightgray:"
"dfocus=black,cyan:"
"dhotnormal=blue,lightgray:"
"dhotfocus=blue,cyan:"
"viewunderline=brightred,blue:"
"menuhot=yellow,cyan:"
"menusel=white,black:"
"menuhotsel=yellow,black:"
"helpnormal=black,lightgray:"
"helpitalic=red,lightgray:"
"helpbold=blue,lightgray:"
"helplink=black,cyan:"
"helpslink=yellow,blue:"
"gauge=white,black:"
"input=black,cyan:"
"editnormal=lightgray,blue:"
"editbold=yellow,blue:"
"editmarked=black,cyan:"
"editwhitespace=brightblue,blue:"
"editlinestate=white,cyan:"
"errdhotnormal=yellow,red:"
"errdhotfocus=yellow,lightgray"
};
struct colors_avail {
struct colors_avail *next;
char *fg, *bg;
int index;
};
extern struct colors_avail c;
extern int max_index;
size_t color_table_len (void);
size_t color_map_len (void);
void configure_colors (void);
void get_color (const char *cpp, CTYPE *colp);
int alloc_color_pair (CTYPE foreground, CTYPE background);
void tty_color_try_alloc_pair_lib (tty_color_pair_t *);
#endif /* MC_COLOR_INTERNAL_H */

View File

@ -28,7 +28,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h> /* size_t*/
#include <sys/types.h> /* size_t */
#include "../../src/global.h"
@ -36,110 +36,171 @@
#include "../../src/tty/color.h" /* variables */
#include "../../src/tty/color-internal.h"
int attr_pairs [MAX_PAIRS];
/*** global variables ****************************************************************************/
/*** file scope macro definitions ****************************************************************/
/*** file scope type declarations ****************************************************************/
/*** file scope variables ************************************************************************/
static GHashTable *mc_tty_color_color_pair_attrs = NULL;
/*** file scope functions ************************************************************************/
/* --------------------------------------------------------------------------------------------- */
static inline void
mc_tty_color_attr_destroy_cb (gpointer data)
{
g_free (data);
}
/* --------------------------------------------------------------------------------------------- */
static int
mc_tty_color_save_attr_lib (int color_pair, int color_attr)
{
int *attr, *key;
attr = g_new0 (int, 1);
if (attr == NULL)
return color_attr;
key = g_new0 (int, 1);
if (key == NULL) {
g_free (attr);
return color_attr;
}
memcpy (key, &color_pair, sizeof (int));
if (color_attr != -1)
*attr = color_attr & (A_BOLD | A_REVERSE | A_UNDERLINE);
g_hash_table_replace (mc_tty_color_color_pair_attrs, (gpointer) key, (gpointer) attr);
return color_attr & (~(*attr));
}
/* --------------------------------------------------------------------------------------------- */
static int
color_get_attr (int color_pair)
{
int *fnd;
if (mc_tty_color_color_pair_attrs == NULL)
return 0;
fnd = (int *) g_hash_table_lookup (mc_tty_color_color_pair_attrs, (gpointer) & color_pair);
return (fnd != NULL) ? *fnd : 0;
}
/* --------------------------------------------------------------------------------------------- */
static void
mc_tty_color_pair_init_special (tty_color_pair_t * mc_color_pair,
int fg1, int bg1, int fg2, int bg2, int mask)
{
if (has_colors ()) {
if (!mc_tty_color_disable) {
init_pair (mc_color_pair->pair_index,
mc_tty_color_save_attr_lib (mc_color_pair->pair_index, fg1 | mask), bg1);
} else {
init_pair (mc_color_pair->pair_index,
mc_tty_color_save_attr_lib (mc_color_pair->pair_index, fg2 | mask), bg2);
}
}
#if 0
else {
SLtt_set_mono (mc_color_pair->pair_index, NULL, mask);
}
#endif
}
/* --------------------------------------------------------------------------------------------- */
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */
void
tty_init_colors (gboolean disable, gboolean force)
tty_color_init_lib (gboolean disable, gboolean force)
{
(void) force;
if (has_colors () && !disable) {
const size_t map_len = color_map_len ();
size_t i;
use_colors = TRUE;
start_color ();
use_default_colors ();
configure_colors ();
if (map_len > MAX_PAIRS) {
/* This message should only be seen by the developers */
fprintf (stderr,
"Too many defined colors, resize MAX_PAIRS on color.c");
exit (1);
}
/* Use default terminal colors */
mc_init_pair (DEFAULT_COLOR_INDEX, -1, -1);
for (i = 0; i < map_len; i++)
if (color_map [i].name != NULL) {
mc_init_pair (i + 1, color_map_fg (i), color_map_bg (i));
/*
* ncurses doesn't remember bold attribute in the color pairs,
* so we should keep track of it in a separate array.
*/
attr_pairs [i + 1] = color_map [i].fg & A_BOLD;
}
}
mc_tty_color_color_pair_attrs = g_hash_table_new_full
(g_int_hash, g_int_equal, mc_tty_color_attr_destroy_cb, mc_tty_color_attr_destroy_cb);
}
/* Functions necessary to implement syntax highlighting */
/* --------------------------------------------------------------------------------------------- */
void
mc_init_pair (int index, CTYPE foreground, CTYPE background)
tty_color_deinit_lib (void)
{
init_pair (index, foreground, background == 0 ? -1 : background);
if (index > max_index)
max_index = index;
g_hash_table_destroy (mc_tty_color_color_pair_attrs);
mc_tty_color_color_pair_attrs = NULL;
}
int
tty_try_alloc_color_pair (const char *fg, const char *bg)
{
int fg_index, bg_index;
int bold_attr;
struct colors_avail *p = &c;
/* --------------------------------------------------------------------------------------------- */
c.index = EDITOR_NORMAL_COLOR_INDEX;
for (;;) {
if (((fg && p->fg) ? !strcmp (fg, p->fg) : fg == p->fg) != 0
&& ((bg && p->bg) ? !strcmp (bg, p->bg) : bg == p->bg) != 0)
return p->index;
if (!p->next)
void
tty_color_try_alloc_pair_lib (tty_color_pair_t * mc_color_pair)
{
if (mc_color_pair->ifg <= (int) SPEC_A_REVERSE) {
switch (mc_color_pair->ifg) {
case SPEC_A_REVERSE:
mc_tty_color_pair_init_special (mc_color_pair,
COLOR_BLACK, COLOR_WHITE,
COLOR_BLACK, COLOR_WHITE | A_BOLD, A_REVERSE);
break;
case SPEC_A_BOLD:
mc_tty_color_pair_init_special (mc_color_pair,
COLOR_WHITE, COLOR_BLACK,
COLOR_WHITE, COLOR_BLACK, A_BOLD);
break;
case SPEC_A_BOLD_REVERSE:
mc_tty_color_pair_init_special (mc_color_pair,
COLOR_WHITE, COLOR_WHITE,
COLOR_WHITE, COLOR_WHITE, A_BOLD | A_REVERSE);
break;
case SPEC_A_UNDERLINE:
mc_tty_color_pair_init_special (mc_color_pair,
COLOR_WHITE, COLOR_BLACK,
COLOR_WHITE, COLOR_BLACK, A_UNDERLINE);
break;
p = p->next;
}
p->next = g_new (struct colors_avail, 1);
p = p->next;
p->next = 0;
p->fg = fg ? g_strdup (fg) : 0;
p->bg = bg ? g_strdup (bg) : 0;
if (!fg)
/* Index in color_map array = COLOR_INDEX - 1 */
fg_index = color_map[EDITOR_NORMAL_COLOR_INDEX - 1].fg;
else
get_color (fg, &fg_index);
if (!bg)
bg_index = color_map[EDITOR_NORMAL_COLOR_INDEX - 1].bg;
else
get_color (bg, &bg_index);
bold_attr = fg_index & A_BOLD;
fg_index = fg_index & COLOR_WHITE;
bg_index = bg_index & COLOR_WHITE;
p->index = alloc_color_pair (fg_index, bg_index);
attr_pairs [p->index] = bold_attr;
return p->index;
} else {
init_pair (mc_color_pair->pair_index,
mc_tty_color_save_attr_lib (mc_color_pair->pair_index,
mc_color_pair->ifg) & COLOR_WHITE,
mc_color_pair->ibg & COLOR_WHITE);
}
}
/* --------------------------------------------------------------------------------------------- */
void
tty_setcolor (int color)
{
attrset (color);
attrset (COLOR_PAIR (color) | color_get_attr (color));
}
/* --------------------------------------------------------------------------------------------- */
void
tty_lowlevel_setcolor (int color)
{
attrset (MY_COLOR_PAIR (color));
attrset (COLOR_PAIR (color) | color_get_attr (color));
}
/* --------------------------------------------------------------------------------------------- */
void
tty_set_normal_attrs (void)
{
standend ();
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -1,23 +0,0 @@
/** \file color-ncurses.h
* \brief Header: NCurses-specific color setup
*/
#ifndef MC_COLOR_NCURSES_H
#define MC_COLOR_NCURSES_H
#include "../../src/tty/tty-ncurses.h" /* NCurses headers */
gboolean tty_use_colors ();
#define MAX_PAIRS 64
extern int attr_pairs [MAX_PAIRS];
#define MY_COLOR_PAIR(x) (COLOR_PAIR (x) | attr_pairs [x])
#define IF_COLOR(co, bw) (tty_use_colors () ? MY_COLOR_PAIR (co) : bw)
#define MARKED_SELECTED_COLOR IF_COLOR (4, A_REVERSE | A_BOLD)
void mc_init_pair (int index, int foreground, int background);
#endif /* MC_COLOR_NCURSES_H */

View File

@ -41,11 +41,12 @@
static int
has_colors (gboolean disable, gboolean force)
{
mc_tty_color_disable = disable;
if (force || (getenv ("COLORTERM") != NULL))
SLtt_Use_Ansi_Colors = 1;
/* We want to allow overwriding */
if (!disable) {
if (!mc_tty_color_disable) {
const char *terminal = getenv ("TERM");
const size_t len = strlen (terminal);
@ -72,95 +73,70 @@ has_colors (gboolean disable, gboolean force)
cts++;
}
}
/* Setup emulated colors */
if (SLtt_Use_Ansi_Colors != 0) {
if (!disable) {
mc_init_pair (A_REVERSE, "black", "white");
mc_init_pair (A_BOLD, "white", "black");
} else {
mc_init_pair (A_REVERSE, "black", "lightgray");
mc_init_pair (A_BOLD, "white", "black");
mc_init_pair (A_BOLD_REVERSE, "white", "lightgray");
}
} else {
SLtt_set_mono (A_BOLD, NULL, SLTT_BOLD_MASK);
SLtt_set_mono (A_REVERSE, NULL, SLTT_REV_MASK);
SLtt_set_mono (A_BOLD | A_REVERSE, NULL, SLTT_BOLD_MASK | SLTT_REV_MASK);
}
return SLtt_Use_Ansi_Colors;
}
static void
mc_tty_color_pair_init_special (tty_color_pair_t * mc_color_pair,
const char *fg1, const char *bg1,
const char *fg2, const char *bg2, SLtt_Char_Type mask)
{
if (SLtt_Use_Ansi_Colors != 0) {
if (!mc_tty_color_disable) {
SLtt_set_color (mc_color_pair->pair_index, (char *) "", (char *) fg1, (char *) bg1);
} else {
SLtt_set_color (mc_color_pair->pair_index, (char *) "", (char *) fg2, (char *) bg2);
}
} else {
SLtt_set_mono (mc_color_pair->pair_index, NULL, mask);
}
}
void
tty_init_colors (gboolean disable, gboolean force)
tty_color_init_lib (gboolean disable, gboolean force)
{
/* FIXME: if S-Lang is used, has_colors() must be called regardless
of whether we are interested in its result */
if (has_colors (disable, force) && !disable) {
const size_t map_len = color_map_len ();
size_t i;
use_colors = TRUE;
configure_colors ();
/*
* We are relying on undocumented feature of
* S-Lang to make COLOR_PAIR(DEFAULT_COLOR_INDEX)
* the default fg/bg of the terminal.
* Hopefully, future versions of S-Lang will
* document this feature.
*/
SLtt_set_color (DEFAULT_COLOR_INDEX, NULL, (char *) "default", (char *) "default");
for (i = 0; i < map_len; i++)
if (color_map [i].name != NULL)
mc_init_pair (i + 1, color_map_fg(i), color_map_bg(i));
}
}
/* Functions necessary to implement syntax highlighting */
void
mc_init_pair (int index, CTYPE foreground, CTYPE background)
tty_color_deinit_lib (void)
{
if (!background)
background = "default";
if (!foreground)
foreground = "default";
SLtt_set_color (index, (char *) "", (char *) foreground, (char *) background);
if (index > max_index)
max_index = index;
}
int
tty_try_alloc_color_pair (const char *fg, const char *bg)
void
tty_color_try_alloc_pair_lib (tty_color_pair_t * mc_color_pair)
{
struct colors_avail *p = &c;
c.index = EDITOR_NORMAL_COLOR_INDEX;
for (;;) {
if (((fg && p->fg) ? (strcmp (fg, p->fg) == 0) : (fg == p->fg)) != 0
&& ((bg && p->bg) ? (strcmp (bg, p->bg) == 0) : (bg == p->bg)) != 0)
return p->index;
if (p->next == NULL)
const char *fg, *bg;
if (mc_color_pair->ifg <= (int) SPEC_A_REVERSE) {
switch (mc_color_pair->ifg) {
case SPEC_A_REVERSE:
mc_tty_color_pair_init_special (mc_color_pair,
"black", "white", "black", "lightgray", SLTT_REV_MASK);
break;
case SPEC_A_BOLD:
mc_tty_color_pair_init_special (mc_color_pair,
"white", "black", "white", "black", SLTT_BOLD_MASK);
break;
case SPEC_A_BOLD_REVERSE:
mc_tty_color_pair_init_special (mc_color_pair,
"white", "white",
"white", "white", SLTT_BOLD_MASK | SLTT_REV_MASK);
break;
case SPEC_A_UNDERLINE:
mc_tty_color_pair_init_special (mc_color_pair,
"white", "black", "white", "black", SLTT_ULINE_MASK);
break;
p = p->next;
}
p->next = g_new (struct colors_avail, 1);
p = p->next;
p->next = NULL;
p->fg = fg ? g_strdup (fg) : NULL;
p->bg = bg ? g_strdup (bg) : NULL;
if (fg == NULL)
/* Index in color_map array = COLOR_INDEX - 1 */
fg = color_map[EDITOR_NORMAL_COLOR_INDEX - 1].fg;
if (bg == NULL)
bg = color_map[EDITOR_NORMAL_COLOR_INDEX - 1].bg;
p->index = alloc_color_pair (fg, bg);
return p->index;
} else {
fg = (mc_color_pair->cfg) ? mc_color_pair->cfg : "default";
bg = (mc_color_pair->cbg) ? mc_color_pair->cbg : "default";
SLtt_set_color (mc_color_pair->pair_index, (char *) "", (char *) fg, (char *) bg);
}
}
void
@ -173,7 +149,9 @@ tty_setcolor (int color)
SLsmg_set_color (A_BOLD);
else
SLsmg_set_color ((color & (~A_BOLD)) + 8);
} else
} else if (color == A_REVERSE)
SLsmg_set_color (A_REVERSE);
else
SLsmg_set_color (color);
}

View File

@ -31,14 +31,4 @@ enum {
# define A_NORMAL 0x00
#endif
gboolean tty_use_colors ();
#define COLOR_PAIR(x) x
#define IF_COLOR(co, bw) (tty_use_colors () ? COLOR_PAIR (co) : bw)
#define MARKED_SELECTED_COLOR IF_COLOR (4, (SLtt_Use_Ansi_Colors ? A_BOLD_REVERSE : A_REVERSE | A_BOLD))
void mc_init_pair (int index, const char *foreground, const char *background);
#endif /* MC_COLOR_SLANG_H */

View File

@ -1,9 +1,12 @@
/* Color setup
/* Color setup.
Interface functions.
Copyright (C) 1994, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
2007, 2008, 2009 Free Software Foundation, Inc.
Written by:
Andrew Borodin <aborodin@vmail.ru>, 2009.
Slava Zanko <slavazanko@gmail.com>, 2009.
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
@ -34,119 +37,219 @@
#include "../../src/tty/tty.h"
#include "../../src/tty/color.h"
#include "../../src/tty/color-internal.h"
#include "../../src/setup.h" /* setup_color_string, term_color_string */
/*** global variables ****************************************************************************/
char *command_line_colors = NULL;
static char *tty_color_defaults__fg = NULL;
static char *tty_color_defaults__bg = NULL;
/* Set if we are actually using colors */
gboolean use_colors = FALSE;
struct colors_avail c;
int max_index = 0;
/*** file scope macro definitions ****************************************************************/
void
get_color (const char *cpp, CTYPE *colp)
/*** file scope type declarations ****************************************************************/
/*** file scope variables ************************************************************************/
static GHashTable *mc_tty_color__hashtable = NULL;
/*** file scope functions ************************************************************************/
/* --------------------------------------------------------------------------------------------- */
static inline void
color_hash_destroy_key (gpointer data)
{
const size_t table_len = color_table_len ();
size_t i;
for (i = 0; i < table_len; i++)
if (strcmp (cpp, color_name (i)) == 0) {
*colp = color_value (i);
break;
}
g_free (data);
}
/* --------------------------------------------------------------------------------------------- */
static void
configure_colors_string (const char *the_color_string)
color_hash_destroy_value (gpointer data)
{
const size_t map_len = color_map_len ();
size_t i;
char **color_strings, **p;
if (!the_color_string)
return;
color_strings = g_strsplit (the_color_string, ":", -1);
p = color_strings;
while ((p != NULL) && (*p != NULL)) {
char **cfb; /* color, fore, back */
/* cfb[0] - entry name
* cfb[1] - fore color
* cfb[2] - back color
*/
char *e;
cfb = g_strsplit_set (*p, "=,", 3);
p++;
if (cfb[0] == NULL) {
g_strfreev (cfb);
continue;
}
/* append '=' to the entry name */
e = g_strdup_printf ("%s=", cfb[0]);
g_free (cfb[0]);
cfb[0] = e;
for (i = 0; i < map_len; i++)
if (color_map [i].name != NULL) {
size_t klen = strlen (color_map [i].name);
if (strncmp (cfb[0], color_map [i].name, klen) == 0) {
if ((cfb[1] != NULL) && (*cfb[1] != '\0'))
get_color (cfb[1], &color_map [i].fg);
if ((cfb[2] != NULL) && (*cfb[2] != '\0'))
get_color (cfb[2], &color_map [i].bg);
break;
}
}
g_strfreev (cfb);
}
g_strfreev (color_strings);
tty_color_pair_t *mc_color_pair = (tty_color_pair_t *) data;
g_free (mc_color_pair);
}
/* --------------------------------------------------------------------------------------------- */
static gboolean
tty_color_free_condition_cb (gpointer key, gpointer value, gpointer user_data)
{
gboolean is_temp_color;
tty_color_pair_t *mc_color_pair;
(void) key;
is_temp_color = (gboolean) user_data;
mc_color_pair = (tty_color_pair_t *) value;
return (mc_color_pair->is_temp == is_temp_color);
}
/* --------------------------------------------------------------------------------------------- */
static void
tty_color_free_all (gboolean is_temp_color)
{
g_hash_table_foreach_remove (mc_tty_color__hashtable, tty_color_free_condition_cb,
(gpointer) is_temp_color);
}
/* --------------------------------------------------------------------------------------------- */
static gboolean
tty_color_get_next_cpn_cb (gpointer key, gpointer value, gpointer user_data)
{
int cp;
tty_color_pair_t *mc_color_pair;
(void) key;
cp = (int) user_data;
mc_color_pair = (tty_color_pair_t *) value;
if (cp == mc_color_pair->pair_index)
return TRUE;
return FALSE;
}
/* --------------------------------------------------------------------------------------------- */
static int
tty_color_get_next__color_pair_number ()
{
int cp_count = g_hash_table_size (mc_tty_color__hashtable);
int cp = 0;
for (cp = 0; cp < cp_count; cp++) {
if (g_hash_table_find (mc_tty_color__hashtable, tty_color_get_next_cpn_cb, (gpointer) cp) ==
NULL)
return cp;
}
return cp;
}
/* --------------------------------------------------------------------------------------------- */
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */
void
configure_colors (void)
tty_init_colors (gboolean disable, gboolean force)
{
configure_colors_string (default_colors);
configure_colors_string (setup_color_string);
configure_colors_string (term_color_string);
configure_colors_string (getenv ("MC_COLOR_TABLE"));
configure_colors_string (command_line_colors);
tty_color_init_lib (disable, force);
mc_tty_color__hashtable = g_hash_table_new_full (g_str_hash, g_str_equal,
color_hash_destroy_key,
color_hash_destroy_value);
}
int
alloc_color_pair (CTYPE foreground, CTYPE background)
{
mc_init_pair (++max_index, foreground, background);
return max_index;
}
/* --------------------------------------------------------------------------------------------- */
void
tty_colors_done (void)
{
struct colors_avail *p, *next;
tty_color_deinit_lib ();
g_free (tty_color_defaults__fg);
g_free (tty_color_defaults__bg);
for (p = c.next; p != NULL; p = next) {
next = p->next;
g_free (p->fg);
g_free (p->bg);
g_free (p);
}
c.next = NULL;
g_hash_table_destroy (mc_tty_color__hashtable);
}
/* --------------------------------------------------------------------------------------------- */
gboolean
tty_use_colors (void)
{
return use_colors;
}
/* --------------------------------------------------------------------------------------------- */
int
tty_try_alloc_color_pair2 (const char *fg, const char *bg, gboolean is_temp_color)
{
gchar *color_pair;
tty_color_pair_t *mc_color_pair;
const char *c_fg, *c_bg;
if (fg == NULL)
fg = tty_color_defaults__fg;
if (bg == NULL) {
bg = tty_color_defaults__bg;
}
c_fg = tty_color_get_valid_name (fg);
c_bg = tty_color_get_valid_name (bg);
color_pair = g_strdup_printf ("%s.%s", c_fg, c_bg);
if (color_pair == NULL)
return 0;
mc_color_pair =
(tty_color_pair_t *) g_hash_table_lookup (mc_tty_color__hashtable, (gpointer) color_pair);
if (mc_color_pair != NULL) {
g_free (color_pair);
return mc_color_pair->pair_index;
}
mc_color_pair = g_new0 (tty_color_pair_t, 1);
if (mc_color_pair == NULL) {
g_free (color_pair);
return 0;
}
mc_color_pair->is_temp = is_temp_color;
mc_color_pair->cfg = c_fg;
mc_color_pair->cbg = c_bg;
mc_color_pair->ifg = tty_color_get_index_by_name (c_fg);
mc_color_pair->ibg = tty_color_get_index_by_name (c_bg);
mc_color_pair->pair_index = tty_color_get_next__color_pair_number ();
tty_color_try_alloc_pair_lib (mc_color_pair);
g_hash_table_insert (mc_tty_color__hashtable, (gpointer) color_pair, (gpointer) mc_color_pair);
return mc_color_pair->pair_index;
}
/* --------------------------------------------------------------------------------------------- */
int
tty_try_alloc_color_pair (const char *fg, const char *bg)
{
return tty_try_alloc_color_pair2 (fg, bg, TRUE);
}
/* --------------------------------------------------------------------------------------------- */
void
tty_color_free_all_tmp (void)
{
tty_color_free_all (TRUE);
}
/* --------------------------------------------------------------------------------------------- */
void
tty_color_free_all_non_tmp (void)
{
tty_color_free_all (FALSE);
}
/* --------------------------------------------------------------------------------------------- */
void
tty_color_set_defaults (const char *fgcolor, const char *bgcolor)
{
g_free (tty_color_defaults__fg);
g_free (tty_color_defaults__fg);
tty_color_defaults__fg = (fgcolor != NULL) ? g_strdup (fgcolor) : NULL;
tty_color_defaults__bg = (bgcolor != NULL) ? g_strdup (bgcolor) : NULL;
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -1,6 +1,12 @@
/** \file color.h
* \brief Header: color setup
*
* PLEASE FORGOT ABOUT tty/color.h!
* Use skin engine for getting needed color pairs.
*
* edit/syntax.c may use this file directly, I'm agree. :)
*
*/
#ifndef MC_COLOR_H
@ -11,71 +17,27 @@
#ifdef HAVE_SLANG
# include "../../src/tty/color-slang.h"
#else
# include "../../src/tty/color-ncurses.h"
# include "../../src/tty/tty-ncurses.h"
#endif
/* Beware! When using Slang with color, not all the indexes are free.
See color-slang.h (A_*) */
#define NORMAL_COLOR IF_COLOR (1, 0)
#define SELECTED_COLOR IF_COLOR (2, A_REVERSE)
#define MARKED_COLOR IF_COLOR (3, A_BOLD)
/* MARKED_SELECTED_COLOR is screen library specific */
#define ERROR_COLOR IF_COLOR (5, A_BOLD)
#define MENU_ENTRY_COLOR IF_COLOR (6, A_REVERSE)
#define REVERSE_COLOR IF_COLOR (7, A_REVERSE)
/* Dialog colors */
#define COLOR_NORMAL IF_COLOR (8, A_REVERSE)
#define COLOR_FOCUS IF_COLOR (9, A_BOLD)
#define COLOR_HOT_NORMAL IF_COLOR (10, 0)
#define COLOR_HOT_FOCUS IF_COLOR (11, 0)
#define VIEW_UNDERLINED_COLOR IF_COLOR (12, A_UNDERLINE)
#define MENU_SELECTED_COLOR IF_COLOR (13, A_BOLD)
#define MENU_HOT_COLOR IF_COLOR (14, 0)
#define MENU_HOTSEL_COLOR IF_COLOR (15, 0)
#define HELP_NORMAL_COLOR IF_COLOR (16, A_REVERSE)
#define HELP_ITALIC_COLOR IF_COLOR (17, A_REVERSE)
#define HELP_BOLD_COLOR IF_COLOR (18, A_REVERSE)
#define HELP_LINK_COLOR IF_COLOR (19, 0)
#define HELP_SLINK_COLOR IF_COLOR (20, A_BOLD)
/*
* This should be selectable independently. Default has to be black background
* foreground does not matter at all.
*/
#define GAUGE_COLOR IF_COLOR (21, 0)
#define INPUT_COLOR IF_COLOR (22, 0)
/* For the default color any unused index may be chosen. */
#define DEFAULT_COLOR_INDEX 23
#define DEFAULT_COLOR IF_COLOR (DEFAULT_COLOR_INDEX, 0)
/*
* editor colors - only 4 for normal, search->found, select, and whitespace
* respectively
* Last is defined to view color.
*/
#define EDITOR_NORMAL_COLOR_INDEX 27
#define EDITOR_NORMAL_COLOR IF_COLOR (EDITOR_NORMAL_COLOR_INDEX, 0)
#define EDITOR_BOLD_COLOR IF_COLOR (28, A_BOLD)
#define EDITOR_MARKED_COLOR IF_COLOR (29, A_REVERSE)
#define EDITOR_WHITESPACE_COLOR IF_COLOR (30, 0 /* irrelevant */)
/* color of left 8 char status per line */
#define LINE_STATE_COLOR IF_COLOR (31, 0)
/* Error dialog colors */
#define ERROR_HOT_NORMAL IF_COLOR (32, 0)
#define ERROR_HOT_FOCUS IF_COLOR (43, 0)
extern char *command_line_colors;
void tty_init_colors (gboolean disable, gboolean force);
void tty_colors_done (void);
gboolean tty_use_colors (void);
int tty_try_alloc_color_pair (const char *fg, const char *bg);
int tty_try_alloc_color_pair (const char *, const char *);
int tty_try_alloc_color_pair2 (const char *, const char *, gboolean);
void tty_color_free_all_tmp (void);
void tty_color_free_all_non_tmp (void);
void tty_setcolor (int color);
void tty_lowlevel_setcolor (int color);
void tty_set_normal_attrs (void);
void tty_color_set_defaults (const char *, const char *);
#define ALLOC_COLOR_PAIR_INDEX 1
#endif /* MC_COLOR_H */

View File

@ -93,79 +93,79 @@ int use_8th_bit_as_meta = 0;
* We use this to allow users to define alternate definitions for
* certain keys that may be missing from the terminal database
*/
key_code_name_t key_name_conv_tab [] = {
key_code_name_t key_name_conv_tab[] = {
/* KEY_F(0) is not here, since we are mapping it to f10, so there is no reason
to define f0 as well. Also, it makes Learn keys a bunch of problems :( */
{ KEY_F(1), "f1", N_("Function key 1") },
{ KEY_F(2), "f2", N_("Function key 2") },
{ KEY_F(3), "f3", N_("Function key 3") },
{ KEY_F(4), "f4", N_("Function key 4") },
{ KEY_F(5), "f5", N_("Function key 5") },
{ KEY_F(6), "f6", N_("Function key 6") },
{ KEY_F(7), "f7", N_("Function key 7") },
{ KEY_F(8), "f8", N_("Function key 8") },
{ KEY_F(9), "f9", N_("Function key 9") },
{ KEY_F(10), "f10", N_("Function key 10") },
{ KEY_F(11), "f11", N_("Function key 11") },
{ KEY_F(12), "f12", N_("Function key 12") },
{ KEY_F(13), "f13", N_("Function key 13") },
{ KEY_F(14), "f14", N_("Function key 14") },
{ KEY_F(15), "f15", N_("Function key 15") },
{ KEY_F(16), "f16", N_("Function key 16") },
{ KEY_F(17), "f17", N_("Function key 17") },
{ KEY_F(18), "f18", N_("Function key 18") },
{ KEY_F(19), "f19", N_("Function key 19") },
{ KEY_F(20), "f20", N_("Function key 20") },
{ KEY_BACKSPACE, "bs", N_("Backspace key") },
{ KEY_END, "end", N_("End key") },
{ KEY_UP, "up", N_("Up arrow key") },
{ KEY_DOWN, "down", N_("Down arrow key") },
{ KEY_LEFT, "left", N_("Left arrow key") },
{ KEY_RIGHT, "right", N_("Right arrow key") },
{ KEY_HOME, "home", N_("Home key") },
{ KEY_NPAGE, "pgdn", N_("Page Down key") },
{ KEY_PPAGE, "pgup", N_("Page Up key") },
{ KEY_IC, "ins", N_("Insert key") },
{ KEY_DC, "delete", N_("Delete key") },
{ ALT('\t'), "complete", N_("Completion/M-tab") },
{ KEY_KP_ADD, "kpplus", N_("+ on keypad") },
{ KEY_KP_SUBTRACT,"kpminus", N_("- on keypad") },
{ KEY_KP_MULTIPLY,"kpasterix", N_("* on keypad") },
{KEY_F (1), "f1", N_("Function key 1")},
{KEY_F (2), "f2", N_("Function key 2")},
{KEY_F (3), "f3", N_("Function key 3")},
{KEY_F (4), "f4", N_("Function key 4")},
{KEY_F (5), "f5", N_("Function key 5")},
{KEY_F (6), "f6", N_("Function key 6")},
{KEY_F (7), "f7", N_("Function key 7")},
{KEY_F (8), "f8", N_("Function key 8")},
{KEY_F (9), "f9", N_("Function key 9")},
{KEY_F (10), "f10", N_("Function key 10")},
{KEY_F (11), "f11", N_("Function key 11")},
{KEY_F (12), "f12", N_("Function key 12")},
{KEY_F (13), "f13", N_("Function key 13")},
{KEY_F (14), "f14", N_("Function key 14")},
{KEY_F (15), "f15", N_("Function key 15")},
{KEY_F (16), "f16", N_("Function key 16")},
{KEY_F (17), "f17", N_("Function key 17")},
{KEY_F (18), "f18", N_("Function key 18")},
{KEY_F (19), "f19", N_("Function key 19")},
{KEY_F (20), "f20", N_("Function key 20")},
{KEY_BACKSPACE, "bs", N_("Backspace key")},
{KEY_END, "end", N_("End key")},
{KEY_UP, "up", N_("Up arrow key")},
{KEY_DOWN, "down", N_("Down arrow key")},
{KEY_LEFT, "left", N_("Left arrow key")},
{KEY_RIGHT, "right", N_("Right arrow key")},
{KEY_HOME, "home", N_("Home key")},
{KEY_NPAGE, "pgdn", N_("Page Down key")},
{KEY_PPAGE, "pgup", N_("Page Up key")},
{KEY_IC, "ins", N_("Insert key")},
{KEY_DC, "delete", N_("Delete key")},
{ALT ('\t'), "complete", N_("Completion/M-tab")},
{KEY_KP_ADD, "kpplus", N_("+ on keypad")},
{KEY_KP_SUBTRACT, "kpminus", N_("- on keypad")},
{KEY_KP_MULTIPLY, "kpasterix", N_("* on keypad")},
/* From here on, these won't be shown in Learn keys (no space) */
{ KEY_LEFT, "kpleft", N_("Left arrow keypad") },
{ KEY_RIGHT, "kpright", N_("Right arrow keypad") },
{ KEY_UP, "kpup", N_("Up arrow keypad") },
{ KEY_DOWN, "kpdown", N_("Down arrow keypad") },
{ KEY_HOME, "kphome", N_("Home on keypad") },
{ KEY_END, "kpend", N_("End on keypad") },
{ KEY_NPAGE, "kpnpage", N_("Page Down keypad") },
{ KEY_PPAGE, "kpppage", N_("Page Up keypad") },
{ KEY_IC, "kpinsert", N_("Insert on keypad") },
{ KEY_DC, "kpdelete", N_("Delete on keypad") },
{ (int) '\n', "kpenter", N_("Enter on keypad") },
{ (int) '\n', "enter", N_("Enter on keypad") },
{ (int) '\t', "tab", N_("Tab on keypad") },
{ (int) ' ', "space", N_("Space on keypad") },
{ (int) '/', "kpslash", N_("Slash on keypad") },
{ (int) '#', "kpnumlock", N_("NumLock on keypad") },
{KEY_LEFT, "kpleft", N_("Left arrow keypad")},
{KEY_RIGHT, "kpright", N_("Right arrow keypad")},
{KEY_UP, "kpup", N_("Up arrow keypad")},
{KEY_DOWN, "kpdown", N_("Down arrow keypad")},
{KEY_HOME, "kphome", N_("Home on keypad")},
{KEY_END, "kpend", N_("End on keypad")},
{KEY_NPAGE, "kpnpage", N_("Page Down keypad")},
{KEY_PPAGE, "kpppage", N_("Page Up keypad")},
{KEY_IC, "kpinsert", N_("Insert on keypad")},
{KEY_DC, "kpdelete", N_("Delete on keypad")},
{(int) '\n', "kpenter", N_("Enter on keypad")},
{(int) '\n', "enter", N_("Enter on keypad")},
{(int) '\t', "tab", N_("Tab on keypad")},
{(int) ' ', "space", N_("Space on keypad")},
{(int) '/', "kpslash", N_("Slash on keypad")},
{(int) '#', "kpnumlock", N_("NumLock on keypad")},
/* Alternative label */
{ KEY_BACKSPACE, "backspace", N_("Backspace key") },
{ KEY_IC, "insert", N_("Insert key") },
{ KEY_KP_ADD, "plus", N_("+ on keypad") },
{ KEY_KP_SUBTRACT,"minus", N_("- on keypad") },
{ KEY_KP_MULTIPLY,"asterix", N_("* on keypad") },
{KEY_BACKSPACE, "backspace", N_("Backspace key")},
{KEY_IC, "insert", N_("Insert key")},
{KEY_KP_ADD, "plus", N_("+ on keypad")},
{KEY_KP_SUBTRACT, "minus", N_("- on keypad")},
{KEY_KP_MULTIPLY, "asterix", N_("* on keypad")},
/* meta keys */
{ KEY_M_CTRL, "control", N_("Ctrl") },
{ KEY_M_CTRL, "ctrl", N_("Ctrl") },
{ KEY_M_ALT, "alt", N_("Alt") },
{ KEY_M_ALT, "ralt", N_("Alt") },
{ KEY_M_ALT, "meta", N_("Alt") },
{ KEY_M_SHIFT, "shift", N_("Shift") },
{KEY_M_CTRL, "control", N_("Ctrl")},
{KEY_M_CTRL, "ctrl", N_("Ctrl")},
{KEY_M_ALT, "alt", N_("Alt")},
{KEY_M_ALT, "ralt", N_("Alt")},
{KEY_M_ALT, "meta", N_("Alt")},
{KEY_M_SHIFT, "shift", N_("Shift")},
{ 0, 0, 0 }
{0, 0, 0}
};
@ -219,66 +219,66 @@ typedef int (*ph_pqc_f) (unsigned short, PhCursorInfo_t *);
/*** file scope variables **********************************************/
static key_define_t mc_default_keys [] = {
{ ESC_CHAR, ESC_STR, MCKEY_ESCAPE },
{ ESC_CHAR, ESC_STR ESC_STR, MCKEY_NOACTION },
{ 0, NULL, MCKEY_NOACTION },
static key_define_t mc_default_keys[] = {
{ESC_CHAR, ESC_STR, MCKEY_ESCAPE},
{ESC_CHAR, ESC_STR ESC_STR, MCKEY_NOACTION},
{0, NULL, MCKEY_NOACTION},
};
/* Broken terminfo and termcap databases on xterminals */
static key_define_t xterm_key_defines [] = {
{ KEY_F(1), ESC_STR "OP", MCKEY_NOACTION },
{ KEY_F(2), ESC_STR "OQ", MCKEY_NOACTION },
{ KEY_F(3), ESC_STR "OR", MCKEY_NOACTION },
{ KEY_F(4), ESC_STR "OS", MCKEY_NOACTION },
{ KEY_F(1), ESC_STR "[11~", MCKEY_NOACTION },
{ KEY_F(2), ESC_STR "[12~", MCKEY_NOACTION },
{ KEY_F(3), ESC_STR "[13~", MCKEY_NOACTION },
{ KEY_F(4), ESC_STR "[14~", MCKEY_NOACTION },
{ KEY_F(5), ESC_STR "[15~", MCKEY_NOACTION },
{ KEY_F(6), ESC_STR "[17~", MCKEY_NOACTION },
{ KEY_F(7), ESC_STR "[18~", MCKEY_NOACTION },
{ KEY_F(8), ESC_STR "[19~", MCKEY_NOACTION },
{ KEY_F(9), ESC_STR "[20~", MCKEY_NOACTION },
{ KEY_F(10), ESC_STR "[21~", MCKEY_NOACTION },
static key_define_t xterm_key_defines[] = {
{KEY_F (1), ESC_STR "OP", MCKEY_NOACTION},
{KEY_F (2), ESC_STR "OQ", MCKEY_NOACTION},
{KEY_F (3), ESC_STR "OR", MCKEY_NOACTION},
{KEY_F (4), ESC_STR "OS", MCKEY_NOACTION},
{KEY_F (1), ESC_STR "[11~", MCKEY_NOACTION},
{KEY_F (2), ESC_STR "[12~", MCKEY_NOACTION},
{KEY_F (3), ESC_STR "[13~", MCKEY_NOACTION},
{KEY_F (4), ESC_STR "[14~", MCKEY_NOACTION},
{KEY_F (5), ESC_STR "[15~", MCKEY_NOACTION},
{KEY_F (6), ESC_STR "[17~", MCKEY_NOACTION},
{KEY_F (7), ESC_STR "[18~", MCKEY_NOACTION},
{KEY_F (8), ESC_STR "[19~", MCKEY_NOACTION},
{KEY_F (9), ESC_STR "[20~", MCKEY_NOACTION},
{KEY_F (10), ESC_STR "[21~", MCKEY_NOACTION},
/* old xterm Shift-arrows */
{ KEY_M_SHIFT | KEY_UP, ESC_STR "O2A", MCKEY_NOACTION },
{ KEY_M_SHIFT | KEY_DOWN, ESC_STR "O2B", MCKEY_NOACTION },
{ KEY_M_SHIFT | KEY_RIGHT, ESC_STR "O2C", MCKEY_NOACTION },
{ KEY_M_SHIFT | KEY_LEFT, ESC_STR "O2D", MCKEY_NOACTION },
{KEY_M_SHIFT | KEY_UP, ESC_STR "O2A", MCKEY_NOACTION},
{KEY_M_SHIFT | KEY_DOWN, ESC_STR "O2B", MCKEY_NOACTION},
{KEY_M_SHIFT | KEY_RIGHT, ESC_STR "O2C", MCKEY_NOACTION},
{KEY_M_SHIFT | KEY_LEFT, ESC_STR "O2D", MCKEY_NOACTION},
/* new xterm Shift-arrows */
{ KEY_M_SHIFT | KEY_UP, ESC_STR "[1;2A", MCKEY_NOACTION },
{ KEY_M_SHIFT | KEY_DOWN, ESC_STR "[1;2B", MCKEY_NOACTION },
{ KEY_M_SHIFT | KEY_RIGHT, ESC_STR "[1;2C", MCKEY_NOACTION },
{ KEY_M_SHIFT | KEY_LEFT, ESC_STR "[1;2D", MCKEY_NOACTION },
{KEY_M_SHIFT | KEY_UP, ESC_STR "[1;2A", MCKEY_NOACTION},
{KEY_M_SHIFT | KEY_DOWN, ESC_STR "[1;2B", MCKEY_NOACTION},
{KEY_M_SHIFT | KEY_RIGHT, ESC_STR "[1;2C", MCKEY_NOACTION},
{KEY_M_SHIFT | KEY_LEFT, ESC_STR "[1;2D", MCKEY_NOACTION},
/* more xterm keys with modifiers */
{ KEY_M_CTRL | KEY_PPAGE, ESC_STR "[5;5~", MCKEY_NOACTION },
{ KEY_M_CTRL | KEY_NPAGE, ESC_STR "[6;5~", MCKEY_NOACTION },
{ KEY_M_CTRL | KEY_IC, ESC_STR "[2;5~", MCKEY_NOACTION },
{ KEY_M_CTRL | KEY_DC, ESC_STR "[3;5~", MCKEY_NOACTION },
{ KEY_M_CTRL | KEY_HOME, ESC_STR "[1;5H", MCKEY_NOACTION },
{ KEY_M_CTRL | KEY_END, ESC_STR "[1;5F", MCKEY_NOACTION },
{ KEY_M_SHIFT | KEY_HOME, ESC_STR "[1;2H", MCKEY_NOACTION },
{ KEY_M_SHIFT | KEY_END, ESC_STR "[1;2F", MCKEY_NOACTION },
{ KEY_M_CTRL | KEY_UP, ESC_STR "[1;5A", MCKEY_NOACTION },
{ KEY_M_CTRL | KEY_DOWN, ESC_STR "[1;5B", MCKEY_NOACTION },
{ KEY_M_CTRL | KEY_RIGHT, ESC_STR "[1;5C", MCKEY_NOACTION },
{ KEY_M_CTRL | KEY_LEFT, ESC_STR "[1;5D", MCKEY_NOACTION },
{ KEY_M_SHIFT | KEY_IC, ESC_STR "[2;2~", MCKEY_NOACTION },
{ KEY_M_SHIFT | KEY_DC, ESC_STR "[3;2~", MCKEY_NOACTION },
{ KEY_M_SHIFT | KEY_M_CTRL | KEY_UP, ESC_STR "[1;6A", MCKEY_NOACTION },
{ KEY_M_SHIFT | KEY_M_CTRL | KEY_DOWN, ESC_STR "[1;6B", MCKEY_NOACTION },
{ KEY_M_SHIFT | KEY_M_CTRL | KEY_RIGHT, ESC_STR "[1;6C", MCKEY_NOACTION },
{ KEY_M_SHIFT | KEY_M_CTRL | KEY_LEFT, ESC_STR "[1;6D", MCKEY_NOACTION },
{KEY_M_CTRL | KEY_PPAGE, ESC_STR "[5;5~", MCKEY_NOACTION},
{KEY_M_CTRL | KEY_NPAGE, ESC_STR "[6;5~", MCKEY_NOACTION},
{KEY_M_CTRL | KEY_IC, ESC_STR "[2;5~", MCKEY_NOACTION},
{KEY_M_CTRL | KEY_DC, ESC_STR "[3;5~", MCKEY_NOACTION},
{KEY_M_CTRL | KEY_HOME, ESC_STR "[1;5H", MCKEY_NOACTION},
{KEY_M_CTRL | KEY_END, ESC_STR "[1;5F", MCKEY_NOACTION},
{KEY_M_SHIFT | KEY_HOME, ESC_STR "[1;2H", MCKEY_NOACTION},
{KEY_M_SHIFT | KEY_END, ESC_STR "[1;2F", MCKEY_NOACTION},
{KEY_M_CTRL | KEY_UP, ESC_STR "[1;5A", MCKEY_NOACTION},
{KEY_M_CTRL | KEY_DOWN, ESC_STR "[1;5B", MCKEY_NOACTION},
{KEY_M_CTRL | KEY_RIGHT, ESC_STR "[1;5C", MCKEY_NOACTION},
{KEY_M_CTRL | KEY_LEFT, ESC_STR "[1;5D", MCKEY_NOACTION},
{KEY_M_SHIFT | KEY_IC, ESC_STR "[2;2~", MCKEY_NOACTION},
{KEY_M_SHIFT | KEY_DC, ESC_STR "[3;2~", MCKEY_NOACTION},
{KEY_M_SHIFT | KEY_M_CTRL | KEY_UP, ESC_STR "[1;6A", MCKEY_NOACTION},
{KEY_M_SHIFT | KEY_M_CTRL | KEY_DOWN, ESC_STR "[1;6B", MCKEY_NOACTION},
{KEY_M_SHIFT | KEY_M_CTRL | KEY_RIGHT, ESC_STR "[1;6C", MCKEY_NOACTION},
{KEY_M_SHIFT | KEY_M_CTRL | KEY_LEFT, ESC_STR "[1;6D", MCKEY_NOACTION},
/* putty */
{ KEY_M_SHIFT | KEY_M_CTRL | KEY_UP, ESC_STR "[[1;6A", MCKEY_NOACTION },
{ KEY_M_SHIFT | KEY_M_CTRL | KEY_DOWN, ESC_STR "[[1;6B", MCKEY_NOACTION },
{ KEY_M_SHIFT | KEY_M_CTRL | KEY_RIGHT, ESC_STR "[[1;6C", MCKEY_NOACTION },
{ KEY_M_SHIFT | KEY_M_CTRL | KEY_LEFT, ESC_STR "[[1;6D", MCKEY_NOACTION },
{KEY_M_SHIFT | KEY_M_CTRL | KEY_UP, ESC_STR "[[1;6A", MCKEY_NOACTION},
{KEY_M_SHIFT | KEY_M_CTRL | KEY_DOWN, ESC_STR "[[1;6B", MCKEY_NOACTION},
{KEY_M_SHIFT | KEY_M_CTRL | KEY_RIGHT, ESC_STR "[[1;6C", MCKEY_NOACTION},
{KEY_M_SHIFT | KEY_M_CTRL | KEY_LEFT, ESC_STR "[[1;6D", MCKEY_NOACTION},
/* putty alt-arrow keys */
/* removed as source esc esc esc trouble */
@ -303,91 +303,90 @@ static key_define_t xterm_key_defines [] = {
{ KEY_M_CTRL | KEY_M_ALT | KEY_END, ESC_STR ESC_STR "[1;5F", MCKEY_NOACTION },
*/
/* xterm alt-arrow keys */
{ KEY_M_ALT | KEY_UP, ESC_STR "[1;3A", MCKEY_NOACTION },
{ KEY_M_ALT | KEY_DOWN, ESC_STR "[1;3B", MCKEY_NOACTION },
{ KEY_M_ALT | KEY_RIGHT, ESC_STR "[1;3C", MCKEY_NOACTION },
{ KEY_M_ALT | KEY_LEFT, ESC_STR "[1;3D", MCKEY_NOACTION },
{ KEY_M_ALT | KEY_PPAGE, ESC_STR "[5;3~", MCKEY_NOACTION },
{ KEY_M_ALT | KEY_NPAGE, ESC_STR "[6;3~", MCKEY_NOACTION },
{ KEY_M_ALT | KEY_HOME, ESC_STR "[1~", MCKEY_NOACTION },
{ KEY_M_ALT | KEY_END, ESC_STR "[4~", MCKEY_NOACTION },
{ KEY_M_CTRL | KEY_M_ALT | KEY_UP, ESC_STR "[1;7A", MCKEY_NOACTION },
{ KEY_M_CTRL | KEY_M_ALT | KEY_DOWN, ESC_STR "[1;7B", MCKEY_NOACTION },
{ KEY_M_CTRL | KEY_M_ALT | KEY_RIGHT, ESC_STR "[1;7C", MCKEY_NOACTION },
{ KEY_M_CTRL | KEY_M_ALT | KEY_LEFT, ESC_STR "[1;7D", MCKEY_NOACTION },
{ KEY_M_CTRL | KEY_M_ALT | KEY_PPAGE, ESC_STR "[5;7~", MCKEY_NOACTION },
{ KEY_M_CTRL | KEY_M_ALT | KEY_NPAGE, ESC_STR "[6;7~", MCKEY_NOACTION },
{ KEY_M_CTRL | KEY_M_ALT | KEY_HOME, ESC_STR "OH", MCKEY_NOACTION },
{ KEY_M_CTRL | KEY_M_ALT | KEY_END, ESC_STR "OF", MCKEY_NOACTION },
{KEY_M_ALT | KEY_UP, ESC_STR "[1;3A", MCKEY_NOACTION},
{KEY_M_ALT | KEY_DOWN, ESC_STR "[1;3B", MCKEY_NOACTION},
{KEY_M_ALT | KEY_RIGHT, ESC_STR "[1;3C", MCKEY_NOACTION},
{KEY_M_ALT | KEY_LEFT, ESC_STR "[1;3D", MCKEY_NOACTION},
{KEY_M_ALT | KEY_PPAGE, ESC_STR "[5;3~", MCKEY_NOACTION},
{KEY_M_ALT | KEY_NPAGE, ESC_STR "[6;3~", MCKEY_NOACTION},
{KEY_M_ALT | KEY_HOME, ESC_STR "[1~", MCKEY_NOACTION},
{KEY_M_ALT | KEY_END, ESC_STR "[4~", MCKEY_NOACTION},
{KEY_M_CTRL | KEY_M_ALT | KEY_UP, ESC_STR "[1;7A", MCKEY_NOACTION},
{KEY_M_CTRL | KEY_M_ALT | KEY_DOWN, ESC_STR "[1;7B", MCKEY_NOACTION},
{KEY_M_CTRL | KEY_M_ALT | KEY_RIGHT, ESC_STR "[1;7C", MCKEY_NOACTION},
{KEY_M_CTRL | KEY_M_ALT | KEY_LEFT, ESC_STR "[1;7D", MCKEY_NOACTION},
{KEY_M_CTRL | KEY_M_ALT | KEY_PPAGE, ESC_STR "[5;7~", MCKEY_NOACTION},
{KEY_M_CTRL | KEY_M_ALT | KEY_NPAGE, ESC_STR "[6;7~", MCKEY_NOACTION},
{KEY_M_CTRL | KEY_M_ALT | KEY_HOME, ESC_STR "OH", MCKEY_NOACTION},
{KEY_M_CTRL | KEY_M_ALT | KEY_END, ESC_STR "OF", MCKEY_NOACTION},
/* rxvt keys with modifiers */
{ KEY_M_SHIFT | KEY_UP, ESC_STR "[a", MCKEY_NOACTION },
{ KEY_M_SHIFT | KEY_DOWN, ESC_STR "[b", MCKEY_NOACTION },
{ KEY_M_SHIFT | KEY_RIGHT, ESC_STR "[c", MCKEY_NOACTION },
{ KEY_M_SHIFT | KEY_LEFT, ESC_STR "[d", MCKEY_NOACTION },
{ KEY_M_CTRL | KEY_UP, ESC_STR "Oa", MCKEY_NOACTION },
{ KEY_M_CTRL | KEY_DOWN, ESC_STR "Ob", MCKEY_NOACTION },
{ KEY_M_CTRL | KEY_RIGHT, ESC_STR "Oc", MCKEY_NOACTION },
{ KEY_M_CTRL | KEY_LEFT, ESC_STR "Od", MCKEY_NOACTION },
{ KEY_M_CTRL | KEY_PPAGE, ESC_STR "[5^", MCKEY_NOACTION },
{ KEY_M_CTRL | KEY_NPAGE, ESC_STR "[6^", MCKEY_NOACTION },
{ KEY_M_CTRL | KEY_HOME, ESC_STR "[7^", MCKEY_NOACTION },
{ KEY_M_CTRL | KEY_END, ESC_STR "[8^", MCKEY_NOACTION },
{ KEY_M_SHIFT | KEY_HOME, ESC_STR "[7$", MCKEY_NOACTION },
{ KEY_M_SHIFT | KEY_END, ESC_STR "[8$", MCKEY_NOACTION },
{ KEY_M_CTRL | KEY_IC, ESC_STR "[2^", MCKEY_NOACTION },
{ KEY_M_CTRL | KEY_DC, ESC_STR "[3^", MCKEY_NOACTION },
{ KEY_M_SHIFT | KEY_DC, ESC_STR "[3$", MCKEY_NOACTION },
{KEY_M_SHIFT | KEY_UP, ESC_STR "[a", MCKEY_NOACTION},
{KEY_M_SHIFT | KEY_DOWN, ESC_STR "[b", MCKEY_NOACTION},
{KEY_M_SHIFT | KEY_RIGHT, ESC_STR "[c", MCKEY_NOACTION},
{KEY_M_SHIFT | KEY_LEFT, ESC_STR "[d", MCKEY_NOACTION},
{KEY_M_CTRL | KEY_UP, ESC_STR "Oa", MCKEY_NOACTION},
{KEY_M_CTRL | KEY_DOWN, ESC_STR "Ob", MCKEY_NOACTION},
{KEY_M_CTRL | KEY_RIGHT, ESC_STR "Oc", MCKEY_NOACTION},
{KEY_M_CTRL | KEY_LEFT, ESC_STR "Od", MCKEY_NOACTION},
{KEY_M_CTRL | KEY_PPAGE, ESC_STR "[5^", MCKEY_NOACTION},
{KEY_M_CTRL | KEY_NPAGE, ESC_STR "[6^", MCKEY_NOACTION},
{KEY_M_CTRL | KEY_HOME, ESC_STR "[7^", MCKEY_NOACTION},
{KEY_M_CTRL | KEY_END, ESC_STR "[8^", MCKEY_NOACTION},
{KEY_M_SHIFT | KEY_HOME, ESC_STR "[7$", MCKEY_NOACTION},
{KEY_M_SHIFT | KEY_END, ESC_STR "[8$", MCKEY_NOACTION},
{KEY_M_CTRL | KEY_IC, ESC_STR "[2^", MCKEY_NOACTION},
{KEY_M_CTRL | KEY_DC, ESC_STR "[3^", MCKEY_NOACTION},
{KEY_M_SHIFT | KEY_DC, ESC_STR "[3$", MCKEY_NOACTION},
/* konsole keys with modifiers */
{ KEY_M_SHIFT | KEY_HOME, ESC_STR "O2H", MCKEY_NOACTION },
{ KEY_M_SHIFT | KEY_END, ESC_STR "O2F", MCKEY_NOACTION },
{KEY_M_SHIFT | KEY_HOME, ESC_STR "O2H", MCKEY_NOACTION},
{KEY_M_SHIFT | KEY_END, ESC_STR "O2F", MCKEY_NOACTION},
/* gnome-terminal */
{ KEY_M_SHIFT | KEY_UP, ESC_STR "[2A", MCKEY_NOACTION },
{ KEY_M_SHIFT | KEY_DOWN, ESC_STR "[2B", MCKEY_NOACTION },
{ KEY_M_SHIFT | KEY_RIGHT, ESC_STR "[2C", MCKEY_NOACTION },
{ KEY_M_SHIFT | KEY_LEFT, ESC_STR "[2D", MCKEY_NOACTION },
{ KEY_M_CTRL | KEY_UP, ESC_STR "[5A", MCKEY_NOACTION },
{ KEY_M_CTRL | KEY_DOWN, ESC_STR "[5B", MCKEY_NOACTION },
{ KEY_M_CTRL | KEY_RIGHT, ESC_STR "[5C", MCKEY_NOACTION },
{ KEY_M_CTRL | KEY_LEFT, ESC_STR "[5D", MCKEY_NOACTION },
{ KEY_M_SHIFT | KEY_M_CTRL | KEY_UP, ESC_STR "[6A", MCKEY_NOACTION },
{ KEY_M_SHIFT | KEY_M_CTRL | KEY_DOWN, ESC_STR "[6B", MCKEY_NOACTION },
{ KEY_M_SHIFT | KEY_M_CTRL | KEY_RIGHT, ESC_STR "[6C", MCKEY_NOACTION },
{ KEY_M_SHIFT | KEY_M_CTRL | KEY_LEFT, ESC_STR "[6D", MCKEY_NOACTION },
{KEY_M_SHIFT | KEY_UP, ESC_STR "[2A", MCKEY_NOACTION},
{KEY_M_SHIFT | KEY_DOWN, ESC_STR "[2B", MCKEY_NOACTION},
{KEY_M_SHIFT | KEY_RIGHT, ESC_STR "[2C", MCKEY_NOACTION},
{KEY_M_SHIFT | KEY_LEFT, ESC_STR "[2D", MCKEY_NOACTION},
{KEY_M_CTRL | KEY_UP, ESC_STR "[5A", MCKEY_NOACTION},
{KEY_M_CTRL | KEY_DOWN, ESC_STR "[5B", MCKEY_NOACTION},
{KEY_M_CTRL | KEY_RIGHT, ESC_STR "[5C", MCKEY_NOACTION},
{KEY_M_CTRL | KEY_LEFT, ESC_STR "[5D", MCKEY_NOACTION},
{KEY_M_SHIFT | KEY_M_CTRL | KEY_UP, ESC_STR "[6A", MCKEY_NOACTION},
{KEY_M_SHIFT | KEY_M_CTRL | KEY_DOWN, ESC_STR "[6B", MCKEY_NOACTION},
{KEY_M_SHIFT | KEY_M_CTRL | KEY_RIGHT, ESC_STR "[6C", MCKEY_NOACTION},
{KEY_M_SHIFT | KEY_M_CTRL | KEY_LEFT, ESC_STR "[6D", MCKEY_NOACTION},
/* gnome-terminal - application mode */
{ KEY_M_CTRL | KEY_UP, ESC_STR "O5A", MCKEY_NOACTION },
{ KEY_M_CTRL | KEY_DOWN, ESC_STR "O5B", MCKEY_NOACTION },
{ KEY_M_CTRL | KEY_RIGHT, ESC_STR "O5C", MCKEY_NOACTION },
{ KEY_M_CTRL | KEY_LEFT, ESC_STR "O5D", MCKEY_NOACTION },
{ KEY_M_SHIFT | KEY_M_CTRL | KEY_UP, ESC_STR "O6A", MCKEY_NOACTION },
{ KEY_M_SHIFT | KEY_M_CTRL | KEY_DOWN, ESC_STR "O6B", MCKEY_NOACTION },
{ KEY_M_SHIFT | KEY_M_CTRL | KEY_RIGHT, ESC_STR "O6C", MCKEY_NOACTION },
{ KEY_M_SHIFT | KEY_M_CTRL | KEY_LEFT, ESC_STR "O6D", MCKEY_NOACTION },
{KEY_M_CTRL | KEY_UP, ESC_STR "O5A", MCKEY_NOACTION},
{KEY_M_CTRL | KEY_DOWN, ESC_STR "O5B", MCKEY_NOACTION},
{KEY_M_CTRL | KEY_RIGHT, ESC_STR "O5C", MCKEY_NOACTION},
{KEY_M_CTRL | KEY_LEFT, ESC_STR "O5D", MCKEY_NOACTION},
{KEY_M_SHIFT | KEY_M_CTRL | KEY_UP, ESC_STR "O6A", MCKEY_NOACTION},
{KEY_M_SHIFT | KEY_M_CTRL | KEY_DOWN, ESC_STR "O6B", MCKEY_NOACTION},
{KEY_M_SHIFT | KEY_M_CTRL | KEY_RIGHT, ESC_STR "O6C", MCKEY_NOACTION},
{KEY_M_SHIFT | KEY_M_CTRL | KEY_LEFT, ESC_STR "O6D", MCKEY_NOACTION},
/* iTerm */
{ KEY_M_SHIFT | KEY_PPAGE, ESC_STR "[5;2~", MCKEY_NOACTION },
{ KEY_M_SHIFT | KEY_NPAGE, ESC_STR "[6;2~", MCKEY_NOACTION },
{KEY_M_SHIFT | KEY_PPAGE, ESC_STR "[5;2~", MCKEY_NOACTION},
{KEY_M_SHIFT | KEY_NPAGE, ESC_STR "[6;2~", MCKEY_NOACTION},
/* putty */
{ KEY_M_SHIFT | KEY_PPAGE, ESC_STR "[[5;53~", MCKEY_NOACTION },
{ KEY_M_SHIFT | KEY_NPAGE, ESC_STR "[[6;53~", MCKEY_NOACTION },
{KEY_M_SHIFT | KEY_PPAGE, ESC_STR "[[5;53~", MCKEY_NOACTION},
{KEY_M_SHIFT | KEY_NPAGE, ESC_STR "[[6;53~", MCKEY_NOACTION},
/* keypad keys */
{ KEY_IC, ESC_STR "Op", MCKEY_NOACTION },
{ KEY_DC, ESC_STR "On", MCKEY_NOACTION },
{ '/', ESC_STR "Oo", MCKEY_NOACTION },
{ '\n', ESC_STR "OM", MCKEY_NOACTION },
{KEY_IC, ESC_STR "Op", MCKEY_NOACTION},
{KEY_DC, ESC_STR "On", MCKEY_NOACTION},
{'/', ESC_STR "Oo", MCKEY_NOACTION},
{'\n', ESC_STR "OM", MCKEY_NOACTION},
{ 0, NULL, MCKEY_NOACTION },
{0, NULL, MCKEY_NOACTION},
};
/* qansi-m terminals have a much more key combinatios,
which are undefined in termcap/terminfo */
static key_define_t qansi_key_defines[] =
{
static key_define_t qansi_key_defines[] = {
/* qansi-m terminal */
{KEY_M_CTRL | KEY_NPAGE, ESC_STR "[u", MCKEY_NOACTION}, /* Ctrl-PgDown */
{KEY_M_CTRL | KEY_PPAGE, ESC_STR "[v", MCKEY_NOACTION}, /* Ctrl-PgUp */
@ -403,30 +402,30 @@ static key_define_t qansi_key_defines[] =
{KEY_M_CTRL | KEY_KP_SUBTRACT, ESC_STR "[t", MCKEY_NOACTION}, /* Ctrl-Gr-Minus */
{KEY_M_CTRL | '\t', ESC_STR "[z", MCKEY_NOACTION}, /* Ctrl-Tab */
{KEY_M_SHIFT | '\t', ESC_STR "[Z", MCKEY_NOACTION}, /* Shift-Tab */
{KEY_M_CTRL | KEY_F(1), ESC_STR "[1~", MCKEY_NOACTION}, /* Ctrl-F1 */
{KEY_M_CTRL | KEY_F(2), ESC_STR "[2~", MCKEY_NOACTION}, /* Ctrl-F2 */
{KEY_M_CTRL | KEY_F(3), ESC_STR "[3~", MCKEY_NOACTION}, /* Ctrl-F3 */
{KEY_M_CTRL | KEY_F(4), ESC_STR "[4~", MCKEY_NOACTION}, /* Ctrl-F4 */
{KEY_M_CTRL | KEY_F(5), ESC_STR "[5~", MCKEY_NOACTION}, /* Ctrl-F5 */
{KEY_M_CTRL | KEY_F(6), ESC_STR "[6~", MCKEY_NOACTION}, /* Ctrl-F6 */
{KEY_M_CTRL | KEY_F(7), ESC_STR "[7~", MCKEY_NOACTION}, /* Ctrl-F7 */
{KEY_M_CTRL | KEY_F(8), ESC_STR "[8~", MCKEY_NOACTION}, /* Ctrl-F8 */
{KEY_M_CTRL | KEY_F(9), ESC_STR "[9~", MCKEY_NOACTION}, /* Ctrl-F9 */
{KEY_M_CTRL | KEY_F(10), ESC_STR "[10~", MCKEY_NOACTION}, /* Ctrl-F10 */
{KEY_M_CTRL | KEY_F(11), ESC_STR "[11~", MCKEY_NOACTION}, /* Ctrl-F11 */
{KEY_M_CTRL | KEY_F(12), ESC_STR "[12~", MCKEY_NOACTION}, /* Ctrl-F12 */
{KEY_M_ALT | KEY_F(1), ESC_STR "[17~", MCKEY_NOACTION}, /* Alt-F1 */
{KEY_M_ALT | KEY_F(2), ESC_STR "[18~", MCKEY_NOACTION}, /* Alt-F2 */
{KEY_M_ALT | KEY_F(3), ESC_STR "[19~", MCKEY_NOACTION}, /* Alt-F3 */
{KEY_M_ALT | KEY_F(4), ESC_STR "[20~", MCKEY_NOACTION}, /* Alt-F4 */
{KEY_M_ALT | KEY_F(5), ESC_STR "[21~", MCKEY_NOACTION}, /* Alt-F5 */
{KEY_M_ALT | KEY_F(6), ESC_STR "[22~", MCKEY_NOACTION}, /* Alt-F6 */
{KEY_M_ALT | KEY_F(7), ESC_STR "[23~", MCKEY_NOACTION}, /* Alt-F7 */
{KEY_M_ALT | KEY_F(8), ESC_STR "[24~", MCKEY_NOACTION}, /* Alt-F8 */
{KEY_M_ALT | KEY_F(9), ESC_STR "[25~", MCKEY_NOACTION}, /* Alt-F9 */
{KEY_M_ALT | KEY_F(10), ESC_STR "[26~", MCKEY_NOACTION}, /* Alt-F10 */
{KEY_M_ALT | KEY_F(11), ESC_STR "[27~", MCKEY_NOACTION}, /* Alt-F11 */
{KEY_M_ALT | KEY_F(12), ESC_STR "[28~", MCKEY_NOACTION}, /* Alt-F12 */
{KEY_M_CTRL | KEY_F (1), ESC_STR "[1~", MCKEY_NOACTION}, /* Ctrl-F1 */
{KEY_M_CTRL | KEY_F (2), ESC_STR "[2~", MCKEY_NOACTION}, /* Ctrl-F2 */
{KEY_M_CTRL | KEY_F (3), ESC_STR "[3~", MCKEY_NOACTION}, /* Ctrl-F3 */
{KEY_M_CTRL | KEY_F (4), ESC_STR "[4~", MCKEY_NOACTION}, /* Ctrl-F4 */
{KEY_M_CTRL | KEY_F (5), ESC_STR "[5~", MCKEY_NOACTION}, /* Ctrl-F5 */
{KEY_M_CTRL | KEY_F (6), ESC_STR "[6~", MCKEY_NOACTION}, /* Ctrl-F6 */
{KEY_M_CTRL | KEY_F (7), ESC_STR "[7~", MCKEY_NOACTION}, /* Ctrl-F7 */
{KEY_M_CTRL | KEY_F (8), ESC_STR "[8~", MCKEY_NOACTION}, /* Ctrl-F8 */
{KEY_M_CTRL | KEY_F (9), ESC_STR "[9~", MCKEY_NOACTION}, /* Ctrl-F9 */
{KEY_M_CTRL | KEY_F (10), ESC_STR "[10~", MCKEY_NOACTION}, /* Ctrl-F10 */
{KEY_M_CTRL | KEY_F (11), ESC_STR "[11~", MCKEY_NOACTION}, /* Ctrl-F11 */
{KEY_M_CTRL | KEY_F (12), ESC_STR "[12~", MCKEY_NOACTION}, /* Ctrl-F12 */
{KEY_M_ALT | KEY_F (1), ESC_STR "[17~", MCKEY_NOACTION}, /* Alt-F1 */
{KEY_M_ALT | KEY_F (2), ESC_STR "[18~", MCKEY_NOACTION}, /* Alt-F2 */
{KEY_M_ALT | KEY_F (3), ESC_STR "[19~", MCKEY_NOACTION}, /* Alt-F3 */
{KEY_M_ALT | KEY_F (4), ESC_STR "[20~", MCKEY_NOACTION}, /* Alt-F4 */
{KEY_M_ALT | KEY_F (5), ESC_STR "[21~", MCKEY_NOACTION}, /* Alt-F5 */
{KEY_M_ALT | KEY_F (6), ESC_STR "[22~", MCKEY_NOACTION}, /* Alt-F6 */
{KEY_M_ALT | KEY_F (7), ESC_STR "[23~", MCKEY_NOACTION}, /* Alt-F7 */
{KEY_M_ALT | KEY_F (8), ESC_STR "[24~", MCKEY_NOACTION}, /* Alt-F8 */
{KEY_M_ALT | KEY_F (9), ESC_STR "[25~", MCKEY_NOACTION}, /* Alt-F9 */
{KEY_M_ALT | KEY_F (10), ESC_STR "[26~", MCKEY_NOACTION}, /* Alt-F10 */
{KEY_M_ALT | KEY_F (11), ESC_STR "[27~", MCKEY_NOACTION}, /* Alt-F11 */
{KEY_M_ALT | KEY_F (12), ESC_STR "[28~", MCKEY_NOACTION}, /* Alt-F12 */
{KEY_M_ALT | 'a', ESC_STR "Na", MCKEY_NOACTION}, /* Alt-a */
{KEY_M_ALT | 'b', ESC_STR "Nb", MCKEY_NOACTION}, /* Alt-b */
{KEY_M_ALT | 'c', ESC_STR "Nc", MCKEY_NOACTION}, /* Alt-c */
@ -467,7 +466,7 @@ static int disabled_channels = 0; /* Disable channels checking */
static SelectList *select_list = NULL;
static int seq_buffer [SEQ_BUFFER_LEN];
static int seq_buffer[SEQ_BUFFER_LEN];
static int *seq_append = NULL;
static int *pending_keys = NULL;
@ -486,7 +485,7 @@ static Window x11_window;
/*** file scope functions **********************************************/
static int
add_selects (fd_set *select_set)
add_selects (fd_set * select_set)
{
int top_fd = 0;
@ -504,7 +503,7 @@ add_selects (fd_set *select_set)
}
static void
check_selects (fd_set *select_set)
check_selects (fd_set * select_set)
{
if (disabled_channels == 0) {
gboolean retry;
@ -516,7 +515,7 @@ check_selects (fd_set *select_set)
for (p = select_list; p; p = p->next)
if (FD_ISSET (p->fd, select_set)) {
FD_CLR (p->fd, select_set);
(*p->callback)(p->fd, p->info);
(*p->callback) (p->fd, p->info);
retry = TRUE;
break;
}
@ -580,7 +579,7 @@ create_sequence (const char *seq, int code, int action)
}
static void
define_sequences (const key_define_t *kd)
define_sequences (const key_define_t * kd)
{
int i;
@ -625,7 +624,7 @@ getch_with_delay (void)
}
static void
xmouse_get_event (Gpm_Event *ev)
xmouse_get_event (Gpm_Event * ev)
{
int btn;
static struct timeval tv1 = { 0, 0 }; /* Force first click as single */
@ -670,7 +669,7 @@ xmouse_get_event (Gpm_Event *ev)
ev->type = GPM_DOWN;
GET_TIME (tv2);
if (tv1.tv_sec && (DIF_TIME (tv1,tv2) < double_click_speed)) {
if (tv1.tv_sec && (DIF_TIME (tv1, tv2) < double_click_speed)) {
clicks++;
clicks %= 3;
} else
@ -754,10 +753,8 @@ get_modifier (void)
void *ph_handle = dlopen ("/usr/lib/libph.so", RTLD_NOW);
if (ph_handle != NULL) {
ph_attach = (ph_dv_f) dlsym (ph_handle, "PhAttach");
ph_input_group =
(ph_ov_f) dlsym (ph_handle, "PhInputGroup");
ph_query_cursor =
(ph_pqc_f) dlsym (ph_handle, "PhQueryCursor");
ph_input_group = (ph_ov_f) dlsym (ph_handle, "PhInputGroup");
ph_query_cursor = (ph_pqc_f) dlsym (ph_handle, "PhQueryCursor");
if ((ph_attach != NULL) && (ph_input_group != NULL)
&& (ph_query_cursor != NULL)) {
if ((*ph_attach) (0, 0)) { /* Attached */
@ -771,9 +768,7 @@ get_modifier (void)
/* We do not have Photon running. Assume we are in text
console or xterm */
if (in_photon == -1) {
if (devctl
(fileno (stdin), DCMD_CHR_LINESTATUS, &mod_status,
sizeof (int), NULL) == -1)
if (devctl (fileno (stdin), DCMD_CHR_LINESTATUS, &mod_status, sizeof (int), NULL) == -1)
return 0;
shift_ext_status = mod_status & 0xffffff00UL;
mod_status &= 0x7f;
@ -822,7 +817,7 @@ push_char (int c)
if (seq_append == NULL)
seq_append = seq_buffer;
if (seq_append != &(seq_buffer [SEQ_BUFFER_LEN - 2])) {
if (seq_append != &(seq_buffer[SEQ_BUFFER_LEN - 2])) {
*(seq_append++) = c;
*seq_append = 0;
ret = TRUE;
@ -837,10 +832,10 @@ correct_key_code (int code)
{
unsigned int c = code & ~KEY_M_MASK; /* code without modifier */
unsigned int mod = code & KEY_M_MASK; /* modifier */
#ifdef __QNXNTO__
#ifdef __QNXNTO__
unsigned int qmod; /* bunch of the QNX console
modifiers needs unchanged */
#endif /* __QNXNTO__ */
#endif /* __QNXNTO__ */
/*
* Add key modifiers directly from X11 or OS.
@ -877,29 +872,23 @@ correct_key_code (int code)
if (c < 32 && c != ESC_CHAR && c != '\t' && c != '\n') {
mod |= KEY_M_CTRL;
}
#ifdef __QNXNTO__
qmod = get_modifier ();
if ((c == 127) && (mod == 0)) /* Add Ctrl/Alt/Shift-BackSpace */
{
mod |= get_modifier();
if ((c == 127) && (mod == 0)) { /* Add Ctrl/Alt/Shift-BackSpace */
mod |= get_modifier ();
c = KEY_BACKSPACE;
}
if ((c == '0') && (mod == 0)) /* Add Shift-Insert on key pad */
{
if ((qmod & KEY_M_SHIFT) == KEY_M_SHIFT)
{
if ((c == '0') && (mod == 0)) { /* Add Shift-Insert on key pad */
if ((qmod & KEY_M_SHIFT) == KEY_M_SHIFT) {
mod = KEY_M_SHIFT;
c = KEY_IC;
}
}
if ((c == '.') && (mod == 0)) /* Add Shift-Del on key pad */
{
if ((qmod & KEY_M_SHIFT) == KEY_M_SHIFT)
{
if ((c == '.') && (mod == 0)) { /* Add Shift-Del on key pad */
if ((qmod & KEY_M_SHIFT) == KEY_M_SHIFT) {
mod = KEY_M_SHIFT;
c = KEY_DC;
}
@ -991,7 +980,7 @@ learn_store_key (char *buffer, char **p, int c)
}
static void
k_dispose (key_def *k)
k_dispose (key_def * k)
{
if (k != NULL) {
k_dispose (k->child);
@ -1001,7 +990,7 @@ k_dispose (key_def *k)
}
static void
s_dispose (SelectList *sel)
s_dispose (SelectList * sel)
{
if (sel != NULL) {
s_dispose (sel->next);
@ -1030,8 +1019,7 @@ init_key (void)
|| (term != NULL
&& (strncmp (term, "iris-ansi", 9) == 0
|| strncmp (term, "xterm", 5) == 0
|| strncmp (term, "rxvt", 4) == 0
|| strcmp (term, "screen") == 0)))
|| strncmp (term, "rxvt", 4) == 0 || strcmp (term, "screen") == 0)))
define_sequences (xterm_key_defines);
/* load some additional keys (e.g. direct Alt-? support) */
@ -1126,8 +1114,7 @@ void
channels_up (void)
{
if (disabled_channels == 0)
fputs ("Error: channels_up called with disabled_channels = 0\n",
stderr);
fputs ("Error: channels_up called with disabled_channels = 0\n", stderr);
disabled_channels--;
}
@ -1225,9 +1212,9 @@ lookup_keyname (char *keyname)
if (keyname[1] == '\0')
return (int) keyname[0];
for (i = 0; key_name_conv_tab [i].code; i++)
if (str_casecmp (key_name_conv_tab [i].name, keyname) == 0)
return key_name_conv_tab [i].code;
for (i = 0; key_name_conv_tab[i].code; i++)
if (str_casecmp (key_name_conv_tab[i].name, keyname) == 0)
return key_name_conv_tab[i].code;
return 0;
}
@ -1248,11 +1235,11 @@ lookup_key (char *keyname)
keys = g_strsplit (keyname, " ", -1);
keys_count = g_strv_length (keys);
for (i = keys_count - 1; i >= 0; i--) {
if (keys[i] !=NULL && keys[i][0] != 0) {
if (keys[i] != NULL && keys[i][0] != 0) {
key = lookup_keyname (keys[i]);
if (key & KEY_M_CTRL) {
if (k < 256)
k = XCTRL(k);
k = XCTRL (k);
else
k |= key;
} else {
@ -1281,7 +1268,7 @@ define_sequence (int code, const char *seq, int action)
if (strlen (seq) > SEQ_BUFFER_LEN - 1)
return FALSE;
for (base = keys; (base != NULL) && (*seq != '\0'); )
for (base = keys; (base != NULL) && (*seq != '\0');)
if (*seq == base->ch) {
if (base->child == 0) {
if (*(seq + 1) != '\0')
@ -1365,7 +1352,7 @@ get_key_code (int no_delay)
goto check_pend;
}
if ((d > 127 && d < 256) && use_8th_bit_as_meta)
d = ALT(d & 0x7f);
d = ALT (d & 0x7f);
this = NULL;
return correct_key_code (d);
}
@ -1382,8 +1369,7 @@ get_key_code (int no_delay)
if (no_delay) {
tty_nodelay (FALSE);
if (c == -1) {
if (this != NULL && parent != NULL &&
parent->action == MCKEY_ESCAPE && old_esc_mode) {
if (this != NULL && parent != NULL && parent->action == MCKEY_ESCAPE && old_esc_mode) {
struct timeval current, timeout;
if (esctime.tv_sec == -1)
@ -1397,8 +1383,7 @@ get_key_code (int no_delay)
}
if (current.tv_sec < timeout.tv_sec)
return -1;
if (current.tv_sec == timeout.tv_sec &&
current.tv_usec < timeout.tv_usec)
if (current.tv_sec == timeout.tv_sec && current.tv_usec < timeout.tv_usec)
return -1;
this = NULL;
pending_keys = seq_append = NULL;
@ -1477,7 +1462,7 @@ get_key_code (int no_delay)
else {
if ((parent != NULL) && (parent->action == MCKEY_ESCAPE)) {
/* Convert escape-digits to F-keys */
if (g_ascii_isdigit(c))
if (g_ascii_isdigit (c))
c = KEY_F (c - '0');
else if (c == ' ')
c = ESC_CHAR;
@ -1653,8 +1638,7 @@ tty_getch (void)
int key;
ev.x = -1;
while ((key = tty_get_event (&ev, FALSE, TRUE)) == EV_NONE)
;
while ((key = tty_get_event (&ev, FALSE, TRUE)) == EV_NONE);
return key;
}
@ -1668,7 +1652,7 @@ learn_key (void)
struct timeval endtime;
struct timeval timeout;
int c;
char buffer [256];
char buffer[256];
char *p = buffer;
tty_keypad (FALSE); /* disable intepreting keys by ncurses */

View File

@ -20,8 +20,7 @@ void done_key (void);
/* Keys management */
typedef void (*move_fn) (void *data, int param);
cb_ret_t check_movement_keys (int key, int page_size, void *data,
move_fn backfn, move_fn forfn,
move_fn topfn, move_fn bottomfn);
move_fn backfn, move_fn forfn, move_fn topfn, move_fn bottomfn);
int lookup_keyname (char *keyname);
int lookup_key (char *keyname);
@ -31,7 +30,7 @@ typedef const struct {
const char *longname;
} key_code_name_t;
extern key_code_name_t key_name_conv_tab [];
extern key_code_name_t key_name_conv_tab[];
/* mouse support */
struct Gpm_Event;

View File

@ -61,9 +61,9 @@
/* include QNX/term.h (not NCURSES/term.h!) */
#if __WATCOMC__ > 1000
#include <sys/term.h>
#include <sys/term.h>
#else
#include <term.h>
#include <term.h>
#endif
#include <stdlib.h> /* getenv() */
@ -307,67 +307,67 @@ typedef const struct qnx_key_define_s {
/* general key define table */
xtra_key_define_t xtra_key_defines[] = {
#if FORCE_BASE_KEY_DEFS
{KEY_BACKSPACE,Key_backspace},
{KEY_LEFT, Key_left },
{KEY_RIGHT, Key_right },
{KEY_UP, Key_up },
{KEY_DOWN, Key_down },
{KEY_NPAGE, Key_npage },
{KEY_PPAGE, Key_ppage },
{KEY_HOME, Key_home },
{KEY_END, Key_end },
{KEY_DC, Key_dc },
{KEY_IC, Key_ic },
{KEY_F(1), Key_f1 },
{KEY_F(2), Key_f2 },
{KEY_F(3), Key_f3 },
{KEY_F(4), Key_f4 },
{KEY_F(5), Key_f5 },
{KEY_F(6), Key_f6 },
{KEY_F(7), Key_f7 },
{KEY_F(8), Key_f8 },
{KEY_F(9), Key_f9 },
{KEY_F(10), Key_f10 },
{KEY_F(11), Key_f11 },
{KEY_F(12), Key_f12 },
{KEY_F(13), Key_f13 },
{KEY_F(14), Key_f14 },
{KEY_F(15), Key_f15 },
{KEY_F(16), Key_f16 },
{KEY_F(17), Key_f17 },
{KEY_F(18), Key_f18 },
{KEY_F(19), Key_f19 },
{KEY_F(20), Key_f20 },
{KEY_BACKSPACE, Key_backspace},
{KEY_LEFT, Key_left},
{KEY_RIGHT, Key_right},
{KEY_UP, Key_up},
{KEY_DOWN, Key_down},
{KEY_NPAGE, Key_npage},
{KEY_PPAGE, Key_ppage},
{KEY_HOME, Key_home},
{KEY_END, Key_end},
{KEY_DC, Key_dc},
{KEY_IC, Key_ic},
{KEY_F (1), Key_f1},
{KEY_F (2), Key_f2},
{KEY_F (3), Key_f3},
{KEY_F (4), Key_f4},
{KEY_F (5), Key_f5},
{KEY_F (6), Key_f6},
{KEY_F (7), Key_f7},
{KEY_F (8), Key_f8},
{KEY_F (9), Key_f9},
{KEY_F (10), Key_f10},
{KEY_F (11), Key_f11},
{KEY_F (12), Key_f12},
{KEY_F (13), Key_f13},
{KEY_F (14), Key_f14},
{KEY_F (15), Key_f15},
{KEY_F (16), Key_f16},
{KEY_F (17), Key_f17},
{KEY_F (18), Key_f18},
{KEY_F (19), Key_f19},
{KEY_F (20), Key_f20},
#endif
{ALT('a'), Key_alt_a },
{ALT('b'), Key_alt_b },
{ALT('c'), Key_alt_c },
{ALT('d'), Key_alt_d },
{ALT('e'), Key_alt_e },
{ALT('f'), Key_alt_f },
{ALT('g'), Key_alt_g },
{ALT('h'), Key_alt_h },
{ALT('i'), Key_alt_i },
{ALT('j'), Key_alt_j },
{ALT('k'), Key_alt_k },
{ALT('l'), Key_alt_l },
{ALT('m'), Key_alt_m },
{ALT('n'), Key_alt_n },
{ALT('o'), Key_alt_o },
{ALT('p'), Key_alt_p },
{ALT('q'), Key_alt_q },
{ALT('r'), Key_alt_r },
{ALT('s'), Key_alt_s },
{ALT('t'), Key_alt_t },
{ALT('u'), Key_alt_u },
{ALT('v'), Key_alt_v },
{ALT('w'), Key_alt_w },
{ALT('x'), Key_alt_x },
{ALT('y'), Key_alt_y },
{ALT('z'), Key_alt_z },
{ALT ('a'), Key_alt_a},
{ALT ('b'), Key_alt_b},
{ALT ('c'), Key_alt_c},
{ALT ('d'), Key_alt_d},
{ALT ('e'), Key_alt_e},
{ALT ('f'), Key_alt_f},
{ALT ('g'), Key_alt_g},
{ALT ('h'), Key_alt_h},
{ALT ('i'), Key_alt_i},
{ALT ('j'), Key_alt_j},
{ALT ('k'), Key_alt_k},
{ALT ('l'), Key_alt_l},
{ALT ('m'), Key_alt_m},
{ALT ('n'), Key_alt_n},
{ALT ('o'), Key_alt_o},
{ALT ('p'), Key_alt_p},
{ALT ('q'), Key_alt_q},
{ALT ('r'), Key_alt_r},
{ALT ('s'), Key_alt_s},
{ALT ('t'), Key_alt_t},
{ALT ('u'), Key_alt_u},
{ALT ('v'), Key_alt_v},
{ALT ('w'), Key_alt_w},
{ALT ('x'), Key_alt_x},
{ALT ('y'), Key_alt_y},
{ALT ('z'), Key_alt_z},
{ALT('\n'), Key_alt_enter},
{ALT('\t'), Key_alt_tab }
{ALT ('\n'), Key_alt_enter},
{ALT ('\t'), Key_alt_tab}
};
#endif /* xtra_key_define_t */
@ -381,7 +381,8 @@ xtra_key_define_t xtra_key_defines[] = {
#define __QTISOFFS(_qtisx) (((charoffset*)(&__CT->_strs))[_qtisx])
#define __QTISSTR(_qtisx) (&__CT->_strtab[0]+__QTISOFFS(_qtisx))
void load_qnx_key_defines (void)
void
load_qnx_key_defines (void)
{
static int _qnx_keys_defined = 0;
@ -389,20 +390,16 @@ void load_qnx_key_defines (void)
int idx, str_idx;
int term_setup_ok;
__setupterm(NULL, fileno(stdout), &term_setup_ok);
__setupterm (NULL, fileno (stdout), &term_setup_ok);
if (term_setup_ok != 1)
return;
for (idx = 0;
idx < sizeof(xtra_key_defines) / sizeof(xtra_key_defines[0]);
idx++) {
for (idx = 0; idx < sizeof (xtra_key_defines) / sizeof (xtra_key_defines[0]); idx++) {
str_idx = xtra_key_defines[idx].str_idx;
if (__QTISOFFS(str_idx)) {
if (*__QTISSTR(str_idx)) {
define_sequence(
xtra_key_defines[idx].mc_code,
__QTISSTR(str_idx),
MCKEY_NOACTION);
if (__QTISOFFS (str_idx)) {
if (*__QTISSTR (str_idx)) {
define_sequence (xtra_key_defines[idx].mc_code,
__QTISSTR (str_idx), MCKEY_NOACTION);
}
}
}
@ -416,11 +413,10 @@ void load_qnx_key_defines (void)
/* called from key.c/init_key() */
void load_xtra_key_defines (void)
void
load_xtra_key_defines (void)
{
#ifdef HAVE_QNX_KEYS
load_qnx_key_defines();
load_qnx_key_defines ();
#endif
}

View File

@ -102,10 +102,10 @@ enable_mouse (void)
case MOUSE_XTERM_NORMAL_TRACKING:
/* save old highlight mouse tracking */
printf(ESC_STR "[?1001s");
printf (ESC_STR "[?1001s");
/* enable mouse tracking */
printf(ESC_STR "[?1000h");
printf (ESC_STR "[?1000h");
fflush (stdout);
mouse_enabled = TRUE;
@ -113,10 +113,10 @@ enable_mouse (void)
case MOUSE_XTERM_BUTTON_EVENT_TRACKING:
/* save old highlight mouse tracking */
printf(ESC_STR "[?1001s");
printf (ESC_STR "[?1001s");
/* enable mouse tracking */
printf(ESC_STR "[?1002h");
printf (ESC_STR "[?1002h");
fflush (stdout);
mouse_enabled = TRUE;
@ -143,19 +143,19 @@ disable_mouse (void)
#endif
case MOUSE_XTERM_NORMAL_TRACKING:
/* disable mouse tracking */
printf(ESC_STR "[?1000l");
printf (ESC_STR "[?1000l");
/* restore old highlight mouse tracking */
printf(ESC_STR "[?1001r");
printf (ESC_STR "[?1001r");
fflush (stdout);
break;
case MOUSE_XTERM_BUTTON_EVENT_TRACKING:
/* disable mouse tracking */
printf(ESC_STR "[?1002l");
printf (ESC_STR "[?1002l");
/* restore old highlight mouse tracking */
printf(ESC_STR "[?1001r");
printf (ESC_STR "[?1001r");
fflush (stdout);
break;

View File

@ -26,19 +26,19 @@
/* Xterm mouse support supports only GPM_DOWN and GPM_UP */
/* If you use others make sure your code also works without them */
enum Gpm_Etype {
GPM_MOVE=1,
GPM_DRAG=2, /* exactly one in four is active at a time */
GPM_DOWN=4,
GPM_UP= 8,
GPM_MOVE = 1,
GPM_DRAG = 2, /* exactly one in four is active at a time */
GPM_DOWN = 4,
GPM_UP = 8,
#define GPM_BARE_EVENTS(ev) ((ev)&0xF)
GPM_SINGLE=16, /* at most one in three is set */
GPM_DOUBLE=32,
GPM_TRIPLE=64,
GPM_SINGLE = 16, /* at most one in three is set */
GPM_DOUBLE = 32,
GPM_TRIPLE = 64,
GPM_MFLAG=128, /* motion during click? */
GPM_HARD=256 /* if set in the defaultMask, force an already
GPM_MFLAG = 128, /* motion during click? */
GPM_HARD = 256 /* if set in the defaultMask, force an already
used event to pass over to another handler */
};

View File

@ -43,8 +43,7 @@
#endif
#include "../../src/tty/tty-internal.h" /* slow_tty */
#include "../../src/tty/tty.h" /* tty_draw_box_slow */
#include "../../src/tty/color-ncurses.h"
#include "../../src/tty/tty.h"
#include "../../src/tty/color-internal.h"
#include "../../src/tty/win.h"
@ -53,7 +52,7 @@
/* include at last !!! */
#ifdef WANT_TERM_H
# include <term.h>
#endif /* WANT_TERM_H*/
#endif /* WANT_TERM_H */
/*** global variables **************************************************/
@ -65,32 +64,64 @@
/*** file scope variables **********************************************/
static const struct {
int acscode;
int character;
} acs_approx [] = {
{ 'q', '-' }, /* ACS_HLINE */
{ 'x', '|' }, /* ACS_VLINE */
{ 'l', '+' }, /* ACS_ULCORNER */
{ 'k', '+' }, /* ACS_URCORNER */
{ 'm', '+' }, /* ACS_LLCORNER */
{ 'j', '+' }, /* ACS_LRCORNER */
{ 'a', '#' }, /* ACS_CKBOARD */
{ 'u', '+' }, /* ACS_RTEE */
{ 't', '+' }, /* ACS_LTEE */
{ 'w', '+' }, /* ACS_TTEE */
{ 'v', '+' }, /* ACS_BTEE */
{ 'n', '+' }, /* ACS_PLUS */
{ 0, 0 } };
/*** file scope functions **********************************************/
/* --------------------------------------------------------------------------------------------- */
/*** public functions **************************************************/
/* --------------------------------------------------------------------------------------------- */
int
mc_tty_normalize_lines_char (const char *ch)
{
int i;
struct mc_tty_lines_struct {
const char *line;
int line_code;
} const lines_codes[] = {
{"\342\224\214", ACS_LRCORNER}, /* ┌ */
{"\342\224\220", ACS_LLCORNER}, /* ┐ */
{"\342\224\224", ACS_URCORNER}, /* └ */
{"\342\224\230", ACS_ULCORNER}, /* ┘ */
{"\342\224\234", ACS_LTEE}, /* ├ */
{"\342\224\244", ACS_RTEE}, /* ┤ */
{"\342\224\254", ACS_TTEE}, /* ┬ */
{"\342\224\264", ACS_BTEE}, /* ┴ */
{"\342\224\200", ACS_HLINE}, /* ─ */
{"\342\224\202", ACS_VLINE}, /* │ */
{"\342\224\274", ACS_PLUS}, /* ┼ */
{"\342\225\235", ACS_LRCORNER | A_BOLD}, /* ╔ */
{"\342\225\232", ACS_LLCORNER | A_BOLD}, /* ╗ */
{"\342\225\227", ACS_URCORNER | A_BOLD}, /* ╚ */
{"\342\225\224", ACS_ULCORNER | A_BOLD}, /* ╝ */
{"\342\225\237", ACS_LTEE | A_BOLD}, /* ╟ */
{"\342\225\242", ACS_RTEE | A_BOLD}, /* ╢ */
{"\342\225\244", ACS_TTEE | A_BOLD}, /* ╤ */
{"\342\225\247", ACS_BTEE | A_BOLD}, /* ╧ */
{"\342\225\220", ACS_HLINE | A_BOLD}, /* ═ */
{"\342\225\221", ACS_VLINE | A_BOLD}, /* ║ */
{NULL, 0}
};
if (ch == NULL)
return (int) ' ';
for (i = 0; lines_codes[i].line; i++) {
if (strcmp (ch, lines_codes[i].line) == 0)
return lines_codes[i].line_code;
}
return (int) ' ';
}
/* --------------------------------------------------------------------------------------------- */
void
tty_init (gboolean slow, gboolean ugly_lines)
{
slow_tty = slow;
(void) ugly_lines;
initscr ();
@ -115,11 +146,6 @@ tty_init (gboolean slow, gboolean ugly_lines)
keypad (stdscr, TRUE);
nodelay (stdscr, FALSE);
if (ugly_lines) {
int i;
for (i = 0; acs_approx[i].acscode != 0; i++)
acs_map[acs_approx[i].acscode] = acs_approx[i].character;
}
}
void
@ -179,7 +205,7 @@ tty_nodelay (gboolean set)
int
tty_baudrate (void)
{
return baudrate();
return baudrate ();
}
int
@ -216,9 +242,8 @@ tty_getyx (int *py, int *px)
void
tty_draw_hline (int y, int x, int ch, int len)
{
if (ch == ACS_HLINE && slow_tty) {
ch = ugly_frm_thinhoriz;
}
if ((chtype) ch == ACS_HLINE)
ch = mc_tty_ugly_frm[MC_TTY_FRM_thinhoriz];
if ((y >= 0) && (x >= 0))
move (y, x);
@ -229,35 +254,14 @@ tty_draw_hline (int y, int x, int ch, int len)
void
tty_draw_vline (int y, int x, int ch, int len)
{
if ((chtype) ch == ACS_VLINE)
ch = mc_tty_ugly_frm[MC_TTY_FRM_thinvert];
if ((y >= 0) && (x >= 0))
move (y, x);
vline (ch, len);
}
void
tty_draw_box (int y, int x, int rows, int cols)
{
if (slow_tty) {
tty_draw_box_slow (y, x, rows, cols);
} else {
#define waddc(_y, _x, c) move (_y, _x); addch (c)
waddc (y, x, ACS_ULCORNER);
hline (ACS_HLINE, cols - 2);
waddc (y + rows - 1, x, ACS_LLCORNER);
hline (ACS_HLINE, cols - 2);
waddc (y, x + cols - 1, ACS_URCORNER);
waddc (y + rows - 1, x + cols - 1, ACS_LRCORNER);
move (y + 1, x);
vline (ACS_VLINE, rows - 2);
move (y + 1, x + cols - 1);
vline (ACS_VLINE, rows - 2);
#undef waddc
}
}
void
tty_fill_region (int y, int x, int rows, int cols, unsigned char ch)
{
@ -294,23 +298,15 @@ tty_print_anychar (int c)
{
unsigned char str[6 + 1];
if (c == ACS_RTEE && (ugly_line_drawing || slow_tty)) {
c = ugly_frm_rightmiddle;
}
if (c == ACS_LTEE && (ugly_line_drawing || slow_tty)) {
c = ugly_frm_leftmiddle;
}
if ( c > 255 ) {
int res = g_unichar_to_utf8 (c, (char *)str);
if ( res == 0 ) {
if (c > 255) {
int res = g_unichar_to_utf8 (c, (char *) str);
if (res == 0) {
str[0] = '.';
str[1] = '\0';
} else {
str[res] = '\0';
}
addstr (str_term_form (str));
addstr (str_term_form ((char *) str));
} else {
addch (c);
}
@ -319,6 +315,25 @@ tty_print_anychar (int c)
void
tty_print_alt_char (int c)
{
if ((chtype) c == ACS_VLINE)
c = mc_tty_ugly_frm[MC_TTY_FRM_thinvert];
else if ((chtype) c == ACS_HLINE)
c = mc_tty_ugly_frm[MC_TTY_FRM_thinhoriz];
else if ((chtype) c == ACS_LTEE)
c = mc_tty_ugly_frm[MC_TTY_FRM_leftmiddle];
else if ((chtype) c == ACS_RTEE)
c = mc_tty_ugly_frm[MC_TTY_FRM_rightmiddle];
else if ((chtype) c == ACS_ULCORNER)
c = mc_tty_ugly_frm[MC_TTY_FRM_lefttop];
else if ((chtype) c == ACS_LLCORNER)
c = mc_tty_ugly_frm[MC_TTY_FRM_leftbottom];
else if ((chtype) c == ACS_URCORNER)
c = mc_tty_ugly_frm[MC_TTY_FRM_righttop];
else if ((chtype) c == ACS_LRCORNER)
c = mc_tty_ugly_frm[MC_TTY_FRM_rightbottom];
else if ((chtype) c == ACS_PLUS)
c = mc_tty_ugly_frm[MC_TTY_FRM_centermiddle];
addch (c);
}

View File

@ -44,7 +44,7 @@
#include "../../src/global.h"
#include "../../src/tty/tty-internal.h" /* slow_tty */
#include "../../src/tty/tty.h" /* tty_draw_box_slow */
#include "../../src/tty/tty.h"
#include "../../src/tty/color-slang.h"
#include "../../src/tty/color-internal.h"
#include "../../src/tty/mouse.h" /* Gpm_Event is required in key.h */
@ -99,40 +99,41 @@ static gboolean no_slang_delay;
static const struct {
int key_code;
const char *key_name;
} key_table [] = {
{ KEY_F(0), "k0" },
{ KEY_F(1), "k1" },
{ KEY_F(2), "k2" },
{ KEY_F(3), "k3" },
{ KEY_F(4), "k4" },
{ KEY_F(5), "k5" },
{ KEY_F(6), "k6" },
{ KEY_F(7), "k7" },
{ KEY_F(8), "k8" },
{ KEY_F(9), "k9" },
{ KEY_F(10), "k;" },
{ KEY_F(11), "F1" },
{ KEY_F(12), "F2" },
{ KEY_F(13), "F3" },
{ KEY_F(14), "F4" },
{ KEY_F(15), "F5" },
{ KEY_F(16), "F6" },
{ KEY_F(17), "F7" },
{ KEY_F(18), "F8" },
{ KEY_F(19), "F9" },
{ KEY_F(20), "FA" },
{ KEY_IC, "kI" },
{ KEY_NPAGE, "kN" },
{ KEY_PPAGE, "kP" },
{ KEY_LEFT, "kl" },
{ KEY_RIGHT, "kr" },
{ KEY_UP, "ku" },
{ KEY_DOWN, "kd" },
{ KEY_DC, "kD" },
{ KEY_BACKSPACE, "kb" },
{ KEY_HOME, "kh" },
{ KEY_END, "@7" },
{ 0, NULL }
} key_table[] = {
{
KEY_F (0), "k0"}, {
KEY_F (1), "k1"}, {
KEY_F (2), "k2"}, {
KEY_F (3), "k3"}, {
KEY_F (4), "k4"}, {
KEY_F (5), "k5"}, {
KEY_F (6), "k6"}, {
KEY_F (7), "k7"}, {
KEY_F (8), "k8"}, {
KEY_F (9), "k9"}, {
KEY_F (10), "k;"}, {
KEY_F (11), "F1"}, {
KEY_F (12), "F2"}, {
KEY_F (13), "F3"}, {
KEY_F (14), "F4"}, {
KEY_F (15), "F5"}, {
KEY_F (16), "F6"}, {
KEY_F (17), "F7"}, {
KEY_F (18), "F8"}, {
KEY_F (19), "F9"}, {
KEY_F (20), "FA"}, {
KEY_IC, "kI"}, {
KEY_NPAGE, "kN"}, {
KEY_PPAGE, "kP"}, {
KEY_LEFT, "kl"}, {
KEY_RIGHT, "kr"}, {
KEY_UP, "ku"}, {
KEY_DOWN, "kd"}, {
KEY_DC, "kD"}, {
KEY_BACKSPACE, "kb"}, {
KEY_HOME, "kh"}, {
KEY_END, "@7"}, {
0, NULL}
};
/*** file scope functions **********************************************/
@ -165,8 +166,7 @@ slang_reset_softkeys (void)
send = (char *) SLtt_tgetstr (tmp);
if (send != NULL) {
g_snprintf (tmp, sizeof (tmp), "\033&f%dk%dd%dL%s%s", key,
(int) (sizeof (display) - 1), (int) strlen (send),
display, send);
(int) (sizeof (display) - 1), (int) strlen (send), display, send);
SLtt_write_string (tmp);
}
}
@ -187,12 +187,59 @@ load_terminfo_keys (void)
{
int i;
for (i = 0; key_table [i].key_code; i++)
do_define_key (key_table [i].key_code, key_table [i].key_name);
for (i = 0; key_table[i].key_code; i++)
do_define_key (key_table[i].key_code, key_table[i].key_name);
}
/*** public functions **************************************************/
static char *
mc_tty_normalize_from_utf8 (const char *str)
{
GIConv conv;
GString *buffer;
const char *_system_codepage = str_detect_termencoding ();
if (str_isutf8 (_system_codepage))
return g_strdup (str);
conv = g_iconv_open (_system_codepage, "UTF-8");
if (conv == INVALID_CONV)
return g_strdup (str);
buffer = g_string_new ("");
if (str_convert (conv, str, buffer) == ESTR_FAILURE) {
g_string_free (buffer, TRUE);
str_close_conv (conv);
return g_strdup (str);
}
str_close_conv (conv);
return g_string_free (buffer, FALSE);
}
/* --------------------------------------------------------------------------------------------- */
/*** public functions **************************************************/
/* --------------------------------------------------------------------------------------------- */
int
mc_tty_normalize_lines_char (const char *str)
{
char *str2;
int res;
if (!str)
return (int) ' ';
str2 = mc_tty_normalize_from_utf8 (str);
res = g_utf8_get_char_validated (str2, -1);
if (res < 0)
res = (unsigned char) str2[0];
g_free (str2);
return res;
}
/* --------------------------------------------------------------------------------------------- */
void
tty_init (gboolean slow, gboolean ugly_lines)
{
@ -212,14 +259,13 @@ tty_init (gboolean slow, gboolean ugly_lines)
|| (COLS > SLTT_MAX_SCREEN_COLS) || (LINES > SLTT_MAX_SCREEN_ROWS)) {
fprintf (stderr,
_("Screen size %dx%d is not supported.\n"
"Check the TERM environment variable.\n"),
COLS, LINES);
"Check the TERM environment variable.\n"), COLS, LINES);
exit (1);
}
tcgetattr (fileno (stdin), &boot_mode);
/* 255 = ignore abort char; XCTRL('g') for abort char = ^g */
SLang_init_tty (XCTRL('c'), 1, 0);
SLang_init_tty (XCTRL ('c'), 1, 0);
if (ugly_lines)
SLtt_Has_Alt_Charset = 0;
@ -270,7 +316,7 @@ tty_shutdown (void)
* active when the program was started up
*/
op_cap = SLtt_tgetstr ((char *) "op");
if (op_cap != NULL){
if (op_cap != NULL) {
fputs (op_cap, stdout);
fflush (stdout);
}
@ -387,9 +433,8 @@ tty_getyx (int *py, int *px)
void
tty_draw_hline (int y, int x, int ch, int len)
{
if (ch == ACS_HLINE && (ugly_line_drawing || slow_tty)) {
if (ch == ACS_HLINE)
ch = mc_tty_ugly_frm[MC_TTY_FRM_thinhoriz];
}
if ((y < 0) || (x < 0)) {
y = SLsmg_get_row ();
@ -413,6 +458,9 @@ tty_draw_hline (int y, int x, int ch, int len)
void
tty_draw_vline (int y, int x, int ch, int len)
{
if (ch == ACS_VLINE)
ch = mc_tty_ugly_frm[MC_TTY_FRM_thinvert];
if ((y < 0) || (x < 0)) {
y = SLsmg_get_row ();
x = SLsmg_get_column ();
@ -437,16 +485,6 @@ tty_draw_vline (int y, int x, int ch, int len)
SLsmg_gotorc (y, x);
}
void
tty_draw_box (int y, int x, int rows, int cols)
{
/* this fix slang drawing stickchars bug */
if (ugly_line_drawing || slow_tty)
tty_draw_box_slow (y, x, rows, cols);
else
SLsmg_draw_box (y, x, rows, cols);
}
void
tty_fill_region (int y, int x, int rows, int cols, unsigned char ch)
{
@ -474,18 +512,41 @@ tty_print_char (int c)
void
tty_print_alt_char (int c)
{
if (c == ACS_RTEE && (ugly_line_drawing || slow_tty)) {
c = mc_tty_ugly_frm[MC_TTY_FRM_rightmiddle];
}
if (c == ACS_LTEE && (ugly_line_drawing || slow_tty)) {
c = mc_tty_ugly_frm[MC_TTY_FRM_leftmiddle];
}
if (ugly_line_drawing || slow_tty) {
tty_print_char (c);
} else {
SLsmg_draw_object (SLsmg_get_row(), SLsmg_get_column(), c);
#define DRAW(x, y) (x == y) \
? SLsmg_draw_object (SLsmg_get_row(), SLsmg_get_column(), x) \
: SLsmg_write_char ((unsigned int) y)
switch (c) {
case ACS_VLINE:
DRAW (c, mc_tty_ugly_frm[MC_TTY_FRM_thinvert]);
break;
case ACS_HLINE:
DRAW (c, mc_tty_ugly_frm[MC_TTY_FRM_thinhoriz]);
break;
case ACS_LTEE:
DRAW (c, mc_tty_ugly_frm[MC_TTY_FRM_leftmiddle]);
break;
case ACS_RTEE:
DRAW (c, mc_tty_ugly_frm[MC_TTY_FRM_rightmiddle]);
break;
case ACS_ULCORNER:
DRAW (c, mc_tty_ugly_frm[MC_TTY_FRM_lefttop]);
break;
case ACS_LLCORNER:
DRAW (c, mc_tty_ugly_frm[MC_TTY_FRM_leftbottom]);
break;
case ACS_URCORNER:
DRAW (c, mc_tty_ugly_frm[MC_TTY_FRM_righttop]);
break;
case ACS_LRCORNER:
DRAW (c, mc_tty_ugly_frm[MC_TTY_FRM_rightbottom]);
break;
case ACS_PLUS:
DRAW (c, mc_tty_ugly_frm[MC_TTY_FRM_centermiddle]);
break;
default:
SLsmg_write_char ((unsigned int) c);
}
#undef DRAW
}
void
@ -493,9 +554,9 @@ tty_print_anychar (int c)
{
char str[6 + 1];
if ( c > 255 ) {
if (c > 255) {
int res = g_unichar_to_utf8 (c, str);
if ( res == 0 ) {
if (res == 0) {
str[0] = '.';
str[1] = '\0';
} else {

View File

@ -25,6 +25,7 @@ enum {
#define ACS_LLCORNER SLSMG_LLCORN_CHAR
#define ACS_URCORNER SLSMG_URCORN_CHAR
#define ACS_LRCORNER SLSMG_LRCORN_CHAR
#define ACS_PLUS SLSMG_PLUS_CHAR
#define COLS SLtt_Screen_Cols
#define LINES SLtt_Screen_Rows

View File

@ -49,7 +49,7 @@ gboolean slow_tty = FALSE;
/* If true use +, -, | for line drawing */
gboolean ugly_line_drawing = FALSE;
int mc_tty_ugly_frm[] = { '|', '-', '|', '-', '+', '+', '+', '+', '+', '+'};
int mc_tty_ugly_frm[MC_TTY_FRM_MAX];
/*** file scope macro definitions **************************************/
@ -62,7 +62,7 @@ static volatile sig_atomic_t got_interrupt = 0;
/*** file scope functions **********************************************/
static void
sigintr_handler(int signo)
sigintr_handler (int signo)
{
(void) &signo;
got_interrupt = 1;
@ -77,7 +77,7 @@ tty_is_slow (void)
}
extern void
tty_start_interrupt_key(void)
tty_start_interrupt_key (void)
{
struct sigaction act;
@ -88,7 +88,7 @@ tty_start_interrupt_key(void)
}
extern void
tty_enable_interrupt_key(void)
tty_enable_interrupt_key (void)
{
struct sigaction act;
@ -100,7 +100,7 @@ tty_enable_interrupt_key(void)
}
extern void
tty_disable_interrupt_key(void)
tty_disable_interrupt_key (void)
{
struct sigaction act;
@ -111,7 +111,7 @@ tty_disable_interrupt_key(void)
}
extern gboolean
tty_got_interrupt(void)
tty_got_interrupt (void)
{
gboolean rv;
@ -123,34 +123,28 @@ tty_got_interrupt(void)
void
tty_print_one_hline (void)
{
if (ugly_line_drawing || slow_tty)
tty_print_char (mc_tty_ugly_frm[MC_TTY_FRM_thinhoriz]);
else
tty_print_alt_char (ACS_HLINE);
tty_print_alt_char (mc_tty_ugly_frm[MC_TTY_FRM_thinhoriz]);
}
void
tty_print_one_vline (void)
{
if (ugly_line_drawing || slow_tty)
tty_print_char (mc_tty_ugly_frm[MC_TTY_FRM_thinvert]);
else
tty_print_alt_char (ACS_VLINE);
tty_print_alt_char (mc_tty_ugly_frm[MC_TTY_FRM_thinvert]);
}
void
tty_draw_box_slow (int y, int x, int ys, int xs)
tty_draw_box (int y, int x, int ys, int xs)
{
tty_draw_vline (y, x, mc_tty_ugly_frm[MC_TTY_FRM_vert], ys);
tty_draw_vline (y, x + xs - 1, mc_tty_ugly_frm[MC_TTY_FRM_vert], ys);
tty_draw_hline (y, x, mc_tty_ugly_frm[MC_TTY_FRM_horiz], xs);
tty_draw_hline (y + ys - 1, x, mc_tty_ugly_frm[MC_TTY_FRM_horiz], xs);
tty_gotoyx (y, x);
tty_print_char (mc_tty_ugly_frm[MC_TTY_FRM_lefttop]);
tty_print_alt_char (mc_tty_ugly_frm[MC_TTY_FRM_lefttop]);
tty_gotoyx (y + ys - 1, x);
tty_print_char (mc_tty_ugly_frm[MC_TTY_FRM_leftbottom]);
tty_print_alt_char (mc_tty_ugly_frm[MC_TTY_FRM_leftbottom]);
tty_gotoyx (y, x + xs - 1);
tty_print_char (mc_tty_ugly_frm[MC_TTY_FRM_righttop]);
tty_print_alt_char (mc_tty_ugly_frm[MC_TTY_FRM_righttop]);
tty_gotoyx (y + ys - 1, x + xs - 1);
tty_print_char (mc_tty_ugly_frm[MC_TTY_FRM_rightbottom]);
tty_print_alt_char (mc_tty_ugly_frm[MC_TTY_FRM_rightbottom]);
}

View File

@ -26,10 +26,10 @@ extern void tty_shutdown (void);
extern gboolean tty_is_slow (void);
extern void tty_start_interrupt_key(void);
extern void tty_enable_interrupt_key(void);
extern void tty_disable_interrupt_key(void);
extern gboolean tty_got_interrupt(void);
extern void tty_start_interrupt_key (void);
extern void tty_enable_interrupt_key (void);
extern void tty_disable_interrupt_key (void);
extern gboolean tty_got_interrupt (void);
extern void tty_reset_prog_mode (void);
extern void tty_reset_shell_mode (void);
@ -57,29 +57,28 @@ extern int tty_lowlevel_getch (void);
extern int tty_reset_screen (void);
extern void tty_touch_screen (void);
extern void tty_gotoyx(int y, int x);
extern void tty_getyx(int *py, int *px);
extern void tty_gotoyx (int y, int x);
extern void tty_getyx (int *py, int *px);
extern void tty_set_alt_charset (gboolean alt_charset);
extern void tty_display_8bit (gboolean what);
extern void tty_print_char(int c);
extern void tty_print_alt_char(int c);
extern void tty_print_anychar(int c);
extern void tty_print_string(const char *s);
extern void tty_printf(const char *s, ...);
extern void tty_print_char (int c);
extern void tty_print_alt_char (int c);
extern void tty_print_anychar (int c);
extern void tty_print_string (const char *s);
extern void tty_printf (const char *s, ...);
extern void tty_print_one_vline (void);
extern void tty_print_one_hline (void);
extern void tty_draw_hline (int y, int x, int ch, int len);
extern void tty_draw_vline (int y, int x, int ch, int len);
extern void tty_draw_box (int y, int x, int rows, int cols);
extern void tty_draw_box_slow (int y, int x, int ys, int xs);
extern void tty_fill_region (int y, int x, int rows, int cols, unsigned char ch);
extern int mc_tty_ugly_frm[];
typedef enum{
typedef enum {
MC_TTY_FRM_thinvert,
MC_TTY_FRM_thinhoriz,
MC_TTY_FRM_vert,
@ -88,8 +87,12 @@ typedef enum{
MC_TTY_FRM_righttop,
MC_TTY_FRM_leftbottom,
MC_TTY_FRM_rightbottom,
MC_TTY_FRM_centertop,
MC_TTY_FRM_centerbottom,
MC_TTY_FRM_leftmiddle,
MC_TTY_FRM_rightmiddle
MC_TTY_FRM_rightmiddle,
MC_TTY_FRM_centermiddle,
MC_TTY_FRM_MAX
} mc_tty_frm_t;
extern char *tty_tgetstr (const char *name);
@ -103,4 +106,6 @@ extern void tty_beep (void);
extern void tty_refresh (void);
extern void tty_setup_sigwinch (void (*handler) (int));
extern int mc_tty_normalize_lines_char (const char *);
#endif /* MC_TTY_H */

View File

@ -62,13 +62,11 @@ rxvt_getc (void)
int r;
unsigned char c;
while (read (0, &c, 1) != 1)
;
while (read (0, &c, 1) != 1);
if (c == '\n')
return -1;
r = (c - 'A') * 16;
while (read (0, &c, 1) != 1)
;
while (read (0, &c, 1) != 1);
r += (c - 'A');
return r;
}
@ -118,9 +116,7 @@ show_rxvt_contents (int starty, unsigned char y1, unsigned char y2)
tty_lowlevel_getch ();
/* my own wierd protocol base 26 - paul */
printf ("\033CL%c%c%c%c\n",
(y1 / 26) + 'A', (y1 % 26) + 'A',
(y2 / 26) + 'A', (y2 % 26) + 'A');
printf ("\033CL%c%c%c%c\n", (y1 / 26) + 'A', (y1 % 26) + 'A', (y2 / 26) + 'A', (y2 % 26) + 'A');
bytes = (y2 - y1) * (COLS + 1) + 1; /* *should* be the number of bytes read */
j = 0;
@ -132,7 +128,7 @@ show_rxvt_contents (int starty, unsigned char y1, unsigned char y2)
break;
if (j < bytes)
k[j++] = c;
for (cols = 1; ; cols++) {
for (cols = 1;; cols++) {
c = rxvt_getc ();
if (c < 0)
break;

View File

@ -51,7 +51,7 @@ typedef int (*mc_XIOErrorHandler_callback) (Display *);
#ifdef HAVE_GMODULE
static Display * (*func_XOpenDisplay) (_Xconst char *);
static Display *(*func_XOpenDisplay) (_Xconst char *);
static int (*func_XCloseDisplay) (Display *);
static mc_XErrorHandler_callback (*func_XSetErrorHandler)
(mc_XErrorHandler_callback);
@ -84,35 +84,40 @@ static gboolean longjmp_allowed = FALSE;
/*** file private functions ********************************************/
static int x_io_error_handler (Display *dpy)
static int
x_io_error_handler (Display * dpy)
{
(void) dpy;
lost_connection = TRUE;
if (longjmp_allowed) {
longjmp_allowed = FALSE;
longjmp(x11_exception, 1);
longjmp (x11_exception, 1);
}
return 0;
}
static int x_error_handler (Display *dpy, XErrorEvent *ee)
static int
x_error_handler (Display * dpy, XErrorEvent * ee)
{
(void) ee;
(void) func_XCloseDisplay (dpy);
return x_io_error_handler (dpy);
}
static void install_error_handlers(void)
static void
install_error_handlers (void)
{
if (handlers_installed) return;
if (handlers_installed)
return;
(void) func_XSetErrorHandler (x_error_handler);
(void) func_XSetIOErrorHandler (x_io_error_handler);
handlers_installed = TRUE;
}
static gboolean x11_available(void)
static gboolean
x11_available (void)
{
#ifdef HAVE_GMODULE
gchar *x11_module_fname;
@ -133,26 +138,21 @@ static gboolean x11_available(void)
if (x11_module == NULL)
return FALSE;
if (!g_module_symbol (x11_module, "XOpenDisplay",
(void *) &func_XOpenDisplay))
if (!g_module_symbol (x11_module, "XOpenDisplay", (void *) &func_XOpenDisplay))
goto cleanup;
if (!g_module_symbol (x11_module, "XCloseDisplay",
(void *) &func_XCloseDisplay))
if (!g_module_symbol (x11_module, "XCloseDisplay", (void *) &func_XCloseDisplay))
goto cleanup;
if (!g_module_symbol (x11_module, "XQueryPointer",
(void *) &func_XQueryPointer))
if (!g_module_symbol (x11_module, "XQueryPointer", (void *) &func_XQueryPointer))
goto cleanup;
if (!g_module_symbol (x11_module, "XSetErrorHandler",
(void *) &func_XSetErrorHandler))
if (!g_module_symbol (x11_module, "XSetErrorHandler", (void *) &func_XSetErrorHandler))
goto cleanup;
if (!g_module_symbol (x11_module, "XSetIOErrorHandler",
(void *) &func_XSetIOErrorHandler))
if (!g_module_symbol (x11_module, "XSetIOErrorHandler", (void *) &func_XSetIOErrorHandler))
goto cleanup;
install_error_handlers();
install_error_handlers ();
return TRUE;
cleanup:
cleanup:
func_XOpenDisplay = 0;
func_XCloseDisplay = 0;
func_XQueryPointer = 0;
@ -162,19 +162,20 @@ cleanup:
x11_module = NULL;
return FALSE;
#else
install_error_handlers();
install_error_handlers ();
return !(lost_connection);
#endif
}
/*** public functions **************************************************/
Display *mc_XOpenDisplay (const char *displayname)
Display *
mc_XOpenDisplay (const char *displayname)
{
Display *retval;
if (x11_available()) {
if (setjmp(x11_exception) == 0) {
if (x11_available ()) {
if (setjmp (x11_exception) == 0) {
longjmp_allowed = TRUE;
retval = func_XOpenDisplay (displayname);
longjmp_allowed = FALSE;
@ -184,12 +185,13 @@ Display *mc_XOpenDisplay (const char *displayname)
return NULL;
}
int mc_XCloseDisplay (Display *display)
int
mc_XCloseDisplay (Display * display)
{
int retval;
if (x11_available()) {
if (setjmp(x11_exception) == 0) {
if (x11_available ()) {
if (setjmp (x11_exception) == 0) {
longjmp_allowed = TRUE;
retval = func_XCloseDisplay (display);
longjmp_allowed = FALSE;
@ -199,14 +201,15 @@ int mc_XCloseDisplay (Display *display)
return 0;
}
Bool mc_XQueryPointer (Display *display, Window win, Window *root_return,
Window *child_return, int *root_x_return, int *root_y_return,
Bool
mc_XQueryPointer (Display * display, Window win, Window * root_return,
Window * child_return, int *root_x_return, int *root_y_return,
int *win_x_return, int *win_y_return, unsigned int *mask_return)
{
Bool retval;
if (x11_available()) {
if (setjmp(x11_exception) == 0) {
if (x11_available ()) {
if (setjmp (x11_exception) == 0) {
longjmp_allowed = TRUE;
retval = func_XQueryPointer (display, win, root_return,
child_return, root_x_return, root_y_return,

View File

@ -30,7 +30,7 @@
#include "global.h"
#include "../src/tty/tty.h"
#include "../src/tty/color.h"
#include "../src/skin/skin.h"
#include "dir.h"
#include "panel.h"
#include "main.h"

View File

@ -38,7 +38,7 @@
#include <config.h>
#include "../src/global.h"
#include "../src/tty/color.h"
#include "../src/skin/skin.h"
#include "../src/tty/tty.h"
#include "../src/tty/key.h"
#include "../src/strutil.h"

View File

@ -42,7 +42,7 @@
#include "../src/global.h"
#include "../src/tty/tty.h"
#include "../src/tty/color.h"
#include "../src/skin/skin.h"
#include "../src/main.h"
#include "../src/wtools.h"
#include "../src/charsets.h"

View File

@ -41,7 +41,7 @@
#include "../src/main.h"
#include "../src/charsets.h"
#include "../src/tty/tty.h"
#include "../src/tty/color.h"
#include "../src/skin/skin.h"
#include "internal.h"

View File

@ -41,7 +41,7 @@
#include "../src/main.h"
#include "../src/charsets.h"
#include "../src/tty/tty.h"
#include "../src/tty/color.h"
#include "../src/skin/skin.h"
#include "internal.h"
/*** global variables ****************************************************************************/

View File

@ -43,7 +43,7 @@
#include "global.h"
#include "../src/tty/tty.h"
#include "../src/tty/color.h"
#include "../src/skin/skin.h"
#include "../src/tty/mouse.h"
#include "../src/tty/key.h" /* XCTRL and ALT macros */

View File

@ -36,7 +36,7 @@
#include "global.h"
#include "../src/tty/tty.h"
#include "../src/tty/color.h" /* INPUT_COLOR */
#include "../src/skin/skin.h" /* INPUT_COLOR */
#include "../src/tty/key.h" /* tty_getch() */
#include "dialog.h"