Wed May 31 22:34:12 PDT 2000 Michael Jennings <mej@eterm.org>
Okay, first off I need to thank Marius Gedminas <mgedmin@takas.lt>. Not only did he point out several issues, he was even willing to send a patch. :-) This commit includes Marius' patch which keeps MappingNotify events from overriding users' modifier settings. It also includes a fix to a seg fault that he pointed out when menus were loaded without the menu imageclass having been defined. He also pointed out that --pause tends to sit and spin, taking up 100% of the CPU time. Funny how E-Cpu never seemed to get too bent out of shape over it, but he was indeed correct. Thus I have fixed it, and while doing so, I have changed the way it works. It no longer waits for a keypress per se. Actually, it just ignores the fact that its child went away and keeps right on taking X events. There are a few exceptions though. Either ESC or Ctrl-C will exit a paused Eterm. Any other input that doesn't have special meaning to Eterm will be ignored. (Shift-PgUp and Shift-PgDn still work however, as do any action bindings you may have.) SVN revision: 2739
This commit is contained in:
parent
cf3f7ca572
commit
47e8788bc8
24
ChangeLog
24
ChangeLog
|
@ -3625,3 +3625,27 @@ Tue May 30 08:49:43 PDT 2000 Michael Jennings <mej@eterm.org>
|
|||
<namsh@lgic.co.kr>.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Wed May 31 22:34:12 PDT 2000 Michael Jennings <mej@eterm.org>
|
||||
|
||||
Okay, first off I need to thank Marius Gedminas <mgedmin@takas.lt>.
|
||||
Not only did he point out several issues, he was even willing to send
|
||||
a patch. :-)
|
||||
|
||||
This commit includes Marius' patch which keeps MappingNotify events
|
||||
from overriding users' modifier settings. It also includes a fix to
|
||||
a seg fault that he pointed out when menus were loaded without the
|
||||
menu imageclass having been defined.
|
||||
|
||||
He also pointed out that --pause tends to sit and spin, taking up 100%
|
||||
of the CPU time. Funny how E-Cpu never seemed to get too bent out of
|
||||
shape over it, but he was indeed correct.
|
||||
|
||||
Thus I have fixed it, and while doing so, I have changed the way it
|
||||
works. It no longer waits for a keypress per se. Actually, it just
|
||||
ignores the fact that its child went away and keeps right on taking
|
||||
X events. There are a few exceptions though. Either ESC or Ctrl-C
|
||||
will exit a paused Eterm. Any other input that doesn't have special
|
||||
meaning to Eterm will be ignored. (Shift-PgUp and Shift-PgDn still
|
||||
work however, as do any action bindings you may have.)
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
|
|
@ -1030,12 +1030,11 @@ handle_child_signal(int sig)
|
|||
our immediate child that exited. We exit gracefully. */
|
||||
if (pid == cmd_pid && cmd_pid != -1) {
|
||||
if (Options & Opt_pause) {
|
||||
const char *message = "\r\nPress any key to exit " APL_NAME "....";
|
||||
const char *done = " -- Task Finished, ESC to exit";
|
||||
|
||||
scr_refresh(DEFAULT_REFRESH);
|
||||
scr_add_lines((unsigned char *) message, 1, strlen(message));
|
||||
scr_refresh(DEFAULT_REFRESH);
|
||||
keypress_exit = 1;
|
||||
append_to_title(done);
|
||||
append_to_icon_name(done);
|
||||
paused = 1;
|
||||
return;
|
||||
}
|
||||
exit(EXIT_SUCCESS);
|
||||
|
@ -2441,7 +2440,9 @@ cmd_getc(void)
|
|||
|
||||
/* Nothing to do! */
|
||||
FD_ZERO(&readfds);
|
||||
FD_SET(cmd_fd, &readfds);
|
||||
if (cmd_fd >= 0) {
|
||||
FD_SET(cmd_fd, &readfds);
|
||||
}
|
||||
FD_SET(Xfd, &readfds);
|
||||
if (pipe_fd >= 0) {
|
||||
FD_SET(pipe_fd, &readfds);
|
||||
|
@ -2461,7 +2462,7 @@ cmd_getc(void)
|
|||
retval = select(num_fds, &readfds, NULL, NULL, delay);
|
||||
|
||||
/* See if we can read from the application */
|
||||
if (FD_ISSET(cmd_fd, &readfds)) {
|
||||
if (cmd_fd >= 0 && FD_ISSET(cmd_fd, &readfds)) {
|
||||
register unsigned int count = CMD_BUF_SIZE;
|
||||
|
||||
cmdbuf_ptr = cmdbuf_endp = cmdbuf_base;
|
||||
|
@ -2469,8 +2470,12 @@ cmd_getc(void)
|
|||
|
||||
register int n = read(cmd_fd, cmdbuf_endp, count);
|
||||
|
||||
if (n <= 0)
|
||||
if (n <= 0) {
|
||||
if (paused) {
|
||||
cmd_fd = -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
cmdbuf_endp += n;
|
||||
count -= n;
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ static const char cvs_ident[] = "$Id$";
|
|||
#include "term.h"
|
||||
#include "windows.h"
|
||||
|
||||
unsigned char keypress_exit = 0;
|
||||
unsigned char paused = 0;
|
||||
event_master_t event_master;
|
||||
event_dispatcher_data_t primary_data;
|
||||
mouse_button_state_t button_state =
|
||||
|
@ -203,7 +203,7 @@ unsigned char
|
|||
handle_key_press(event_t * ev)
|
||||
{
|
||||
#ifdef COUNT_X_EVENTS
|
||||
static long long keypress_cnt = 0;
|
||||
static unsigned long keypress_cnt = 0;
|
||||
#endif
|
||||
|
||||
PROF_INIT(handle_key_press);
|
||||
|
@ -723,7 +723,7 @@ unsigned char
|
|||
handle_motion_notify(event_t * ev)
|
||||
{
|
||||
#ifdef COUNT_X_EVENTS
|
||||
static long long motion_cnt = 0;
|
||||
static unsigned long motion_cnt = 0;
|
||||
#endif
|
||||
|
||||
PROF_INIT(handle_motion_notify);
|
||||
|
@ -762,7 +762,7 @@ unsigned char
|
|||
process_x_event(event_t * ev)
|
||||
{
|
||||
#ifdef COUNT_X_EVENTS
|
||||
static long long event_cnt = 0;
|
||||
static unsigned long event_cnt = 0;
|
||||
#endif
|
||||
|
||||
COUNT_EVENT(event_cnt);
|
||||
|
|
|
@ -80,7 +80,7 @@ typedef struct {
|
|||
} mouse_button_state_t;
|
||||
|
||||
/************ Variables ************/
|
||||
extern unsigned char keypress_exit;
|
||||
extern unsigned char paused;
|
||||
extern event_master_t event_master;
|
||||
extern mouse_button_state_t button_state;
|
||||
|
||||
|
|
|
@ -428,7 +428,6 @@ menu_create(char *title)
|
|||
menu_t *menu;
|
||||
static Cursor cursor;
|
||||
static long mask;
|
||||
static XGCValues gcvalue;
|
||||
static XSetWindowAttributes xattr;
|
||||
|
||||
if (!mask) {
|
||||
|
@ -440,7 +439,6 @@ menu_create(char *title)
|
|||
|
||||
cursor = XCreateFontCursor(Xdisplay, XC_left_ptr);
|
||||
mask = PointerMotionMask | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask | Button1MotionMask | Button2MotionMask | Button3MotionMask;
|
||||
gcvalue.foreground = images[image_menu].norm->fg;
|
||||
}
|
||||
menu = (menu_t *) MALLOC(sizeof(menu_t));
|
||||
MEMSET(menu, 0, sizeof(menu_t));
|
||||
|
@ -455,7 +453,7 @@ menu_create(char *title)
|
|||
menu->swin = XCreateWindow(Xdisplay, menu->win, 0, 0, 1, 1, 0, Xdepth, InputOutput, CopyFromParent,
|
||||
CWOverrideRedirect | CWSaveUnder | CWBackingStore | CWBorderPixel | CWColormap, &xattr);
|
||||
|
||||
menu->gc = X_CREATE_GC(GCForeground, &gcvalue);
|
||||
menu->gc = X_CREATE_GC(0, NULL);
|
||||
menuitem_clear_current(menu);
|
||||
|
||||
return menu;
|
||||
|
|
|
@ -318,7 +318,7 @@ static const struct {
|
|||
OPT_BLONG("backing-store", "use backing store", &Options, Opt_backing_store),
|
||||
OPT_BLONG("double-buffer", "use double-buffering to reduce exposes (uses more memory)", &Options, Opt_double_buffer),
|
||||
OPT_BLONG("no-cursor", "disable the text cursor", &Options, Opt_noCursor),
|
||||
OPT_BLONG("pause", "pause for a keypress after the child process exits", &Options, Opt_pause),
|
||||
OPT_BLONG("pause", "pause after the child process exits", &Options, Opt_pause),
|
||||
OPT_BLONG("xterm-select", "duplicate xterm's broken selection behavior", &Options, Opt_xterm_select),
|
||||
OPT_BLONG("select-line", "triple-click selects whole line", &Options, Opt_select_whole_line),
|
||||
OPT_BLONG("select-trailing-spaces", "do not skip trailing spaces when selecting", &Options, Opt_select_trailing_spaces),
|
||||
|
|
|
@ -220,6 +220,7 @@ extern char *rs_name;
|
|||
extern char *rs_theme;
|
||||
extern char *rs_config_file;
|
||||
extern unsigned int rs_line_space;
|
||||
extern unsigned int rs_meta_mod, rs_alt_mod, rs_numlock_mod;
|
||||
#ifndef NO_BOLDFONT
|
||||
extern char *rs_boldFont;
|
||||
#endif
|
||||
|
|
63
src/term.c
63
src/term.c
|
@ -168,6 +168,17 @@ get_modifiers(void)
|
|||
D_X11(("Defaulted Alt key to match Meta mask\n"));
|
||||
AltMask = MetaMask; /* MetaMask will always be defined at this point. */
|
||||
}
|
||||
|
||||
/* See if the user wants to override any of those */
|
||||
if (rs_meta_mod) {
|
||||
MetaMask = modmasks[rs_meta_mod - 1];
|
||||
}
|
||||
if (rs_alt_mod) {
|
||||
AltMask = modmasks[rs_alt_mod - 1];
|
||||
}
|
||||
if (rs_numlock_mod) {
|
||||
NumLockMask = modmasks[rs_numlock_mod - 1];
|
||||
}
|
||||
}
|
||||
|
||||
/* To handle buffer overflows properly, we must malloc a buffer. Free it when done. */
|
||||
|
@ -260,10 +271,6 @@ lookup_key(XEvent * ev)
|
|||
LK_RET();
|
||||
}
|
||||
if (len) {
|
||||
/* If we're in pause mode, exit. */
|
||||
if (keypress_exit) {
|
||||
exit(0);
|
||||
}
|
||||
/* Only home for keypresses with length. */
|
||||
if (Options & Opt_home_on_input) {
|
||||
TermWin.view_start = 0;
|
||||
|
@ -375,6 +382,16 @@ lookup_key(XEvent * ev)
|
|||
break;
|
||||
}
|
||||
|
||||
/* At this point, all the keystrokes that have special meaning to us have been handled.
|
||||
If we're in pause mode, this is a keystroke we need to ignore. Just return here. */
|
||||
if (paused) {
|
||||
/* Allow ESC or Ctrl-C to exit. */
|
||||
if ((keysym == XK_Escape) || ((ctrl) && ((keysym == XK_C) || (keysym == XK_c)))) {
|
||||
exit(0);
|
||||
}
|
||||
LK_RET();
|
||||
}
|
||||
|
||||
/* Process extended keysyms. This is where the conversion to escape sequences happens. */
|
||||
if (keysym >= 0xff00 && keysym <= 0xffff) {
|
||||
#ifdef KEYSYM_ATTRIBUTE
|
||||
|
@ -1612,7 +1629,7 @@ set_colorfgbg(void)
|
|||
}
|
||||
#endif /* NO_BRIGHTCOLOR */
|
||||
|
||||
static void
|
||||
void
|
||||
set_title(const char *str)
|
||||
{
|
||||
static char *name = NULL;
|
||||
|
@ -1630,7 +1647,7 @@ set_title(const char *str)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
set_icon_name(const char *str)
|
||||
{
|
||||
static char *name = NULL;
|
||||
|
@ -1646,6 +1663,40 @@ set_icon_name(const char *str)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
append_to_title(const char *str)
|
||||
{
|
||||
char *name, *buff;
|
||||
|
||||
REQUIRE(str != NULL);
|
||||
|
||||
XFetchName(Xdisplay, TermWin.parent, &name);
|
||||
if (name != NULL) {
|
||||
buff = (char *) MALLOC(strlen(name) + strlen(str) + 1);
|
||||
strcpy(buff, name);
|
||||
strcat(buff, str);
|
||||
set_title(buff);
|
||||
FREE(buff);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
append_to_icon_name(const char *str)
|
||||
{
|
||||
char *name, *buff;
|
||||
|
||||
REQUIRE(str != NULL);
|
||||
|
||||
XGetIconName(Xdisplay, TermWin.parent, &name);
|
||||
if (name != NULL) {
|
||||
buff = (char *) MALLOC(strlen(name) + strlen(str) + 1);
|
||||
strcpy(buff, name);
|
||||
strcat(buff, str);
|
||||
set_icon_name(buff);
|
||||
FREE(buff);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* XTerm escape sequences: ESC ] Ps;Pt BEL
|
||||
* 0 = change iconName/title
|
||||
|
|
|
@ -181,6 +181,10 @@ extern void set_colorfgbg(void);
|
|||
#else
|
||||
# define set_colorfgbg() ((void)0)
|
||||
#endif /* NO_BRIGHTCOLOR */
|
||||
extern void set_title(const char *);
|
||||
extern void set_icon_name(const char *);
|
||||
extern void append_to_title(const char *);
|
||||
extern void append_to_icon_name(const char *);
|
||||
extern void xterm_seq(int, const char *);
|
||||
|
||||
_XFUNCPROTOEND
|
||||
|
|
Loading…
Reference in New Issue