mirror of https://github.com/cy384/ssheven.git
only send mouse clicks when the console wants them (version->0.8.5)
This commit is contained in:
parent
ef6fedb6a6
commit
7678ae0779
|
@ -13,6 +13,8 @@
|
|||
|
||||
#include <Sound.h>
|
||||
|
||||
#include <vterm.h>
|
||||
|
||||
char key_to_vterm[256] = { VTERM_KEY_NONE };
|
||||
|
||||
void setup_key_translation(void)
|
||||
|
@ -150,14 +152,14 @@ inline int idx2qd(VTermColor c)
|
|||
// p is in window local coordinates
|
||||
void mouse_click(Point p, bool click)
|
||||
{
|
||||
if (prefs.mouse_mode == CLICK_SEND)
|
||||
if (con.mouse_mode == CLICK_SEND)
|
||||
{
|
||||
int row = p.v / con.cell_height;
|
||||
int col = p.h / con.cell_width;
|
||||
vterm_mouse_move(con.vterm, row, col, VTERM_MOD_NONE);
|
||||
vterm_mouse_button(con.vterm, 1, click, VTERM_MOD_NONE);
|
||||
}
|
||||
else if (prefs.mouse_mode == CLICK_SELECT)
|
||||
else if (con.mouse_mode == CLICK_SELECT)
|
||||
{
|
||||
// TODO: implement text selection
|
||||
}
|
||||
|
@ -545,6 +547,9 @@ int settermprop(VTermProp prop, VTermValue *val, void *user)
|
|||
case VTERM_PROP_REVERSE: //bool
|
||||
case VTERM_PROP_CURSORSHAPE: // number
|
||||
case VTERM_PROP_MOUSE: // number
|
||||
// record whether or not the terminal wants mouse clicks
|
||||
con.mouse_mode = (val->number | VTERM_MOUSE_WANT_CLICK) ? CLICK_SEND : CLICK_SELECT;
|
||||
return 1;
|
||||
case VTERM_PROP_CURSORBLINK: // bool
|
||||
case VTERM_PROP_ALTSCREEN: // bool
|
||||
default:
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
#define __SSHEVEN_CONSTANTS_R__
|
||||
|
||||
/* so many versions */
|
||||
#define SSHEVEN_VERSION "0.8.4"
|
||||
#define SSHEVEN_LONG_VERSION "0.8.4 prerelease, by cy384"
|
||||
#define SSHEVEN_DESCRIPTION "ssheven 0.8.4 by cy384"
|
||||
#define SSHEVEN_VERSION "0.8.5"
|
||||
#define SSHEVEN_LONG_VERSION "0.8.5 prerelease, by cy384"
|
||||
#define SSHEVEN_DESCRIPTION "ssheven 0.8.5 by cy384"
|
||||
#define SSHEVEN_VERSION_MAJOR 0x00
|
||||
#define SSHEVEN_VERSION_MINOR 0x84
|
||||
#define SSHEVEN_VERSION_MINOR 0x85
|
||||
#define SSHEVEN_VERSION_PRERELEASE 0x01
|
||||
|
||||
/* options: development, alpha, beta, release */
|
||||
|
|
31
ssheven.c
31
ssheven.c
|
@ -25,7 +25,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
// sinful globals
|
||||
struct ssheven_console con = { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 1, NULL, NULL };
|
||||
struct ssheven_console con = { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 1, CLICK_SELECT, NULL, NULL };
|
||||
struct ssheven_ssh_connection ssh_con = { NULL, NULL, kOTInvalidEndpointRef, NULL, NULL };
|
||||
struct preferences prefs;
|
||||
|
||||
|
@ -118,7 +118,7 @@ int save_prefs(void)
|
|||
memset(output_buffer, 0, write_length);
|
||||
|
||||
long int i = snprintf(output_buffer, write_length, "%d\n%d\n", prefs.major_version, prefs.minor_version);
|
||||
i += snprintf(output_buffer+i, write_length-i, "%d\n%d\n%d\n%d\n%d\n", (int)prefs.auth_type, (int)prefs.display_mode, (int)prefs.fg_color, (int)prefs.bg_color, (int)prefs.mouse_mode);
|
||||
i += snprintf(output_buffer+i, write_length-i, "%d\n%d\n%d\n%d\n", (int)prefs.auth_type, (int)prefs.display_mode, (int)prefs.fg_color, (int)prefs.bg_color);
|
||||
|
||||
snprintf(output_buffer+i, prefs.hostname[0]+1, "%s", prefs.hostname+1); i += prefs.hostname[0];
|
||||
i += snprintf(output_buffer+i, write_length-i, "\n");
|
||||
|
@ -180,8 +180,6 @@ void init_prefs(void)
|
|||
prefs.fg_color = blackColor;
|
||||
prefs.bg_color = whiteColor;
|
||||
|
||||
prefs.mouse_mode = CLICK_SELECT;
|
||||
|
||||
prefs.loaded_from_file = 0;
|
||||
}
|
||||
|
||||
|
@ -230,7 +228,7 @@ void load_prefs(void)
|
|||
if ((prefs.major_version == SSHEVEN_VERSION_MAJOR) && (prefs.minor_version == SSHEVEN_VERSION_MINOR))
|
||||
{
|
||||
prefs.loaded_from_file = 1;
|
||||
items_got = sscanf(buffer, "%d\n%d\n%d\n%d\n%d\n%d\n%d\n%255[^\n]\n%255[^\n]\n%255[^\n]\n%[^\n]\n%[^\n]", &prefs.major_version, &prefs.minor_version, (int*)&prefs.auth_type, (int*)&prefs.display_mode, &prefs.fg_color, &prefs.bg_color, (int*)&prefs.mouse_mode, prefs.hostname+1, prefs.username+1, prefs.port+1, prefs.privkey_path, prefs.pubkey_path);
|
||||
items_got = sscanf(buffer, "%d\n%d\n%d\n%d\n%d\n%d\n%255[^\n]\n%255[^\n]\n%255[^\n]\n%[^\n]\n%[^\n]", &prefs.major_version, &prefs.minor_version, (int*)&prefs.auth_type, (int*)&prefs.display_mode, &prefs.fg_color, &prefs.bg_color, prefs.hostname+1, prefs.username+1, prefs.port+1, prefs.privkey_path, prefs.pubkey_path);
|
||||
|
||||
// add the size for the pascal strings
|
||||
prefs.hostname[0] = (unsigned char)strlen(prefs.hostname+1);
|
||||
|
@ -357,31 +355,12 @@ void preferences_window(void)
|
|||
fg_color_menu = (ControlHandle)itemH;
|
||||
SetControlValue(fg_color_menu, qd_color_to_menu_item(prefs.fg_color));
|
||||
|
||||
// get handle and set mouse mode checkbox
|
||||
ControlHandle mouse_checkbox;
|
||||
GetDialogItem(dlg, 9, &type, &itemH, &box);
|
||||
mouse_checkbox = (ControlHandle)itemH;
|
||||
if (prefs.mouse_mode == CLICK_SEND)
|
||||
{
|
||||
SetControlValue(mouse_checkbox, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetControlValue(mouse_checkbox, 0);
|
||||
}
|
||||
|
||||
// let the modalmanager do everything
|
||||
// stop on ok or cancel
|
||||
short item;
|
||||
do {
|
||||
ModalDialog(NULL, &item);
|
||||
|
||||
// flip the mouse checkbox if clicked
|
||||
if (item == 9)
|
||||
{
|
||||
SetControlValue(mouse_checkbox, !GetControlValue(mouse_checkbox));
|
||||
}
|
||||
} while(item != 1 && item != 10);
|
||||
} while(item != 1 && item != 9);
|
||||
|
||||
// save if OK'd
|
||||
if (item == 1)
|
||||
|
@ -396,8 +375,6 @@ void preferences_window(void)
|
|||
prefs.bg_color = menu_item_to_qd_color(GetControlValue(bg_color_menu));
|
||||
prefs.fg_color = menu_item_to_qd_color(GetControlValue(fg_color_menu));
|
||||
|
||||
prefs.mouse_mode = GetControlValue(mouse_checkbox) ? CLICK_SEND : CLICK_SELECT;
|
||||
|
||||
save_prefs();
|
||||
|
||||
prefs.bg_color = save_bg;
|
||||
|
|
|
@ -37,6 +37,8 @@ struct ssheven_console
|
|||
long int last_cursor_blink;
|
||||
int cursor_visible;
|
||||
|
||||
enum { CLICK_SEND, CLICK_SELECT } mouse_mode;
|
||||
|
||||
VTerm* vterm;
|
||||
VTermScreen* vts;
|
||||
};
|
||||
|
@ -80,8 +82,6 @@ struct preferences
|
|||
enum { FASTEST, MONOCHROME, COLOR } display_mode;
|
||||
int fg_color;
|
||||
int bg_color;
|
||||
|
||||
enum { CLICK_SEND, CLICK_SELECT } mouse_mode;
|
||||
};
|
||||
|
||||
extern struct preferences prefs;
|
||||
|
|
Loading…
Reference in New Issue