1
1

Reidentation of code and changes for compile with CFLAGS="-pedantic -Wall -Wextra -Werror -Wno-long-long"

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
Этот коммит содержится в:
Slava Zanko 2009-09-17 01:07:04 +03:00
родитель bdfc9adf39
Коммит 84f502a2e1
24 изменённых файлов: 1544 добавлений и 1600 удалений

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

@ -98,10 +98,10 @@ mc_skin_colors_old_transform (const char *old_color, const char **group, const c
if (group != NULL)
*group = old_colors[index].group;
if (key != NULL)
*key = old_colors[index].key;
*key = old_colors[index].key;
return TRUE;
}
}
}
return FALSE;
}

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

@ -26,9 +26,9 @@
#include <config.h>
#include <string.h> /* strcmp */
#include <string.h> /* strcmp */
#include "../../src/tty/color.h" /* colors and attributes */
#include "../../src/tty/color.h" /* colors and attributes */
#include "../../src/tty/color-internal.h"
/*** global variables ****************************************************************************/
@ -41,12 +41,12 @@ gboolean mc_tty_color_disable;
typedef struct mc_tty_color_table_struct {
const char *name;
int value;
int value;
} mc_tty_color_table_t;
/*** file scope variables ************************************************************************/
mc_tty_color_table_t const color_table [] = {
mc_tty_color_table_t const color_table[] = {
{ "black", COLOR_BLACK },
{ "gray", COLOR_BLACK | A_BOLD },
{ "red", COLOR_RED },
@ -85,9 +85,9 @@ tty_color_get_valid_name (const char *color_name)
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;
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;
}
@ -99,9 +99,9 @@ tty_color_get_index_by_name (const char *color_name)
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;
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;
}

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

@ -6,7 +6,7 @@
#ifndef MC_COLOR_INTERNAL_H
#define MC_COLOR_INTERNAL_H
#include <sys/types.h> /* size_t */
#include <sys/types.h> /* size_t */
#include "../../src/global.h"
@ -14,7 +14,7 @@
# include "../../src/tty/tty-slang.h"
#else
# include "../../src/tty/tty-ncurses.h"
#endif /* HAVE_SLANG */
#endif /* HAVE_SLANG */
extern gboolean use_colors;
extern gboolean mc_tty_color_disable;
@ -28,8 +28,7 @@ typedef struct mc_color_pair_struct {
gboolean is_temp;
} tty_color_pair_t;
typedef enum
{
typedef enum {
SPEC_A_REVERSE = -100,
SPEC_A_BOLD = -101,
SPEC_A_BOLD_REVERSE = -102,
@ -44,4 +43,4 @@ void tty_color_deinit_lib (void);
void tty_color_try_alloc_pair_lib (tty_color_pair_t *);
#endif /* MC_COLOR_INTERNAL_H */
#endif /* MC_COLOR_INTERNAL_H */

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

@ -28,12 +28,12 @@
#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"
#include "../../src/tty/tty-ncurses.h"
#include "../../src/tty/color.h" /* variables */
#include "../../src/tty/color.h" /* variables */
#include "../../src/tty/color-internal.h"
/*** global variables ****************************************************************************/
@ -61,20 +61,19 @@ static int
mc_tty_color_save_attr_lib (int color_pair, int color_attr)
{
int *attr, *key;
attr = g_new0(int,1);
attr = g_new0 (int, 1);
if (attr == NULL)
return color_attr;
return color_attr;
key = g_new0(int,1);
if (key == NULL)
{
g_free(attr);
return color_attr;
key = g_new0 (int, 1);
if (key == NULL) {
g_free (attr);
return color_attr;
}
memcpy(key,&color_pair,sizeof(int));
memcpy (key, &color_pair, sizeof (int));
if (color_attr != -1)
*attr = color_attr & (A_BOLD | A_REVERSE | A_UNDERLINE);
*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));
}
@ -87,41 +86,30 @@ color_get_attr (int color_pair)
int *fnd;
if (mc_tty_color_color_pair_attrs == NULL)
return 0;
return 0;
fnd = (int *) g_hash_table_lookup (mc_tty_color_color_pair_attrs, (gpointer) &color_pair);
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)
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 (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);
else {
SLtt_set_mono (mc_color_pair->pair_index, NULL, mask);
}
#endif
}
@ -136,17 +124,13 @@ tty_color_init_lib (gboolean disable, gboolean force)
(void) force;
if (has_colors () && !disable) {
use_colors = TRUE;
start_color ();
use_default_colors ();
use_colors = TRUE;
start_color ();
use_default_colors ();
}
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
);
(g_int_hash, g_int_equal, mc_tty_color_attr_destroy_cb, mc_tty_color_attr_destroy_cb);
}
/* --------------------------------------------------------------------------------------------- */
@ -161,52 +145,37 @@ tty_color_deinit_lib (void)
/* --------------------------------------------------------------------------------------------- */
void
tty_color_try_alloc_pair_lib (tty_color_pair_t *mc_color_pair)
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:
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;
}
}
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);
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;
}
} 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);
}
}

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

