mirror of
https://github.com/rkd77/elinks.git
synced 2025-06-30 22:19:29 -04:00
[mouse] Create or delete ~/.elinks/mouse.lock file while changing ui.mouse_disable option. Refs #137
There is no good way to inform slave elinks instances about options. So, for mouse there is a workaround. Note, If you set ui.mouse_disable = 1 in elinks.conf manually, to get effect on 2nd ELinks instance, you must also touch ~/.elinks/mouse.lock . Changes via option manager delete or create this file automatically.
This commit is contained in:
parent
c388d2e397
commit
88d9704e11
@ -7,6 +7,10 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
#include "elinks.h"
|
#include "elinks.h"
|
||||||
|
|
||||||
#include "bfu/dialog.h"
|
#include "bfu/dialog.h"
|
||||||
@ -14,6 +18,7 @@
|
|||||||
#include "config/conf.h"
|
#include "config/conf.h"
|
||||||
#include "config/dialogs.h"
|
#include "config/dialogs.h"
|
||||||
#include "config/domain.h"
|
#include "config/domain.h"
|
||||||
|
#include "config/home.h"
|
||||||
#include "config/options.h"
|
#include "config/options.h"
|
||||||
#include "config/opttypes.h"
|
#include "config/opttypes.h"
|
||||||
#include "dialogs/status.h"
|
#include "dialogs/status.h"
|
||||||
@ -872,6 +877,23 @@ change_hook_ui_double_esc(struct session *ses, struct option *current, struct op
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
change_hook_ui_mouse_disable(struct session *ses, struct option *current, struct option *changed)
|
||||||
|
{
|
||||||
|
char *lock_filename = straconcat(empty_string_or_(elinks_home), "mouse.lock", (char *)NULL);
|
||||||
|
|
||||||
|
if (lock_filename) {
|
||||||
|
if (changed->value.number) {
|
||||||
|
creat(lock_filename, 0600);
|
||||||
|
} else {
|
||||||
|
unlink(lock_filename);
|
||||||
|
}
|
||||||
|
mem_free(lock_filename);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Make option templates visible or invisible in the option manager.
|
/** Make option templates visible or invisible in the option manager.
|
||||||
* This is called once on startup, and then each time the value of the
|
* This is called once on startup, and then each time the value of the
|
||||||
* "config.show_template" option is changed.
|
* "config.show_template" option is changed.
|
||||||
@ -946,6 +968,7 @@ static const struct change_hook_info change_hooks[] = {
|
|||||||
{ "terminal", change_hook_terminal },
|
{ "terminal", change_hook_terminal },
|
||||||
{ "ui.double_esc", change_hook_ui_double_esc },
|
{ "ui.double_esc", change_hook_ui_double_esc },
|
||||||
{ "ui.language", change_hook_language },
|
{ "ui.language", change_hook_language },
|
||||||
|
{ "ui.mouse_disable", change_hook_ui_mouse_disable },
|
||||||
{ "ui", change_hook_ui },
|
{ "ui", change_hook_ui },
|
||||||
{ NULL, NULL },
|
{ NULL, NULL },
|
||||||
};
|
};
|
||||||
|
@ -174,8 +174,9 @@ send_init_sequence(int h, int altscreen)
|
|||||||
write_sequence(h, INIT_ALT_SCREEN_SEQ);
|
write_sequence(h, INIT_ALT_SCREEN_SEQ);
|
||||||
}
|
}
|
||||||
#ifdef CONFIG_MOUSE
|
#ifdef CONFIG_MOUSE
|
||||||
if (! get_opt_bool("ui.mouse_disable", NULL))
|
if (mouse_enabled) {
|
||||||
send_mouse_init_sequence(h);
|
send_mouse_init_sequence(h);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
write_sequence(h, INIT_BRACKETED_PASTE_SEQ);
|
write_sequence(h, INIT_BRACKETED_PASTE_SEQ);
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include "elinks.h"
|
#include "elinks.h"
|
||||||
|
|
||||||
|
#include "config/home.h"
|
||||||
#include "config/options.h"
|
#include "config/options.h"
|
||||||
#include "dialogs/status.h"
|
#include "dialogs/status.h"
|
||||||
#include "intl/libintl.h"
|
#include "intl/libintl.h"
|
||||||
@ -71,7 +72,7 @@ send_mouse_done_sequence(int h)
|
|||||||
write_sequence(h, DONE_XWIN_MOUSE_SEQ);
|
write_sequence(h, DONE_XWIN_MOUSE_SEQ);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mouse_enabled;
|
int mouse_enabled;
|
||||||
|
|
||||||
void
|
void
|
||||||
disable_mouse(void)
|
disable_mouse(void)
|
||||||
@ -84,12 +85,30 @@ disable_mouse(void)
|
|||||||
mouse_enabled = 0;
|
mouse_enabled = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
mouse_lock_exists(void)
|
||||||
|
{
|
||||||
|
char *lock_filename = straconcat(empty_string_or_(elinks_home), "mouse.lock", (char *) NULL);
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
|
if (lock_filename) {
|
||||||
|
res = !access(lock_filename, F_OK);
|
||||||
|
mem_free(lock_filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
enable_mouse(void)
|
enable_mouse(void)
|
||||||
{
|
{
|
||||||
if (get_opt_bool("ui.mouse_disable", NULL))
|
if (get_opt_bool("ui.mouse_disable", NULL))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (mouse_lock_exists()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (mouse_enabled) return;
|
if (mouse_enabled) return;
|
||||||
|
|
||||||
if (is_xterm()) send_mouse_init_sequence(get_output_handle());
|
if (is_xterm()) send_mouse_init_sequence(get_output_handle());
|
||||||
|
@ -9,6 +9,8 @@ struct interlink_event;
|
|||||||
struct itrm;
|
struct itrm;
|
||||||
struct session;
|
struct session;
|
||||||
|
|
||||||
|
extern int mouse_enabled;
|
||||||
|
|
||||||
/* The mouse reporting button byte looks like:
|
/* The mouse reporting button byte looks like:
|
||||||
*
|
*
|
||||||
* -ss??bbb
|
* -ss??bbb
|
||||||
|
Loading…
x
Reference in New Issue
Block a user