@ -28,15 +28,15 @@
#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"
#include "../../src/tty/tty-slang.h"
#include "../../src/tty/color.h" /* variables */
#include "../../src/tty/color.h" /* variables */
#include "../../src/tty/color-internal.h"
#include "../../src/setup.h" /* color_terminal_string */
#include "../../src/setup.h" /* color_terminal_string */
static int
has_colors (gboolean disable, gboolean force)
@ -44,59 +44,51 @@ has_colors (gboolean disable, gboolean force)
mc_tty_color_disable = disable;
if (force || (getenv ("COLORTERM") != NULL))
SLtt_Use_Ansi_Colors = 1;
SLtt_Use_Ansi_Colors = 1;
if (!mc_tty_color_disable)
{
const char *terminal = getenv ("TERM");
const size_t len = strlen (terminal);
if (!mc_tty_color_disable) {
const char *terminal = getenv ("TERM");
const size_t len = strlen (terminal);
char *cts = color_terminal_string;
char *s;
size_t i;
char *cts = color_terminal_string;
char *s;
size_t i;
/* check color_terminal_string */
while (*cts != '\0') {
while (*cts == ' ' || *cts == '\t')
cts++;
s = cts;
i = 0;
/* check color_terminal_string */
while (*cts != '\0') {
while (*cts == ' ' || *cts == '\t')
cts++;
s = cts;
i = 0;
while (*cts != '\0' && *cts != ',') {
cts++;
i++;
}
while (*cts != '\0' && *cts != ',') {
cts++;
i++;
}
if ((i != 0) && (i == len) && (strncmp (s, terminal, i) == 0))
SLtt_Use_Ansi_Colors = 1;
if ((i != 0) && (i == len) && (strncmp (s, terminal, i) == 0))
SLtt_Use_Ansi_Colors = 1;
if (*cts == ',')
cts++;
}
if (*cts == ',')
cts++;
}
}
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)
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);
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);
}
}
@ -106,7 +98,7 @@ 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) {
use_colors = TRUE;
use_colors = TRUE;
}
}
@ -116,53 +108,34 @@ tty_color_deinit_lib (void)
}
void
tty_color_try_alloc_pair_lib (tty_color_pair_t *mc_color_pair)
tty_color_try_alloc_pair_lib (tty_color_pair_t * mc_color_pair)
{
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:
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;
}
}
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);
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;
}
} 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);
}
}
@ -170,16 +143,16 @@ void
tty_setcolor (int color)
{
if (!SLtt_Use_Ansi_Colors)
SLsmg_set_color (color);
SLsmg_set_color (color);
else if ((color & A_BOLD) != 0) {
if (color == A_BOLD)
SLsmg_set_color (A_BOLD);
else
SLsmg_set_color ((color & (~A_BOLD)) + 8);
if (color == A_BOLD)
SLsmg_set_color (A_BOLD);
else
SLsmg_set_color ((color & (~A_BOLD)) + 8);
} else if (color == A_REVERSE)
SLsmg_set_color (A_REVERSE);
SLsmg_set_color (A_REVERSE);
else
SLsmg_set_color (color);
SLsmg_set_color (color);
}
/* Set colorpair by index, don't interpret S-Lang "emulated attributes" */

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

@ -6,7 +6,7 @@
#ifndef MC_COLOR_SLANG_H
#define MC_COLOR_SLANG_H
#include "../../src/tty/tty-slang.h" /* S-Lang headers */
#include "../../src/tty/tty-slang.h" /* S-Lang headers */
enum {
COLOR_BLACK = 0,
@ -31,4 +31,4 @@ enum {
# define A_NORMAL 0x00
#endif
#endif /* MC_COLOR_SLANG_H */
#endif /* MC_COLOR_SLANG_H */

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

@ -31,7 +31,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"
@ -81,17 +81,22 @@ color_hash_destroy_value (gpointer data)
static gboolean
tty_color_free_condition_cb (gpointer key, gpointer value, gpointer user_data)
{
gboolean is_temp_color = (gboolean) user_data;
tty_color_pair_t *mc_color_pair = (tty_color_pair_t *) value;
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)
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);
g_hash_table_foreach_remove (mc_tty_color__hashtable, tty_color_free_condition_cb,
(gpointer) is_temp_color);
}
/* --------------------------------------------------------------------------------------------- */
@ -99,11 +104,15 @@ tty_color_free_all(gboolean is_temp_color)
static gboolean
tty_color_get_next_cpn_cb (gpointer key, gpointer value, gpointer user_data)
{
int cp = (int) user_data;
tty_color_pair_t *mc_color_pair = (tty_color_pair_t *) value;
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 TRUE;
return FALSE;
}
@ -111,14 +120,15 @@ tty_color_get_next_cpn_cb (gpointer key, gpointer value, gpointer user_data)
/* --------------------------------------------------------------------------------------------- */
static int
tty_color_get_next__color_pair_number()
tty_color_get_next__color_pair_number ()
{
int cp_count = g_hash_table_size (mc_tty_color__hashtable);
int cp=0;
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;
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;
}
@ -132,8 +142,8 @@ tty_init_colors (gboolean disable, gboolean force)
{
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);
color_hash_destroy_key,
color_hash_destroy_value);
}
/* --------------------------------------------------------------------------------------------- */
@ -166,31 +176,30 @@ tty_try_alloc_color_pair2 (const char *fg, const char *bg, gboolean is_temp_colo
const char *c_fg, *c_bg;
if (fg == NULL)
fg = tty_color_defaults__fg;
fg = tty_color_defaults__fg;
if(bg == NULL)
{
bg = tty_color_defaults__bg;
}
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);
color_pair = g_strdup_printf ("%s.%s", c_fg, c_bg);
if (color_pair == NULL)
return 0;
return 0;
mc_color_pair = (tty_color_pair_t *) g_hash_table_lookup (mc_tty_color__hashtable, (gpointer) color_pair);
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;
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;
if (mc_color_pair == NULL) {
g_free (color_pair);
return 0;
}
mc_color_pair->is_temp = is_temp_color;
@ -198,7 +207,7 @@ tty_try_alloc_color_pair2 (const char *fg, const char *bg, gboolean is_temp_colo
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();
mc_color_pair->pair_index = tty_color_get_next__color_pair_number ();
tty_color_try_alloc_pair_lib (mc_color_pair);
@ -218,17 +227,17 @@ tty_try_alloc_color_pair (const char *fg, const char *bg)
/* --------------------------------------------------------------------------------------------- */
void
tty_color_free_all_tmp(void)
tty_color_free_all_tmp (void)
{
tty_color_free_all(TRUE);
tty_color_free_all (TRUE);
}
/* --------------------------------------------------------------------------------------------- */
void
tty_color_free_all_non_tmp(void)
tty_color_free_all_non_tmp (void)
{
tty_color_free_all(FALSE);
tty_color_free_all (FALSE);
}
/* --------------------------------------------------------------------------------------------- */
@ -236,8 +245,8 @@ tty_color_free_all_non_tmp(void)
void
tty_color_set_defaults (const char *fgcolor, const char *bgcolor)
{
g_free(tty_color_defaults__fg);
g_free(tty_color_defaults__fg);
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;

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

@ -12,7 +12,7 @@
#ifndef MC_COLOR_H
#define MC_COLOR_H
#include "../../src/global.h" /* glib.h */
#include "../../src/global.h" /* glib.h */
#ifdef HAVE_SLANG
# include "../../src/tty/color-slang.h"
@ -40,4 +40,4 @@ void tty_color_set_defaults (const char *, const char *);
#define ALLOC_COLOR_PAIR_INDEX 1
#endif /* MC_COLOR_H */
#endif /* MC_COLOR_H */

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -6,10 +6,10 @@
#ifndef MC_KEY_H
#define MC_KEY_H
#include "../../src/global.h" /* <glib.h> */
#include "../../src/dialog.h" /* cb_ret_t */
#include "../../src/global.h" /* <glib.h> */
#include "../../src/dialog.h" /* cb_ret_t */
#include "../../src/tty/tty.h" /* KEY_F macro */
#include "../../src/tty/tty.h" /* KEY_F macro */
gboolean define_sequence (int code, const char *seq, int action);
@ -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;
@ -62,7 +61,7 @@ extern int mou_auto_repeat;
typedef int (*select_fn) (int fd, void *info);
/* Channel manipulation */
void add_select_channel (int fd, select_fn callback, void *info);
void add_select_channel (int fd, select_fn callback, void *info);
void delete_select_channel (int fd);
void remove_select_channel (int fd);
@ -77,7 +76,7 @@ static inline gboolean
is_abort_char (int c)
{
return ((c == XCTRL ('c')) || (c == XCTRL ('g'))
|| (c == ESC_CHAR) || (c == KEY_F (10)));
|| (c == ESC_CHAR) || (c == KEY_F (10)));
}
/* To define sequences and return codes */
@ -101,4 +100,4 @@ int get_key_code (int nodelay);
void numeric_keypad_mode (void);
void application_keypad_mode (void);
#endif /* MC_KEY_H */
#endif /* MC_KEY_H */

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

@ -44,7 +44,7 @@
#include "../../src/global.h"
#include "../../src/tty/tty.h"
#include "../../src/tty/mouse.h" /* required before key.h */
#include "../../src/tty/mouse.h" /* required before key.h */
#include "../../src/tty/key.h"
#if defined (__QNX__) && !defined (__QNXNTO__)
@ -61,11 +61,11 @@
/* 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() */
#include <stdlib.h> /* getenv() */
/* fieldname -> index conversion */
#define __QTISX(_qtisn) \
@ -73,14 +73,14 @@
/* define the OS/implementation-specific __TK() format */
#define __TK(_tis,_tcs,_tisx,_qtisn) __QTISX(_qtisn)
#endif /* __USE_QNX_TI */
#endif /* HAVE_QNX_KEYS */
/* {{{ */
/* general key definitions:
*
* format:
@ -90,7 +90,7 @@
* index in the terminfo string table (ncurses),
* field name in the QNX terminfo strings struct
*/
#define Key_backspace __TK("kbs", "kb", 55, _ky_backspace )
#define Key_catab __TK("ktbc", "ka", 56, _ky_catab )
#define Key_clear __TK("kclr", "kC", 57, _ky_clear )
@ -247,7 +247,7 @@
/* don't force pre-defining of base keys under QNX */
#define FORCE_BASE_KEY_DEFS 0
/* OS specific key aliases */
#define Key_alt_a Key_clear
#define Key_alt_b Key_stab
@ -279,11 +279,11 @@
#define Key_ctl_enter Key_enter
#define Key_ctl_tab Key_ctab
#define Key_alt_tab Key_ctl_tab /* map ALT-TAB to CTRL-TAB */
#define Key_alt_enter Key_ctl_enter /* map ALT-ENTER to CTRL-ENTER */
#define Key_alt_tab Key_ctl_tab /* map ALT-TAB to CTRL-TAB */
#define Key_alt_enter Key_ctl_enter /* map ALT-ENTER to CTRL-ENTER */
#ifdef __USE_QNX_TI
/* OS/implementation specific key-define struct */
typedef const struct qnx_key_define_s {
int mc_code;
@ -307,70 +307,70 @@ 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 */
#endif /* xtra_key_define_t */
#ifdef HAVE_QNX_KEYS
@ -381,28 +381,25 @@ 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;
if (!_qnx_keys_defined) {
int idx, str_idx;
int term_setup_ok;
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
}

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

@ -34,9 +34,9 @@
#include "../../src/global.h"
#include "../../src/tty/tty.h"
#include "../../src/tty/tty-internal.h" /* mouse_enabled */
#include "../../src/tty/tty-internal.h" /* mouse_enabled */
#include "../../src/tty/mouse.h"
#include "../../src/tty/key.h" /* define sequence */
#include "../../src/tty/key.h" /* define sequence */
gboolean mouse_enabled = FALSE;
const char *xmouse_seq;
@ -46,7 +46,7 @@ show_mouse_pointer (int x, int y)
{
#ifdef HAVE_LIBGPM
if (use_mouse_p == MOUSE_GPM)
Gpm_DrawPointer (x, y, gpm_consolefd);
Gpm_DrawPointer (x, y, gpm_consolefd);
#endif /* HAVE_LIBGPM */
}
@ -56,17 +56,17 @@ init_mouse (void)
switch (use_mouse_p) {
#ifdef HAVE_LIBGPM
case MOUSE_NONE:
use_mouse_p = MOUSE_GPM;
break;
use_mouse_p = MOUSE_GPM;
break;
#endif /* HAVE_LIBGPM */
case MOUSE_XTERM_NORMAL_TRACKING:
case MOUSE_XTERM_BUTTON_EVENT_TRACKING:
define_sequence (MCKEY_MOUSE, xmouse_seq, MCKEY_NOACTION);
break;
define_sequence (MCKEY_MOUSE, xmouse_seq, MCKEY_NOACTION);
break;
default:
break;
break;
}
enable_mouse ();
@ -76,54 +76,54 @@ void
enable_mouse (void)
{
if (mouse_enabled)
return;
return;
switch (use_mouse_p) {
#ifdef HAVE_LIBGPM
case MOUSE_GPM:
{
int mouse_d;
Gpm_Connect conn;
{
int mouse_d;
Gpm_Connect conn;
conn.eventMask = ~GPM_MOVE;
conn.defaultMask = GPM_MOVE;
conn.minMod = 0;
conn.maxMod = 0;
conn.eventMask = ~GPM_MOVE;
conn.defaultMask = GPM_MOVE;
conn.minMod = 0;
conn.maxMod = 0;
mouse_d = Gpm_Open (&conn, 0);
if (mouse_d == -1) {
use_mouse_p = MOUSE_NONE;
return;
}
mouse_enabled = 1;
}
break;
mouse_d = Gpm_Open (&conn, 0);
if (mouse_d == -1) {
use_mouse_p = MOUSE_NONE;
return;
}
mouse_enabled = 1;
}
break;
#endif /* HAVE_LIBGPM */
case MOUSE_XTERM_NORMAL_TRACKING:
/* save old highlight mouse tracking */
printf(ESC_STR "[?1001s");
/* save old highlight mouse tracking */
printf (ESC_STR "[?1001s");
/* enable mouse tracking */
printf(ESC_STR "[?1000h");
/* enable mouse tracking */
printf (ESC_STR "[?1000h");
fflush (stdout);
mouse_enabled = TRUE;
break;
fflush (stdout);
mouse_enabled = TRUE;
break;
case MOUSE_XTERM_BUTTON_EVENT_TRACKING:
/* save old highlight mouse tracking */
printf(ESC_STR "[?1001s");
/* save old highlight mouse tracking */
printf (ESC_STR "[?1001s");
/* enable mouse tracking */
printf(ESC_STR "[?1002h");
/* enable mouse tracking */
printf (ESC_STR "[?1002h");
fflush (stdout);
mouse_enabled = TRUE;
break;
fflush (stdout);
mouse_enabled = TRUE;
break;
default:
break;
break;
}
}
@ -131,35 +131,35 @@ void
disable_mouse (void)
{
if (!mouse_enabled)
return;
return;
mouse_enabled = FALSE;
switch (use_mouse_p) {
#ifdef HAVE_LIBGPM
case MOUSE_GPM:
Gpm_Close ();
break;
Gpm_Close ();
break;
#endif
case MOUSE_XTERM_NORMAL_TRACKING:
/* disable mouse tracking */
printf(ESC_STR "[?1000l");
/* disable mouse tracking */
printf (ESC_STR "[?1000l");
/* restore old highlight mouse tracking */
printf(ESC_STR "[?1001r");
/* restore old highlight mouse tracking */
printf (ESC_STR "[?1001r");
fflush (stdout);
break;
fflush (stdout);
break;
case MOUSE_XTERM_BUTTON_EVENT_TRACKING:
/* disable mouse tracking */
printf(ESC_STR "[?1002l");
/* disable mouse tracking */
printf (ESC_STR "[?1002l");
/* restore old highlight mouse tracking */
printf(ESC_STR "[?1001r");
/* restore old highlight mouse tracking */
printf (ESC_STR "[?1001r");
fflush (stdout);
break;
fflush (stdout);
break;
default:
break;
break;
}
}

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

@ -26,25 +26,25 @@
/* 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
used event to pass over to another handler */
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 */
};
typedef struct Gpm_Event {
int buttons, x, y;
enum Gpm_Etype type;
int buttons, x, y;
enum Gpm_Etype type;
} Gpm_Event;
#endif /* !HAVE_LIBGPM */
@ -59,10 +59,10 @@ typedef int (*mouse_h) (Gpm_Event *, void *);
/* Type of mouse support */
typedef enum {
MOUSE_NONE, /* Not detected yet */
MOUSE_DISABLED, /* Explicitly disabled by -d */
MOUSE_GPM, /* Support using GPM on Linux */
MOUSE_XTERM, /* Support using xterm-style mouse reporting */
MOUSE_NONE, /* Not detected yet */
MOUSE_DISABLED, /* Explicitly disabled by -d */
MOUSE_GPM, /* Support using GPM on Linux */
MOUSE_XTERM, /* Support using xterm-style mouse reporting */
MOUSE_XTERM_NORMAL_TRACKING = MOUSE_XTERM,
MOUSE_XTERM_BUTTON_EVENT_TRACKING
} Mouse_Type;
@ -88,4 +88,4 @@ void disable_mouse (void);
void show_mouse_pointer (int x, int y);
#endif /* MC_MOUSE_H */
#endif /* MC_MOUSE_H */

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

@ -6,7 +6,7 @@
#ifndef MC_TTY_INTERNAL_H
#define MC_TTY_INTERNAL_H
#include "../../src/global.h" /* include <glib.h> */
#include "../../src/global.h" /* include <glib.h> */
/* If true lines are shown by spaces */
extern gboolean slow_tty;
@ -17,4 +17,4 @@ extern gboolean ugly_line_drawing;
/* The mouse is currently: TRUE - enabled, FALSE - disabled */
extern gboolean mouse_enabled;
#endif /* MC_TTY_INTERNAL_H */
#endif /* MC_TTY_INTERNAL_H */

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

@ -42,17 +42,17 @@
# define WANT_TERM_H
#endif
#include "../../src/tty/tty-internal.h" /* slow_tty */
#include "../../src/tty/tty-internal.h" /* slow_tty */
#include "../../src/tty/tty.h"
#include "../../src/tty/color-internal.h"
#include "../../src/tty/win.h"
#include "../../src/strutil.h" /* str_term_form */
#include "../../src/strutil.h" /* str_term_form */
/* include at last !!! */
#ifdef WANT_TERM_H
# include <term.h>
#endif /* WANT_TERM_H*/
#endif /* WANT_TERM_H */
/*** global variables **************************************************/
@ -71,45 +71,43 @@
/* --------------------------------------------------------------------------------------------- */
int
mc_tty_normalize_lines_char(const char *ch)
mc_tty_normalize_lines_char (const char *ch)
{
int i;
struct mc_tty_lines_struct {
const char *line;
int line_code;
} const lines_codes[] =
{
{"", ACS_BSSB},
{"", ACS_BBSS},
{"", ACS_SSBB},
{"", ACS_SBBS},
{"", ACS_SBSS},
{"", ACS_SSSB},
{"", ACS_BSSS},
{"", ACS_SSBS},
{"", ACS_BSBS},
{"", ACS_SBSB},
{"", ACS_SSSS},
{"", ACS_BSSB | A_BOLD},
{"", ACS_BBSS | A_BOLD},
{"", ACS_BSSS | A_BOLD},
{"", ACS_SSBS | A_BOLD},
{"", ACS_SSBB | A_BOLD},
{"", ACS_SBBS | A_BOLD},
{"", ACS_SSSB | A_BOLD},
{"", ACS_SBSS | A_BOLD},
{"", ACS_BSBS | A_BOLD},
{"", ACS_SBSB | A_BOLD},
{NULL,0}
} const lines_codes[] = {
{"", ACS_BSSB},
{"", ACS_BBSS},
{"", ACS_SSBB},
{"", ACS_SBBS},
{"", ACS_SBSS},
{"", ACS_SSSB},
{"", ACS_BSSS},
{"", ACS_SSBS},
{"", ACS_BSBS},
{"", ACS_SBSB},
{"", ACS_SSSS},
{"", ACS_BSSB | A_BOLD},
{"", ACS_BBSS | A_BOLD},
{"", ACS_BSSS | A_BOLD},
{"", ACS_SSBS | A_BOLD},
{"", ACS_SSBB | A_BOLD},
{"", ACS_SBBS | A_BOLD},
{"", ACS_SSSB | A_BOLD},
{"", ACS_SBSS | A_BOLD},
{"", ACS_BSBS | A_BOLD},
{"", ACS_SBSB | A_BOLD},
{NULL, 0}
};
if (ch == NULL)
return (int) ' ';
return (int) ' ';
for(i=0;lines_codes[i].line;i++)
{
if (strcmp(ch,lines_codes[i].line) == 0)
return lines_codes[i].line_code;
for (i = 0; lines_codes[i].line; i++) {
if (strcmp (ch, lines_codes[i].line) == 0)
return lines_codes[i].line_code;
}
return (int) ' ';
@ -123,6 +121,7 @@ void
tty_init (gboolean slow, gboolean ugly_lines)
{
slow_tty = slow;
(void) ugly_lines;
initscr ();
@ -206,7 +205,7 @@ tty_nodelay (gboolean set)
int
tty_baudrate (void)
{
return baudrate();
return baudrate ();
}
int
@ -243,7 +242,7 @@ tty_getyx (int *py, int *px)
void
tty_draw_hline (int y, int x, int ch, int len)
{
if (ch == ACS_HLINE)
if ((chtype) ch == ACS_HLINE)
ch = mc_tty_ugly_frm[MC_TTY_FRM_thinhoriz];
if ((y >= 0) && (x >= 0))
@ -255,11 +254,11 @@ 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)
if ((chtype) ch == ACS_VLINE)
ch = mc_tty_ugly_frm[MC_TTY_FRM_thinvert];
if ((y >= 0) && (x >= 0))
move (y, x);
move (y, x);
vline (ch, len);
}
@ -269,8 +268,8 @@ tty_fill_region (int y, int x, int rows, int cols, unsigned char ch)
int i;
for (i = 0; i < rows; i++) {
move (y + i, x);
hline (ch, cols);
move (y + i, x);
hline (ch, cols);
}
move (y, x);
@ -299,15 +298,15 @@ tty_print_anychar (int c)
{
unsigned char str[6 + 1];
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 ((char *)str));
addstr (str_term_form ((char *) str));
} else {
addch (c);
}
@ -316,24 +315,24 @@ tty_print_anychar (int c)
void
tty_print_alt_char (int c)
{
if (c == ACS_VLINE)
c = mc_tty_ugly_frm[MC_TTY_FRM_thinvert];
else if (c == ACS_HLINE)
c = mc_tty_ugly_frm[MC_TTY_FRM_thinhoriz];
else if (c == ACS_LTEE)
c = mc_tty_ugly_frm[MC_TTY_FRM_leftmiddle];
else if (c == ACS_RTEE)
c = mc_tty_ugly_frm[MC_TTY_FRM_rightmiddle];
else if (c == ACS_ULCORNER)
c = mc_tty_ugly_frm[MC_TTY_FRM_lefttop];
else if (c == ACS_LLCORNER)
c = mc_tty_ugly_frm[MC_TTY_FRM_leftbottom];
else if (c == ACS_URCORNER)
c = mc_tty_ugly_frm[MC_TTY_FRM_righttop];
else if (c == ACS_LRCORNER)
c = mc_tty_ugly_frm[MC_TTY_FRM_rightbottom];
else if (c == ACS_PLUS)
c = mc_tty_ugly_frm[MC_TTY_FRM_centermiddle];
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);
}
@ -378,9 +377,9 @@ tty_setup_sigwinch (void (*handler) (int))
act.sa_flags = 0;
#ifdef SA_RESTART
act.sa_flags |= SA_RESTART;
#endif /* SA_RESTART */
#endif /* SA_RESTART */
sigaction (SIGWINCH, &act, &oact);
#endif /* SIGWINCH */
#endif /* SIGWINCH */
}
void

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

@ -12,12 +12,12 @@
# else
# include <curses.h>
# endif
#endif /* USE_NCURSES */
#endif /* USE_NCURSES */
#ifdef USE_NCURSESW
# include <ncursesw/curses.h>
#endif /* USE_NCURSESW */
#endif /* USE_NCURSESW */
void init_curses (void);
#endif /* MC_TTY_NCURSES_H */
#endif /* MC_TTY_NCURSES_H */

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

@ -37,21 +37,21 @@
#ifdef HAVE_TERMIOS_H
#include <termios.h>
#endif
#include <sys/types.h> /* size_t */
#include <sys/types.h> /* size_t */
#include <unistd.h>
#include <signal.h>
#include "../../src/global.h"
#include "../../src/tty/tty-internal.h" /* slow_tty */
#include "../../src/tty/tty-internal.h" /* slow_tty */
#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 */
#include "../../src/tty/key.h" /* define_sequence */
#include "../../src/tty/mouse.h" /* Gpm_Event is required in key.h */
#include "../../src/tty/key.h" /* define_sequence */
#include "../../src/tty/win.h"
#include "../../src/strutil.h" /* str_term_form */
#include "../../src/strutil.h" /* str_term_form */
/*** global variables **************************************************/
extern int reset_hp_softkeys;
@ -59,7 +59,7 @@ extern int reset_hp_softkeys;
/*** file scope macro definitions **************************************/
/* Taken from S-Lang's slutty.c */
#ifdef ultrix /* Ultrix gets _POSIX_VDISABLE wrong! */
#ifdef ultrix /* Ultrix gets _POSIX_VDISABLE wrong! */
# define NULL_VALUE -1
#else
# ifdef _POSIX_VDISABLE
@ -67,7 +67,7 @@ extern int reset_hp_softkeys;
# else
# define NULL_VALUE 255
# endif
#endif /* ultrix */
#endif /* ultrix */
#ifndef SA_RESTART
# define SA_RESTART 0
@ -97,42 +97,43 @@ static gboolean no_slang_delay;
* assign to them.
*/
static const struct {
int key_code;
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 **********************************************/
@ -161,14 +162,13 @@ slang_reset_softkeys (void)
char tmp[BUF_SMALL];
for (key = 1; key < 9; key++) {
g_snprintf (tmp, sizeof (tmp), "k%d", key);
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);
SLtt_write_string (tmp);
}
g_snprintf (tmp, sizeof (tmp), "k%d", key);
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);
SLtt_write_string (tmp);
}
}
}
@ -179,7 +179,7 @@ do_define_key (int code, const char *strcap)
seq = (char *) SLtt_tgetstr ((char *) strcap);
if (seq != NULL)
define_sequence (code, seq, MCKEY_NOACTION);
define_sequence (code, seq, MCKEY_NOACTION);
}
static void
@ -187,8 +187,8 @@ 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);
}
static char *
@ -196,26 +196,25 @@ mc_tty_normalize_from_utf8 (const char *str)
{
GIConv conv;
GString *buffer;
const char *_system_codepage = str_detect_termencoding();
const char *_system_codepage = str_detect_termencoding ();
if (str_isutf8 (_system_codepage))
return g_strdup(str);
return g_strdup (str);
conv = g_iconv_open (_system_codepage, "UTF-8");
if (conv == INVALID_CONV)
return g_strdup(str);
return g_strdup (str);
buffer = g_string_new ("");
if (str_convert (conv, str, buffer) == ESTR_FAILURE)
{
g_string_free(buffer, TRUE);
if (str_convert (conv, str, buffer) == ESTR_FAILURE) {
g_string_free (buffer, TRUE);
str_close_conv (conv);
return g_strdup(str);
return g_strdup (str);
}
str_close_conv (conv);
return g_string_free(buffer, FALSE);
return g_string_free (buffer, FALSE);
}
/* --------------------------------------------------------------------------------------------- */
@ -223,7 +222,7 @@ mc_tty_normalize_from_utf8 (const char *str)
/* --------------------------------------------------------------------------------------------- */
int
mc_tty_normalize_lines_char(const char *str)
mc_tty_normalize_lines_char (const char *str)
{
char *str2;
int res;
@ -234,8 +233,8 @@ mc_tty_normalize_lines_char(const char *str)
res = g_utf8_get_char_validated (str2, -1);
if (res < 0)
res = (unsigned char) str2[0];
g_free(str2);
res = (unsigned char) str2[0];
g_free (str2);
return res;
}
@ -249,44 +248,43 @@ tty_init (gboolean slow, gboolean ugly_lines)
SLtt_get_terminfo ();
SLutf8_enable (-1);
/*
* If the terminal in not in terminfo but begins with a well-known
* string such as "linux" or "xterm" S-Lang will go on, but the
* terminal size and several other variables won't be initialized
* (as of S-Lang 1.4.4). Detect it and abort. Also detect extremely
* small, large and negative screen dimensions.
*/
/*
* If the terminal in not in terminfo but begins with a well-known
* string such as "linux" or "xterm" S-Lang will go on, but the
* terminal size and several other variables won't be initialized
* (as of S-Lang 1.4.4). Detect it and abort. Also detect extremely
* small, large and negative screen dimensions.
*/
if ((COLS < 10) || (LINES < 5)
|| (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);
exit (1);
|| (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);
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;
SLtt_Has_Alt_Charset = 0;
/* If SLang uses fileno(stderr) for terminal input MC will hang
if we call SLang_getkey between calls to open_error_pipe and
close_error_pipe, e.g. when we do a growing view of an gzipped
file. */
if (SLang_TT_Read_FD == fileno (stderr))
SLang_TT_Read_FD = fileno (stdin);
SLang_TT_Read_FD = fileno (stdin);
if (tcgetattr (SLang_TT_Read_FD, &new_mode) == 0) {
#ifdef VDSUSP
new_mode.c_cc[VDSUSP] = NULL_VALUE; /* to ignore ^Y */
new_mode.c_cc[VDSUSP] = NULL_VALUE; /* to ignore ^Y */
#endif
#ifdef VLNEXT
new_mode.c_cc[VLNEXT] = NULL_VALUE; /* to ignore ^V */
new_mode.c_cc[VLNEXT] = NULL_VALUE; /* to ignore ^V */
#endif
tcsetattr (SLang_TT_Read_FD, TCSADRAIN, &new_mode);
tcsetattr (SLang_TT_Read_FD, TCSADRAIN, &new_mode);
}
tty_reset_prog_mode ();
@ -318,9 +316,9 @@ tty_shutdown (void)
* active when the program was started up
*/
op_cap = SLtt_tgetstr ((char *) "op");
if (op_cap != NULL){
fputs (op_cap, stdout);
fflush (stdout);
if (op_cap != NULL) {
fputs (op_cap, stdout);
fflush (stdout);
}
}
@ -359,7 +357,7 @@ tty_noecho (void)
int
tty_flush_input (void)
{
return 0; /* OK */
return 0; /* OK */
}
void
@ -369,9 +367,9 @@ tty_keypad (gboolean set)
keypad_string = (char *) SLtt_tgetstr ((char *) (set ? "ks" : "ke"));
if (keypad_string != NULL)
SLtt_write_string (keypad_string);
SLtt_write_string (keypad_string);
if (set && reset_hp_softkeys)
slang_reset_softkeys ();
slang_reset_softkeys ();
}
void
@ -392,14 +390,14 @@ tty_lowlevel_getch (void)
int c;
if (no_slang_delay && (SLang_input_pending (0) == 0))
return -1;
return -1;
c = SLang_getkey ();
if (c == SLANG_GETKEY_ERROR) {
fprintf (stderr,
"SLang_getkey returned SLANG_GETKEY_ERROR\n"
"Assuming EOF on stdin and exiting\n");
exit (1);
fprintf (stderr,
"SLang_getkey returned SLANG_GETKEY_ERROR\n"
"Assuming EOF on stdin and exiting\n");
exit (1);
}
return c;
@ -409,7 +407,7 @@ int
tty_reset_screen (void)
{
SLsmg_reset_smg ();
return 0; /* OK */
return 0; /* OK */
}
void
@ -439,19 +437,19 @@ tty_draw_hline (int y, int x, int ch, int len)
ch = mc_tty_ugly_frm[MC_TTY_FRM_thinhoriz];
if ((y < 0) || (x < 0)) {
y = SLsmg_get_row ();
x = SLsmg_get_column ();
y = SLsmg_get_row ();
x = SLsmg_get_column ();
} else
SLsmg_gotorc (y, x);
SLsmg_gotorc (y, x);
if (ch == 0)
ch = ACS_HLINE;
ch = ACS_HLINE;
if (ch == ACS_HLINE)
SLsmg_draw_hline (len);
SLsmg_draw_hline (len);
else
while (len-- != 0)
tty_print_char (ch);
while (len-- != 0)
tty_print_char (ch);
SLsmg_gotorc (y, x);
}
@ -464,24 +462,24 @@ tty_draw_vline (int y, int x, int ch, int len)
ch = mc_tty_ugly_frm[MC_TTY_FRM_thinvert];
if ((y < 0) || (x < 0)) {
y = SLsmg_get_row ();
x = SLsmg_get_column ();
y = SLsmg_get_row ();
x = SLsmg_get_column ();
} else
SLsmg_gotorc (y, x);
SLsmg_gotorc (y, x);
if (ch == 0)
ch = ACS_VLINE;
ch = ACS_VLINE;
if (ch == ACS_VLINE)
SLsmg_draw_vline (len);
SLsmg_draw_vline (len);
else {
int pos = 0;
int pos = 0;
while (len-- != 0) {
SLsmg_gotorc (y + pos, x);
tty_print_char (ch);
pos++;
}
while (len-- != 0) {
SLsmg_gotorc (y + pos, x);
tty_print_char (ch);
pos++;
}
}
SLsmg_gotorc (y, x);
@ -518,16 +516,35 @@ tty_print_alt_char (int c)
? 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);
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
}
@ -537,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 {
@ -589,9 +606,9 @@ tty_setup_sigwinch (void (*handler) (int))
act.sa_flags = 0;
#ifdef SA_RESTART
act.sa_flags |= SA_RESTART;
#endif /* SA_RESTART */
#endif /* SA_RESTART */
sigaction (SIGWINCH, &act, &oact);
#endif /* SIGWINCH */
#endif /* SIGWINCH */
}
void

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

@ -6,7 +6,7 @@
# include <slang/slang.h>
#else
# include <slang.h>
#endif /* HAVE_SLANG_SLANG_H */
#endif /* HAVE_SLANG_SLANG_H */
enum {
KEY_BACKSPACE = 400,
@ -30,4 +30,4 @@ enum {
#define COLS SLtt_Screen_Cols
#define LINES SLtt_Screen_Rows
#endif /* MC_TTY_SLANG_H */
#endif /* MC_TTY_SLANG_H */

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

@ -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;

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

@ -11,7 +11,7 @@
#ifndef MC_TTY_H
#define MC_TTY_H
#include "../../src/global.h" /* include <glib.h> */
#include "../../src/global.h" /* include <glib.h> */
#ifdef HAVE_SLANG
# include "../../src/tty/tty-slang.h"
@ -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,17 +57,17 @@ 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);
@ -78,7 +78,7 @@ 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,
@ -106,6 +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 *);
extern int mc_tty_normalize_lines_char (const char *);
#endif /* MC_TTY_H */
#endif /* MC_TTY_H */

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

@ -32,10 +32,10 @@
#include <sys/types.h>
#include <unistd.h>
#include "../../src/tty/tty.h" /* tty_gotoyx, tty_print_char */
#include "../../src/tty/tty.h" /* tty_gotoyx, tty_print_char */
#include "../../src/tty/win.h"
#include "../../src/cons.saver.h" /* console_flag */
#include "../../src/cons.saver.h" /* console_flag */
/*** global variables **************************************************/
@ -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;
return -1;
r = (c - 'A') * 16;
while (read (0, &c, 1) != 1)
;
while (read (0, &c, 1) != 1);
r += (c - 'A');
return r;
}
@ -92,8 +90,8 @@ void
do_enter_ca_mode (void)
{
if (xterm_flag) {
fprintf (stdout, /* ESC_STR ")0" */ ESC_STR "7" ESC_STR "[?47h");
fflush (stdout);
fprintf (stdout, /* ESC_STR ")0" */ ESC_STR "7" ESC_STR "[?47h");
fflush (stdout);
}
}
@ -101,8 +99,8 @@ void
do_exit_ca_mode (void)
{
if (xterm_flag) {
fprintf (stdout, ESC_STR "[?47l" ESC_STR "8" ESC_STR "[m");
fflush (stdout);
fprintf (stdout, ESC_STR "[?47l" ESC_STR "8" ESC_STR "[m");
fflush (stdout);
}
}
@ -112,38 +110,36 @@ show_rxvt_contents (int starty, unsigned char y1, unsigned char y2)
unsigned char *k;
int bytes, i, j, cols = 0;
y1 += (keybar_visible != 0); /* i don't knwo why we need this - paul */
y1 += (keybar_visible != 0); /* i don't knwo why we need this - paul */
y2 += (keybar_visible != 0);
while (anything_ready ())
tty_lowlevel_getch ();
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 */
bytes = (y2 - y1) * (COLS + 1) + 1; /* *should* be the number of bytes read */
j = 0;
k = g_malloc (bytes);
for (;;) {
int c;
c = rxvt_getc ();
if (c < 0)
break;
if (j < bytes)
k[j++] = c;
for (cols = 1; ; cols++) {
c = rxvt_getc ();
if (c < 0)
break;
if (j < bytes)
k[j++] = c;
}
int c;
c = rxvt_getc ();
if (c < 0)
break;
if (j < bytes)
k[j++] = c;
for (cols = 1;; cols++) {
c = rxvt_getc ();
if (c < 0)
break;
if (j < bytes)
k[j++] = c;
}
}
for (i = 0; i < j; i++) {
if ((i % cols) == 0)
tty_gotoyx (starty + (i / cols), 0);
tty_print_char (is_printable (k[i]) ? k[i] : ' ');
if ((i % cols) == 0)
tty_gotoyx (starty + (i / cols), 0);
tty_print_char (is_printable (k[i]) ? k[i] : ' ');
}
g_free (k);
}
@ -154,13 +150,13 @@ look_for_rxvt_extensions (void)
static gboolean been_called = FALSE;
if (!been_called) {
const char *e = getenv ("RXVT_EXT");
rxvt_extensions = ((e != NULL) && (strcmp (e, "1.0") == 0));
been_called = TRUE;
const char *e = getenv ("RXVT_EXT");
rxvt_extensions = ((e != NULL) && (strcmp (e, "1.0") == 0));
been_called = TRUE;
}
if (rxvt_extensions)
console_flag = 4;
console_flag = 4;
return rxvt_extensions;
}

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

@ -6,7 +6,7 @@
#ifndef MC_WIN_H
#define MC_WIN_H
#include "../../src/global.h" /* <glib.h> */
#include "../../src/global.h" /* <glib.h> */
extern int xterm_flag;
@ -16,4 +16,4 @@ void do_exit_ca_mode (void);
void show_rxvt_contents (int starty, unsigned char y1, unsigned char y2);
gboolean look_for_rxvt_extensions (void);
#endif /* MC_WIN_H */
#endif /* MC_WIN_H */

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

@ -30,7 +30,7 @@
#include <config.h>
#ifndef HAVE_TEXTMODE_X11_SUPPORT
typedef int dummy; /* C99 forbids empty compilation unit */
typedef int dummy; /* C99 forbids empty compilation unit */
#else
#include <setjmp.h>
@ -51,14 +51,14 @@ 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);
(mc_XErrorHandler_callback);
static mc_XIOErrorHandler_callback (*func_XSetIOErrorHandler)
(mc_XIOErrorHandler_callback);
(mc_XIOErrorHandler_callback);
static Bool (*func_XQueryPointer) (Display *, Window, Window *, Window *,
int *, int *, int *, int *, unsigned int *);
int *, int *, int *, int *, unsigned int *);
static GModule *x11_module;
@ -79,80 +79,80 @@ static gboolean handlers_installed = FALSE;
* reconnect, as that would violate the X11 protocol. */
static gboolean lost_connection = FALSE;
static jmp_buf x11_exception; /* FIXME: get a better name */
static jmp_buf x11_exception; /* FIXME: get a better name */
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_allowed = FALSE;
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;
if (lost_connection)
return FALSE;
return FALSE;
if (x11_module != NULL)
return TRUE;
return TRUE;
x11_module_fname = g_module_build_path (NULL, "X11");
x11_module = g_module_open (x11_module_fname, G_MODULE_BIND_LAZY);
if (x11_module == NULL)
x11_module = g_module_open ("libX11.so.6", G_MODULE_BIND_LAZY);
x11_module = g_module_open ("libX11.so.6", G_MODULE_BIND_LAZY);
g_free (x11_module_fname);
if (x11_module == NULL)
return FALSE;
return FALSE;
if (!g_module_symbol (x11_module, "XOpenDisplay",
(void *) &func_XOpenDisplay))
goto cleanup;
if (!g_module_symbol (x11_module, "XCloseDisplay",
(void *) &func_XCloseDisplay))
goto cleanup;
if (!g_module_symbol (x11_module, "XQueryPointer",
(void *) &func_XQueryPointer))
goto cleanup;
if (!g_module_symbol (x11_module, "XSetErrorHandler",
(void *) &func_XSetErrorHandler))
goto cleanup;
if (!g_module_symbol (x11_module, "XSetIOErrorHandler",
(void *) &func_XSetIOErrorHandler))
goto cleanup;
if (!g_module_symbol (x11_module, "XOpenDisplay", (void *) &func_XOpenDisplay))
goto cleanup;
if (!g_module_symbol (x11_module, "XCloseDisplay", (void *) &func_XCloseDisplay))
goto cleanup;
if (!g_module_symbol (x11_module, "XQueryPointer", (void *) &func_XQueryPointer))
goto cleanup;
if (!g_module_symbol (x11_module, "XSetErrorHandler", (void *) &func_XSetErrorHandler))
goto cleanup;
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,58 +162,61 @@ 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) {
longjmp_allowed = TRUE;
retval = func_XOpenDisplay (displayname);
longjmp_allowed = FALSE;
return retval;
}
if (x11_available ()) {
if (setjmp (x11_exception) == 0) {
longjmp_allowed = TRUE;
retval = func_XOpenDisplay (displayname);
longjmp_allowed = FALSE;
return retval;
}
}
return NULL;
}
int mc_XCloseDisplay (Display *display)
int
mc_XCloseDisplay (Display * display)
{
int retval;
if (x11_available()) {
if (setjmp(x11_exception) == 0) {
longjmp_allowed = TRUE;
retval = func_XCloseDisplay (display);
longjmp_allowed = FALSE;
return retval;
}
if (x11_available ()) {
if (setjmp (x11_exception) == 0) {
longjmp_allowed = TRUE;
retval = func_XCloseDisplay (display);
longjmp_allowed = FALSE;
return retval;
}
}
return 0;
}
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
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) {
longjmp_allowed = TRUE;
retval = func_XQueryPointer (display, win, root_return,
child_return, root_x_return, root_y_return,
win_x_return, win_y_return, mask_return);
longjmp_allowed = FALSE;
return retval;
}
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,
win_x_return, win_y_return, mask_return);
longjmp_allowed = FALSE;
return retval;
}
}
*root_return = None;
*child_return = None;

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

@ -23,6 +23,6 @@ extern Display *mc_XOpenDisplay (const char *);
extern int mc_XCloseDisplay (Display *);
extern Bool mc_XQueryPointer (Display *, Window, Window *, Window *,
int *, int *, int *, int *, unsigned int *);
int *, int *, int *, int *, unsigned int *);
#endif