mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 09:27:59 +00:00
Formatting change to braces around one case of a switch.
Sometimes, within a switch statement, you want to declare local variables specific to the handler for one particular case. Until now I've mostly been writing this in the form switch (discriminant) { case SIMPLE: do stuff; break; case COMPLICATED: { declare variables; do stuff; } break; } which is ugly because the two pieces of essentially similar code appear at different indent levels, and also inconvenient because you have less horizontal space available to write the complicated case handler in - particuarly undesirable because _complicated_ case handlers are the ones most likely to need all the space they can get! After encountering a rather nicer idiom in the LLVM source code, and after a bit of hackery this morning figuring out how to persuade Emacs's auto-indent to do what I wanted with it, I've decided to move to an idiom in which the open brace comes right after the case statement, and the code within it is indented the same as it would have been without the brace. Then the whole case handler (including the break) lives inside those braces, and you get something that looks more like this: switch (discriminant) { case SIMPLE: do stuff; break; case COMPLICATED: { declare variables; do stuff; break; } } This commit is a big-bang change that reformats all the complicated case handlers I could find into the new layout. This is particularly nice in the Pageant main function, in which almost _every_ case handler had a bundle of variables and was long and complicated. (In fact that's what motivated me to get round to this.) Some of the innermost parts of the terminal escape-sequence handling are also breathing a bit easier now the horizontal pressure on them is relieved. (Also, in a few cases, I was able to remove the extra braces completely, because the only variable local to the case handler was a loop variable which our new C99 policy allows me to move into the initialiser clause of its for statement.) Viewed with whitespace ignored, this is not too disruptive a change. Downstream patches that conflict with it may need to be reapplied using --ignore-whitespace or similar.
This commit is contained in:
parent
2571eabeef
commit
8d186c3c93
27
be_misc.c
27
be_misc.c
@ -32,26 +32,25 @@ void backend_socket_log(Seat *seat, LogContext *logctx,
|
|||||||
sk_getaddr(addr, addrbuf, lenof(addrbuf));
|
sk_getaddr(addr, addrbuf, lenof(addrbuf));
|
||||||
msg = dupprintf("Connected to %s", addrbuf);
|
msg = dupprintf("Connected to %s", addrbuf);
|
||||||
break;
|
break;
|
||||||
case PLUGLOG_PROXY_MSG:
|
case PLUGLOG_PROXY_MSG: {
|
||||||
/* Proxy-related log messages have their own identifying
|
/* Proxy-related log messages have their own identifying
|
||||||
* prefix already, put on by our caller. */
|
* prefix already, put on by our caller. */
|
||||||
{
|
int len, log_to_term;
|
||||||
int len, log_to_term;
|
|
||||||
|
|
||||||
/* Suffix \r\n temporarily, so we can log to the terminal. */
|
/* Suffix \r\n temporarily, so we can log to the terminal. */
|
||||||
msg = dupprintf("%s\r\n", error_msg);
|
msg = dupprintf("%s\r\n", error_msg);
|
||||||
len = strlen(msg);
|
len = strlen(msg);
|
||||||
assert(len >= 2);
|
assert(len >= 2);
|
||||||
|
|
||||||
log_to_term = conf_get_int(conf, CONF_proxy_log_to_term);
|
log_to_term = conf_get_int(conf, CONF_proxy_log_to_term);
|
||||||
if (log_to_term == AUTO)
|
if (log_to_term == AUTO)
|
||||||
log_to_term = session_started ? FORCE_OFF : FORCE_ON;
|
log_to_term = session_started ? FORCE_OFF : FORCE_ON;
|
||||||
if (log_to_term == FORCE_ON)
|
if (log_to_term == FORCE_ON)
|
||||||
seat_stderr(seat, msg, len);
|
seat_stderr(seat, msg, len);
|
||||||
|
|
||||||
msg[len-2] = '\0'; /* remove the \r\n again */
|
msg[len-2] = '\0'; /* remove the \r\n again */
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
msg = NULL; /* shouldn't happen, but placate optimiser */
|
msg = NULL; /* shouldn't happen, but placate optimiser */
|
||||||
break;
|
break;
|
||||||
|
278
cmdgen.c
278
cmdgen.c
@ -211,91 +211,90 @@ int main(int argc, char **argv)
|
|||||||
while (p && *++p) {
|
while (p && *++p) {
|
||||||
char c = *p;
|
char c = *p;
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '-':
|
case '-': {
|
||||||
/*
|
/*
|
||||||
* Long option.
|
* Long option.
|
||||||
*/
|
*/
|
||||||
{
|
char *opt, *val;
|
||||||
char *opt, *val;
|
opt = p++; /* opt will have _one_ leading - */
|
||||||
opt = p++; /* opt will have _one_ leading - */
|
while (*p && *p != '=')
|
||||||
while (*p && *p != '=')
|
p++; /* find end of option */
|
||||||
p++; /* find end of option */
|
if (*p == '=') {
|
||||||
if (*p == '=') {
|
*p++ = '\0';
|
||||||
*p++ = '\0';
|
val = p;
|
||||||
val = p;
|
} else
|
||||||
} else
|
val = NULL;
|
||||||
val = NULL;
|
|
||||||
|
|
||||||
if (!strcmp(opt, "-help")) {
|
if (!strcmp(opt, "-help")) {
|
||||||
if (val) {
|
if (val) {
|
||||||
errs = true;
|
errs = true;
|
||||||
fprintf(stderr, "puttygen: option `-%s'"
|
fprintf(stderr, "puttygen: option `-%s'"
|
||||||
" expects no argument\n", opt);
|
" expects no argument\n", opt);
|
||||||
} else {
|
} else {
|
||||||
help();
|
help();
|
||||||
nogo = true;
|
nogo = true;
|
||||||
}
|
}
|
||||||
} else if (!strcmp(opt, "-version")) {
|
} else if (!strcmp(opt, "-version")) {
|
||||||
if (val) {
|
if (val) {
|
||||||
errs = true;
|
errs = true;
|
||||||
fprintf(stderr, "puttygen: option `-%s'"
|
fprintf(stderr, "puttygen: option `-%s'"
|
||||||
" expects no argument\n", opt);
|
" expects no argument\n", opt);
|
||||||
} else {
|
} else {
|
||||||
showversion();
|
showversion();
|
||||||
nogo = true;
|
nogo = true;
|
||||||
}
|
}
|
||||||
} else if (!strcmp(opt, "-pgpfp")) {
|
} else if (!strcmp(opt, "-pgpfp")) {
|
||||||
if (val) {
|
if (val) {
|
||||||
errs = true;
|
errs = true;
|
||||||
fprintf(stderr, "puttygen: option `-%s'"
|
fprintf(stderr, "puttygen: option `-%s'"
|
||||||
" expects no argument\n", opt);
|
" expects no argument\n", opt);
|
||||||
} else {
|
} else {
|
||||||
/* support --pgpfp for consistency */
|
/* support --pgpfp for consistency */
|
||||||
pgp_fingerprints();
|
pgp_fingerprints();
|
||||||
nogo = true;
|
nogo = true;
|
||||||
}
|
}
|
||||||
} else if (!strcmp(opt, "-old-passphrase")) {
|
} else if (!strcmp(opt, "-old-passphrase")) {
|
||||||
if (!val && argc > 1)
|
if (!val && argc > 1)
|
||||||
--argc, val = *++argv;
|
--argc, val = *++argv;
|
||||||
if (!val) {
|
if (!val) {
|
||||||
errs = true;
|
errs = true;
|
||||||
fprintf(stderr, "puttygen: option `-%s'"
|
fprintf(stderr, "puttygen: option `-%s'"
|
||||||
" expects an argument\n", opt);
|
" expects an argument\n", opt);
|
||||||
} else {
|
} else {
|
||||||
old_passphrase = readpassphrase(val);
|
old_passphrase = readpassphrase(val);
|
||||||
if (!old_passphrase)
|
if (!old_passphrase)
|
||||||
errs = true;
|
|
||||||
}
|
|
||||||
} else if (!strcmp(opt, "-new-passphrase")) {
|
|
||||||
if (!val && argc > 1)
|
|
||||||
--argc, val = *++argv;
|
|
||||||
if (!val) {
|
|
||||||
errs = true;
|
|
||||||
fprintf(stderr, "puttygen: option `-%s'"
|
|
||||||
" expects an argument\n", opt);
|
|
||||||
} else {
|
|
||||||
new_passphrase = readpassphrase(val);
|
|
||||||
if (!new_passphrase)
|
|
||||||
errs = true;
|
|
||||||
}
|
|
||||||
} else if (!strcmp(opt, "-random-device")) {
|
|
||||||
if (!val && argc > 1)
|
|
||||||
--argc, val = *++argv;
|
|
||||||
if (!val) {
|
|
||||||
errs = true;
|
|
||||||
fprintf(stderr, "puttygen: option `-%s'"
|
|
||||||
" expects an argument\n", opt);
|
|
||||||
} else {
|
|
||||||
random_device = val;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
errs = true;
|
errs = true;
|
||||||
fprintf(stderr,
|
}
|
||||||
"puttygen: no such option `-%s'\n", opt);
|
} else if (!strcmp(opt, "-new-passphrase")) {
|
||||||
}
|
if (!val && argc > 1)
|
||||||
|
--argc, val = *++argv;
|
||||||
|
if (!val) {
|
||||||
|
errs = true;
|
||||||
|
fprintf(stderr, "puttygen: option `-%s'"
|
||||||
|
" expects an argument\n", opt);
|
||||||
|
} else {
|
||||||
|
new_passphrase = readpassphrase(val);
|
||||||
|
if (!new_passphrase)
|
||||||
|
errs = true;
|
||||||
|
}
|
||||||
|
} else if (!strcmp(opt, "-random-device")) {
|
||||||
|
if (!val && argc > 1)
|
||||||
|
--argc, val = *++argv;
|
||||||
|
if (!val) {
|
||||||
|
errs = true;
|
||||||
|
fprintf(stderr, "puttygen: option `-%s'"
|
||||||
|
" expects an argument\n", opt);
|
||||||
|
} else {
|
||||||
|
random_device = val;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
errs = true;
|
||||||
|
fprintf(stderr,
|
||||||
|
"puttygen: no such option `-%s'\n", opt);
|
||||||
}
|
}
|
||||||
p = NULL;
|
p = NULL;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 'h':
|
case 'h':
|
||||||
case 'V':
|
case 'V':
|
||||||
case 'P':
|
case 'P':
|
||||||
@ -941,75 +940,74 @@ int main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PUBLIC:
|
case PUBLIC:
|
||||||
case PUBLICO:
|
case PUBLICO: {
|
||||||
{
|
FILE *fp;
|
||||||
FILE *fp;
|
|
||||||
|
|
||||||
if (outfile) {
|
if (outfile) {
|
||||||
fp = f_open(outfilename, "w", false);
|
fp = f_open(outfilename, "w", false);
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
fprintf(stderr, "unable to open output file\n");
|
fprintf(stderr, "unable to open output file\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fp = stdout;
|
fp = stdout;
|
||||||
}
|
|
||||||
|
|
||||||
if (sshver == 1) {
|
|
||||||
ssh1_write_pubkey(fp, ssh1key);
|
|
||||||
} else {
|
|
||||||
if (!ssh2blob) {
|
|
||||||
assert(ssh2key);
|
|
||||||
ssh2blob = strbuf_new();
|
|
||||||
ssh_key_public_blob(ssh2key->key, BinarySink_UPCAST(ssh2blob));
|
|
||||||
}
|
|
||||||
|
|
||||||
ssh2_write_pubkey(fp, ssh2key ? ssh2key->comment : origcomment,
|
|
||||||
ssh2blob->s, ssh2blob->len,
|
|
||||||
(outtype == PUBLIC ?
|
|
||||||
SSH_KEYTYPE_SSH2_PUBLIC_RFC4716 :
|
|
||||||
SSH_KEYTYPE_SSH2_PUBLIC_OPENSSH));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (outfile)
|
|
||||||
fclose(fp);
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
case FP:
|
if (sshver == 1) {
|
||||||
{
|
ssh1_write_pubkey(fp, ssh1key);
|
||||||
FILE *fp;
|
} else {
|
||||||
char *fingerprint;
|
if (!ssh2blob) {
|
||||||
|
assert(ssh2key);
|
||||||
|
ssh2blob = strbuf_new();
|
||||||
|
ssh_key_public_blob(ssh2key->key, BinarySink_UPCAST(ssh2blob));
|
||||||
|
}
|
||||||
|
|
||||||
if (sshver == 1) {
|
ssh2_write_pubkey(fp, ssh2key ? ssh2key->comment : origcomment,
|
||||||
assert(ssh1key);
|
ssh2blob->s, ssh2blob->len,
|
||||||
fingerprint = rsa_ssh1_fingerprint(ssh1key);
|
(outtype == PUBLIC ?
|
||||||
} else {
|
SSH_KEYTYPE_SSH2_PUBLIC_RFC4716 :
|
||||||
if (ssh2key) {
|
SSH_KEYTYPE_SSH2_PUBLIC_OPENSSH));
|
||||||
fingerprint = ssh2_fingerprint(ssh2key->key);
|
|
||||||
} else {
|
|
||||||
assert(ssh2blob);
|
|
||||||
fingerprint = ssh2_fingerprint_blob(
|
|
||||||
ptrlen_from_strbuf(ssh2blob));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (outfile) {
|
|
||||||
fp = f_open(outfilename, "w", false);
|
|
||||||
if (!fp) {
|
|
||||||
fprintf(stderr, "unable to open output file\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
fp = stdout;
|
|
||||||
}
|
|
||||||
fprintf(fp, "%s\n", fingerprint);
|
|
||||||
if (outfile)
|
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
sfree(fingerprint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (outfile)
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case FP: {
|
||||||
|
FILE *fp;
|
||||||
|
char *fingerprint;
|
||||||
|
|
||||||
|
if (sshver == 1) {
|
||||||
|
assert(ssh1key);
|
||||||
|
fingerprint = rsa_ssh1_fingerprint(ssh1key);
|
||||||
|
} else {
|
||||||
|
if (ssh2key) {
|
||||||
|
fingerprint = ssh2_fingerprint(ssh2key->key);
|
||||||
|
} else {
|
||||||
|
assert(ssh2blob);
|
||||||
|
fingerprint = ssh2_fingerprint_blob(
|
||||||
|
ptrlen_from_strbuf(ssh2blob));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (outfile) {
|
||||||
|
fp = f_open(outfilename, "w", false);
|
||||||
|
if (!fp) {
|
||||||
|
fprintf(stderr, "unable to open output file\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fp = stdout;
|
||||||
|
}
|
||||||
|
fprintf(fp, "%s\n", fingerprint);
|
||||||
|
if (outfile)
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
sfree(fingerprint);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case OPENSSH_AUTO:
|
case OPENSSH_AUTO:
|
||||||
case OPENSSH_NEW:
|
case OPENSSH_NEW:
|
||||||
|
19
import.c
19
import.c
@ -1235,20 +1235,19 @@ static struct openssh_new_key *load_openssh_new_key(BinarySource *filesrc,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ON_K_BCRYPT:
|
case ON_K_BCRYPT: {
|
||||||
{
|
BinarySource opts[1];
|
||||||
BinarySource opts[1];
|
|
||||||
|
|
||||||
BinarySource_BARE_INIT_PL(opts, str);
|
BinarySource_BARE_INIT_PL(opts, str);
|
||||||
ret->kdfopts.bcrypt.salt = get_string(opts);
|
ret->kdfopts.bcrypt.salt = get_string(opts);
|
||||||
ret->kdfopts.bcrypt.rounds = get_uint32(opts);
|
ret->kdfopts.bcrypt.rounds = get_uint32(opts);
|
||||||
|
|
||||||
if (get_err(opts)) {
|
if (get_err(opts)) {
|
||||||
errmsg = "failed to parse bcrypt options string";
|
errmsg = "failed to parse bcrypt options string";
|
||||||
goto error;
|
goto error;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
19
minibidi.c
19
minibidi.c
@ -1281,20 +1281,19 @@ int do_bidi(bidi_char *line, int count)
|
|||||||
bover = true;
|
bover = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PDF:
|
case PDF: {
|
||||||
{
|
int prevlevel = getPreviousLevel(levels, i);
|
||||||
int prevlevel = getPreviousLevel(levels, i);
|
|
||||||
|
|
||||||
if (prevlevel == -1) {
|
if (prevlevel == -1) {
|
||||||
currentEmbedding = paragraphLevel;
|
currentEmbedding = paragraphLevel;
|
||||||
currentOverride = ON;
|
currentOverride = ON;
|
||||||
} else {
|
} else {
|
||||||
currentOverride = currentEmbedding & OMASK;
|
currentOverride = currentEmbedding & OMASK;
|
||||||
currentEmbedding = currentEmbedding & ~OMASK;
|
currentEmbedding = currentEmbedding & ~OMASK;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
levels[i] = currentEmbedding;
|
levels[i] = currentEmbedding;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* Whitespace is treated as neutral for now */
|
/* Whitespace is treated as neutral for now */
|
||||||
case WS:
|
case WS:
|
||||||
|
93
proxy.c
93
proxy.c
@ -766,13 +766,12 @@ int proxy_socks4_negotiate (ProxySocket *p, int change)
|
|||||||
put_uint16(command, p->remote_port);
|
put_uint16(command, p->remote_port);
|
||||||
|
|
||||||
switch (sk_addrtype(p->remote_addr)) {
|
switch (sk_addrtype(p->remote_addr)) {
|
||||||
case ADDRTYPE_IPV4:
|
case ADDRTYPE_IPV4: {
|
||||||
{
|
char addr[4];
|
||||||
char addr[4];
|
sk_addrcopy(p->remote_addr, addr);
|
||||||
sk_addrcopy(p->remote_addr, addr);
|
put_data(command, addr, 4);
|
||||||
put_data(command, addr, 4);
|
break;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
case ADDRTYPE_NAME:
|
case ADDRTYPE_NAME:
|
||||||
sk_getaddr(p->remote_addr, hostname, lenof(hostname));
|
sk_getaddr(p->remote_addr, hostname, lenof(hostname));
|
||||||
put_uint32(command, 1);
|
put_uint32(command, 1);
|
||||||
@ -1084,19 +1083,18 @@ int proxy_socks5_negotiate (ProxySocket *p, int change)
|
|||||||
put_byte(command, 4); /* IPv6 */
|
put_byte(command, 4); /* IPv6 */
|
||||||
sk_addrcopy(p->remote_addr, strbuf_append(command, 16));
|
sk_addrcopy(p->remote_addr, strbuf_append(command, 16));
|
||||||
break;
|
break;
|
||||||
case ADDRTYPE_NAME:
|
case ADDRTYPE_NAME: {
|
||||||
{
|
char hostname[512];
|
||||||
char hostname[512];
|
put_byte(command, 3); /* domain name */
|
||||||
put_byte(command, 3); /* domain name */
|
sk_getaddr(p->remote_addr, hostname, lenof(hostname));
|
||||||
sk_getaddr(p->remote_addr, hostname, lenof(hostname));
|
if (!put_pstring(command, hostname)) {
|
||||||
if (!put_pstring(command, hostname)) {
|
p->error = "Proxy error: SOCKS 5 cannot "
|
||||||
p->error = "Proxy error: SOCKS 5 cannot "
|
"support host names longer than 255 chars";
|
||||||
"support host names longer than 255 chars";
|
strbuf_free(command);
|
||||||
strbuf_free(command);
|
return 1;
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
put_uint16(command, p->remote_port);
|
put_uint16(command, p->remote_port);
|
||||||
@ -1317,41 +1315,40 @@ char *format_telnet_command(SockAddr *addr, int port, Conf *conf)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'x':
|
case 'x':
|
||||||
case 'X':
|
case 'X': {
|
||||||
{
|
/* escaped hexadecimal value (ie. \xff) */
|
||||||
/* escaped hexadecimal value (ie. \xff) */
|
unsigned char v = 0;
|
||||||
unsigned char v = 0;
|
int i = 0;
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
eo++;
|
eo++;
|
||||||
if (fmt[eo] >= '0' && fmt[eo] <= '9')
|
if (fmt[eo] >= '0' && fmt[eo] <= '9')
|
||||||
v += fmt[eo] - '0';
|
v += fmt[eo] - '0';
|
||||||
else if (fmt[eo] >= 'a' && fmt[eo] <= 'f')
|
else if (fmt[eo] >= 'a' && fmt[eo] <= 'f')
|
||||||
v += fmt[eo] - 'a' + 10;
|
v += fmt[eo] - 'a' + 10;
|
||||||
else if (fmt[eo] >= 'A' && fmt[eo] <= 'F')
|
else if (fmt[eo] >= 'A' && fmt[eo] <= 'F')
|
||||||
v += fmt[eo] - 'A' + 10;
|
v += fmt[eo] - 'A' + 10;
|
||||||
else {
|
else {
|
||||||
/* non hex character, so we abort and just
|
/* non hex character, so we abort and just
|
||||||
* send the whole thing unescaped (including \x)
|
* send the whole thing unescaped (including \x)
|
||||||
*/
|
*/
|
||||||
put_byte(buf, '\\');
|
put_byte(buf, '\\');
|
||||||
eo = so + 1;
|
eo = so + 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* we only extract two hex characters */
|
/* we only extract two hex characters */
|
||||||
if (i == 1) {
|
if (i == 1) {
|
||||||
put_byte(buf, v);
|
put_byte(buf, v);
|
||||||
eo++;
|
eo++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
v <<= 4;
|
v <<= 4;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
put_data(buf, fmt + so, 2);
|
put_data(buf, fmt + so, 2);
|
||||||
|
11
settings.c
11
settings.c
@ -492,13 +492,12 @@ static void write_clip_setting(settings_w *sesskey, const char *savekey,
|
|||||||
case CLIPUI_EXPLICIT:
|
case CLIPUI_EXPLICIT:
|
||||||
write_setting_s(sesskey, savekey, "explicit");
|
write_setting_s(sesskey, savekey, "explicit");
|
||||||
break;
|
break;
|
||||||
case CLIPUI_CUSTOM:
|
case CLIPUI_CUSTOM: {
|
||||||
{
|
char *sval = dupcat("custom:", conf_get_str(conf, strconfkey));
|
||||||
char *sval = dupcat("custom:", conf_get_str(conf, strconfkey));
|
write_setting_s(sesskey, savekey, sval);
|
||||||
write_setting_s(sesskey, savekey, sval);
|
sfree(sval);
|
||||||
sfree(sval);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,15 +262,14 @@ bool ssh1_handle_direction_specific_packet(
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case SSH1_SMSG_EXIT_STATUS:
|
case SSH1_SMSG_EXIT_STATUS: {
|
||||||
{
|
int exitcode = get_uint32(pktin);
|
||||||
int exitcode = get_uint32(pktin);
|
ppl_logevent("Server sent command exit status %d", exitcode);
|
||||||
ppl_logevent("Server sent command exit status %d", exitcode);
|
ssh_got_exitcode(s->ppl.ssh, exitcode);
|
||||||
ssh_got_exitcode(s->ppl.ssh, exitcode);
|
|
||||||
|
|
||||||
s->session_terminated = true;
|
s->session_terminated = true;
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
@ -115,35 +115,35 @@ bool ssh1_handle_direction_specific_packet(
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case SSH1_CMSG_REQUEST_PTY:
|
case SSH1_CMSG_REQUEST_PTY: {
|
||||||
if (s->finished_setup)
|
if (s->finished_setup)
|
||||||
goto unexpected_setup_packet;
|
goto unexpected_setup_packet;
|
||||||
{
|
|
||||||
ptrlen termtype = get_string(pktin);
|
|
||||||
unsigned height = get_uint32(pktin);
|
|
||||||
unsigned width = get_uint32(pktin);
|
|
||||||
unsigned pixwidth = get_uint32(pktin);
|
|
||||||
unsigned pixheight = get_uint32(pktin);
|
|
||||||
struct ssh_ttymodes modes = read_ttymodes_from_packet(
|
|
||||||
BinarySource_UPCAST(pktin), 1);
|
|
||||||
|
|
||||||
if (get_err(pktin)) {
|
ptrlen termtype = get_string(pktin);
|
||||||
ppl_logevent("Unable to decode pty request packet");
|
unsigned height = get_uint32(pktin);
|
||||||
success = false;
|
unsigned width = get_uint32(pktin);
|
||||||
} else if (!chan_allocate_pty(
|
unsigned pixwidth = get_uint32(pktin);
|
||||||
s->mainchan_chan, termtype, width, height,
|
unsigned pixheight = get_uint32(pktin);
|
||||||
pixwidth, pixheight, modes)) {
|
struct ssh_ttymodes modes = read_ttymodes_from_packet(
|
||||||
ppl_logevent("Unable to allocate a pty");
|
BinarySource_UPCAST(pktin), 1);
|
||||||
success = false;
|
|
||||||
} else {
|
if (get_err(pktin)) {
|
||||||
success = true;
|
ppl_logevent("Unable to decode pty request packet");
|
||||||
}
|
success = false;
|
||||||
|
} else if (!chan_allocate_pty(
|
||||||
|
s->mainchan_chan, termtype, width, height,
|
||||||
|
pixwidth, pixheight, modes)) {
|
||||||
|
ppl_logevent("Unable to allocate a pty");
|
||||||
|
success = false;
|
||||||
|
} else {
|
||||||
|
success = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
pktout = ssh_bpp_new_pktout(
|
pktout = ssh_bpp_new_pktout(
|
||||||
s->ppl.bpp, (success ? SSH1_SMSG_SUCCESS : SSH1_SMSG_FAILURE));
|
s->ppl.bpp, (success ? SSH1_SMSG_SUCCESS : SSH1_SMSG_FAILURE));
|
||||||
pq_push(s->ppl.out_pq, pktout);
|
pq_push(s->ppl.out_pq, pktout);
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
case SSH1_CMSG_PORT_FORWARD_REQUEST:
|
case SSH1_CMSG_PORT_FORWARD_REQUEST:
|
||||||
if (s->finished_setup)
|
if (s->finished_setup)
|
||||||
@ -166,25 +166,24 @@ bool ssh1_handle_direction_specific_packet(
|
|||||||
pq_push(s->ppl.out_pq, pktout);
|
pq_push(s->ppl.out_pq, pktout);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case SSH1_CMSG_X11_REQUEST_FORWARDING:
|
case SSH1_CMSG_X11_REQUEST_FORWARDING: {
|
||||||
if (s->finished_setup)
|
if (s->finished_setup)
|
||||||
goto unexpected_setup_packet;
|
goto unexpected_setup_packet;
|
||||||
|
|
||||||
{
|
ptrlen authproto = get_string(pktin);
|
||||||
ptrlen authproto = get_string(pktin);
|
ptrlen authdata = get_string(pktin);
|
||||||
ptrlen authdata = get_string(pktin);
|
unsigned screen_number = 0;
|
||||||
unsigned screen_number = 0;
|
if (s->remote_protoflags & SSH1_PROTOFLAG_SCREEN_NUMBER)
|
||||||
if (s->remote_protoflags & SSH1_PROTOFLAG_SCREEN_NUMBER)
|
screen_number = get_uint32(pktin);
|
||||||
screen_number = get_uint32(pktin);
|
|
||||||
|
|
||||||
success = chan_enable_x11_forwarding(
|
success = chan_enable_x11_forwarding(
|
||||||
s->mainchan_chan, false, authproto, authdata, screen_number);
|
s->mainchan_chan, false, authproto, authdata, screen_number);
|
||||||
}
|
|
||||||
|
|
||||||
pktout = ssh_bpp_new_pktout(
|
pktout = ssh_bpp_new_pktout(
|
||||||
s->ppl.bpp, (success ? SSH1_SMSG_SUCCESS : SSH1_SMSG_FAILURE));
|
s->ppl.bpp, (success ? SSH1_SMSG_SUCCESS : SSH1_SMSG_FAILURE));
|
||||||
pq_push(s->ppl.out_pq, pktout);
|
pq_push(s->ppl.out_pq, pktout);
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
case SSH1_CMSG_AGENT_REQUEST_FORWARDING:
|
case SSH1_CMSG_AGENT_REQUEST_FORWARDING:
|
||||||
if (s->finished_setup)
|
if (s->finished_setup)
|
||||||
|
@ -516,19 +516,18 @@ static bool ssh2_connection_filter_queue(struct ssh2_connection_state *s)
|
|||||||
ssh2_channel_try_eof(c); /* in case we had a pending EOF */
|
ssh2_channel_try_eof(c); /* in case we had a pending EOF */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SSH2_MSG_CHANNEL_OPEN_FAILURE:
|
case SSH2_MSG_CHANNEL_OPEN_FAILURE: {
|
||||||
assert(c->halfopen);
|
assert(c->halfopen);
|
||||||
|
|
||||||
{
|
char *err = ssh2_channel_open_failure_error_text(pktin);
|
||||||
char *err = ssh2_channel_open_failure_error_text(pktin);
|
chan_open_failed(c->chan, err);
|
||||||
chan_open_failed(c->chan, err);
|
sfree(err);
|
||||||
sfree(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
del234(s->channels, c);
|
del234(s->channels, c);
|
||||||
ssh2_channel_free(c);
|
ssh2_channel_free(c);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case SSH2_MSG_CHANNEL_DATA:
|
case SSH2_MSG_CHANNEL_DATA:
|
||||||
case SSH2_MSG_CHANNEL_EXTENDED_DATA:
|
case SSH2_MSG_CHANNEL_EXTENDED_DATA:
|
||||||
|
855
terminal.c
855
terminal.c
@ -3411,71 +3411,70 @@ static void term_out(Terminal *term)
|
|||||||
strbuf_free(buf);
|
strbuf_free(buf);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '\007': /* BEL: Bell */
|
case '\007': { /* BEL: Bell */
|
||||||
{
|
struct beeptime *newbeep;
|
||||||
struct beeptime *newbeep;
|
unsigned long ticks;
|
||||||
unsigned long ticks;
|
|
||||||
|
|
||||||
ticks = GETTICKCOUNT();
|
ticks = GETTICKCOUNT();
|
||||||
|
|
||||||
if (!term->beep_overloaded) {
|
if (!term->beep_overloaded) {
|
||||||
newbeep = snew(struct beeptime);
|
newbeep = snew(struct beeptime);
|
||||||
newbeep->ticks = ticks;
|
newbeep->ticks = ticks;
|
||||||
newbeep->next = NULL;
|
newbeep->next = NULL;
|
||||||
if (!term->beephead)
|
if (!term->beephead)
|
||||||
term->beephead = newbeep;
|
term->beephead = newbeep;
|
||||||
else
|
else
|
||||||
term->beeptail->next = newbeep;
|
term->beeptail->next = newbeep;
|
||||||
term->beeptail = newbeep;
|
term->beeptail = newbeep;
|
||||||
term->nbeeps++;
|
term->nbeeps++;
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Throw out any beeps that happened more than
|
|
||||||
* t seconds ago.
|
|
||||||
*/
|
|
||||||
while (term->beephead &&
|
|
||||||
term->beephead->ticks < ticks - term->bellovl_t) {
|
|
||||||
struct beeptime *tmp = term->beephead;
|
|
||||||
term->beephead = tmp->next;
|
|
||||||
sfree(tmp);
|
|
||||||
if (!term->beephead)
|
|
||||||
term->beeptail = NULL;
|
|
||||||
term->nbeeps--;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (term->bellovl && term->beep_overloaded &&
|
|
||||||
ticks - term->lastbeep >= (unsigned)term->bellovl_s) {
|
|
||||||
/*
|
|
||||||
* If we're currently overloaded and the
|
|
||||||
* last beep was more than s seconds ago,
|
|
||||||
* leave overload mode.
|
|
||||||
*/
|
|
||||||
term->beep_overloaded = false;
|
|
||||||
} else if (term->bellovl && !term->beep_overloaded &&
|
|
||||||
term->nbeeps >= term->bellovl_n) {
|
|
||||||
/*
|
|
||||||
* Now, if we have n or more beeps
|
|
||||||
* remaining in the queue, go into overload
|
|
||||||
* mode.
|
|
||||||
*/
|
|
||||||
term->beep_overloaded = true;
|
|
||||||
}
|
|
||||||
term->lastbeep = ticks;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Perform an actual beep if we're not overloaded.
|
|
||||||
*/
|
|
||||||
if (!term->bellovl || !term->beep_overloaded) {
|
|
||||||
win_bell(term->win, term->beep);
|
|
||||||
|
|
||||||
if (term->beep == BELL_VISUAL) {
|
|
||||||
term_schedule_vbell(term, false, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
seen_disp_event(term);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Throw out any beeps that happened more than
|
||||||
|
* t seconds ago.
|
||||||
|
*/
|
||||||
|
while (term->beephead &&
|
||||||
|
term->beephead->ticks < ticks - term->bellovl_t) {
|
||||||
|
struct beeptime *tmp = term->beephead;
|
||||||
|
term->beephead = tmp->next;
|
||||||
|
sfree(tmp);
|
||||||
|
if (!term->beephead)
|
||||||
|
term->beeptail = NULL;
|
||||||
|
term->nbeeps--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (term->bellovl && term->beep_overloaded &&
|
||||||
|
ticks - term->lastbeep >= (unsigned)term->bellovl_s) {
|
||||||
|
/*
|
||||||
|
* If we're currently overloaded and the
|
||||||
|
* last beep was more than s seconds ago,
|
||||||
|
* leave overload mode.
|
||||||
|
*/
|
||||||
|
term->beep_overloaded = false;
|
||||||
|
} else if (term->bellovl && !term->beep_overloaded &&
|
||||||
|
term->nbeeps >= term->bellovl_n) {
|
||||||
|
/*
|
||||||
|
* Now, if we have n or more beeps
|
||||||
|
* remaining in the queue, go into overload
|
||||||
|
* mode.
|
||||||
|
*/
|
||||||
|
term->beep_overloaded = true;
|
||||||
|
}
|
||||||
|
term->lastbeep = ticks;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Perform an actual beep if we're not overloaded.
|
||||||
|
*/
|
||||||
|
if (!term->bellovl || !term->beep_overloaded) {
|
||||||
|
win_bell(term->win, term->beep);
|
||||||
|
|
||||||
|
if (term->beep == BELL_VISUAL) {
|
||||||
|
term_schedule_vbell(term, false, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
seen_disp_event(term);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case '\b': /* BS: Back space */
|
case '\b': /* BS: Back space */
|
||||||
if (term->curs.x == 0 && (term->curs.y == 0 || !term->wrap))
|
if (term->curs.x == 0 && (term->curs.y == 0 || !term->wrap))
|
||||||
/* do nothing */ ;
|
/* do nothing */ ;
|
||||||
@ -3542,28 +3541,27 @@ static void term_out(Terminal *term)
|
|||||||
if (term->logctx)
|
if (term->logctx)
|
||||||
logtraffic(term->logctx, (unsigned char) c, LGTYP_ASCII);
|
logtraffic(term->logctx, (unsigned char) c, LGTYP_ASCII);
|
||||||
break;
|
break;
|
||||||
case '\t': /* HT: Character tabulation */
|
case '\t': { /* HT: Character tabulation */
|
||||||
{
|
pos old_curs = term->curs;
|
||||||
pos old_curs = term->curs;
|
termline *ldata = scrlineptr(term->curs.y);
|
||||||
termline *ldata = scrlineptr(term->curs.y);
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
term->curs.x++;
|
term->curs.x++;
|
||||||
} while (term->curs.x < term->cols - 1 &&
|
} while (term->curs.x < term->cols - 1 &&
|
||||||
!term->tabs[term->curs.x]);
|
!term->tabs[term->curs.x]);
|
||||||
|
|
||||||
if ((ldata->lattr & LATTR_MODE) != LATTR_NORM) {
|
if ((ldata->lattr & LATTR_MODE) != LATTR_NORM) {
|
||||||
if (term->curs.x >= term->cols / 2)
|
if (term->curs.x >= term->cols / 2)
|
||||||
term->curs.x = term->cols / 2 - 1;
|
term->curs.x = term->cols / 2 - 1;
|
||||||
} else {
|
} else {
|
||||||
if (term->curs.x >= term->cols)
|
if (term->curs.x >= term->cols)
|
||||||
term->curs.x = term->cols - 1;
|
term->curs.x = term->cols - 1;
|
||||||
}
|
|
||||||
|
|
||||||
check_selection(term, old_curs, term->curs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_selection(term, old_curs, term->curs);
|
||||||
seen_disp_event(term);
|
seen_disp_event(term);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
switch (term->termstate) {
|
switch (term->termstate) {
|
||||||
@ -3679,62 +3677,60 @@ static void term_out(Terminal *term)
|
|||||||
term->tabs[term->curs.x] = true;
|
term->tabs[term->curs.x] = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ANSI('8', '#'): /* DECALN: fills screen with Es :-) */
|
case ANSI('8', '#'): { /* DECALN: fills screen with Es :-) */
|
||||||
compatibility(VT100);
|
compatibility(VT100);
|
||||||
{
|
termline *ldata;
|
||||||
termline *ldata;
|
int i, j;
|
||||||
int i, j;
|
pos scrtop, scrbot;
|
||||||
pos scrtop, scrbot;
|
|
||||||
|
|
||||||
for (i = 0; i < term->rows; i++) {
|
for (i = 0; i < term->rows; i++) {
|
||||||
ldata = scrlineptr(i);
|
ldata = scrlineptr(i);
|
||||||
check_line_size(term, ldata);
|
check_line_size(term, ldata);
|
||||||
for (j = 0; j < term->cols; j++) {
|
for (j = 0; j < term->cols; j++) {
|
||||||
copy_termchar(ldata, j,
|
copy_termchar(ldata, j,
|
||||||
&term->basic_erase_char);
|
&term->basic_erase_char);
|
||||||
ldata->chars[j].chr = 'E';
|
ldata->chars[j].chr = 'E';
|
||||||
}
|
}
|
||||||
ldata->lattr = LATTR_NORM;
|
ldata->lattr = LATTR_NORM;
|
||||||
}
|
|
||||||
if (term->scroll_on_disp)
|
|
||||||
term->disptop = 0;
|
|
||||||
seen_disp_event(term);
|
|
||||||
scrtop.x = scrtop.y = 0;
|
|
||||||
scrbot.x = 0;
|
|
||||||
scrbot.y = term->rows;
|
|
||||||
check_selection(term, scrtop, scrbot);
|
|
||||||
}
|
}
|
||||||
|
if (term->scroll_on_disp)
|
||||||
|
term->disptop = 0;
|
||||||
|
seen_disp_event(term);
|
||||||
|
scrtop.x = scrtop.y = 0;
|
||||||
|
scrbot.x = 0;
|
||||||
|
scrbot.y = term->rows;
|
||||||
|
check_selection(term, scrtop, scrbot);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case ANSI('3', '#'):
|
case ANSI('3', '#'):
|
||||||
case ANSI('4', '#'):
|
case ANSI('4', '#'):
|
||||||
case ANSI('5', '#'):
|
case ANSI('5', '#'):
|
||||||
case ANSI('6', '#'):
|
case ANSI('6', '#'): {
|
||||||
compatibility(VT100);
|
compatibility(VT100);
|
||||||
{
|
int nlattr;
|
||||||
int nlattr;
|
termline *ldata;
|
||||||
termline *ldata;
|
|
||||||
|
|
||||||
switch (ANSI(c, term->esc_query)) {
|
switch (ANSI(c, term->esc_query)) {
|
||||||
case ANSI('3', '#'): /* DECDHL: 2*height, top */
|
case ANSI('3', '#'): /* DECDHL: 2*height, top */
|
||||||
nlattr = LATTR_TOP;
|
nlattr = LATTR_TOP;
|
||||||
break;
|
break;
|
||||||
case ANSI('4', '#'): /* DECDHL: 2*height, bottom */
|
case ANSI('4', '#'): /* DECDHL: 2*height, bottom */
|
||||||
nlattr = LATTR_BOT;
|
nlattr = LATTR_BOT;
|
||||||
break;
|
break;
|
||||||
case ANSI('5', '#'): /* DECSWL: normal */
|
case ANSI('5', '#'): /* DECSWL: normal */
|
||||||
nlattr = LATTR_NORM;
|
nlattr = LATTR_NORM;
|
||||||
break;
|
break;
|
||||||
default: /* case ANSI('6', '#'): DECDWL: 2*width */
|
default: /* case ANSI('6', '#'): DECDWL: 2*width */
|
||||||
nlattr = LATTR_WIDE;
|
nlattr = LATTR_WIDE;
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
ldata = scrlineptr(term->curs.y);
|
|
||||||
check_line_size(term, ldata);
|
|
||||||
check_trust_status(term, ldata);
|
|
||||||
ldata->lattr = nlattr;
|
|
||||||
}
|
}
|
||||||
|
ldata = scrlineptr(term->curs.y);
|
||||||
|
check_line_size(term, ldata);
|
||||||
|
check_trust_status(term, ldata);
|
||||||
|
ldata->lattr = nlattr;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
/* GZD4: G0 designate 94-set */
|
/* GZD4: G0 designate 94-set */
|
||||||
case ANSI('A', '('):
|
case ANSI('A', '('):
|
||||||
compatibility(VT100);
|
compatibility(VT100);
|
||||||
@ -3913,34 +3909,32 @@ static void term_out(Terminal *term)
|
|||||||
(term->dec_om ? 2 : 0));
|
(term->dec_om ? 2 : 0));
|
||||||
seen_disp_event(term);
|
seen_disp_event(term);
|
||||||
break;
|
break;
|
||||||
case 'J': /* ED: erase screen or parts of it */
|
case 'J': { /* ED: erase screen or parts of it */
|
||||||
{
|
unsigned int i = def(term->esc_args[0], 0);
|
||||||
unsigned int i = def(term->esc_args[0], 0);
|
if (i == 3) {
|
||||||
if (i == 3) {
|
/* Erase Saved Lines (xterm)
|
||||||
/* Erase Saved Lines (xterm)
|
* This follows Thomas Dickey's xterm. */
|
||||||
* This follows Thomas Dickey's xterm. */
|
if (!term->no_remote_clearscroll)
|
||||||
if (!term->no_remote_clearscroll)
|
term_clrsb(term);
|
||||||
term_clrsb(term);
|
} else {
|
||||||
} else {
|
i++;
|
||||||
i++;
|
if (i > 3)
|
||||||
if (i > 3)
|
i = 0;
|
||||||
i = 0;
|
erase_lots(term, false, !!(i & 2), !!(i & 1));
|
||||||
erase_lots(term, false, !!(i & 2), !!(i & 1));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (term->scroll_on_disp)
|
if (term->scroll_on_disp)
|
||||||
term->disptop = 0;
|
term->disptop = 0;
|
||||||
seen_disp_event(term);
|
seen_disp_event(term);
|
||||||
break;
|
break;
|
||||||
case 'K': /* EL: erase line or parts of it */
|
}
|
||||||
{
|
case 'K': { /* EL: erase line or parts of it */
|
||||||
unsigned int i = def(term->esc_args[0], 0) + 1;
|
unsigned int i = def(term->esc_args[0], 0) + 1;
|
||||||
if (i > 3)
|
if (i > 3)
|
||||||
i = 0;
|
i = 0;
|
||||||
erase_lots(term, true, !!(i & 2), !!(i & 1));
|
erase_lots(term, true, !!(i & 2), !!(i & 1));
|
||||||
}
|
|
||||||
seen_disp_event(term);
|
seen_disp_event(term);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 'L': /* IL: insert lines */
|
case 'L': /* IL: insert lines */
|
||||||
compatibility(VT102);
|
compatibility(VT102);
|
||||||
CLAMP(term->esc_args[0], term->rows);
|
CLAMP(term->esc_args[0], term->rows);
|
||||||
@ -3994,41 +3988,34 @@ static void term_out(Terminal *term)
|
|||||||
case 'h': /* SM: toggle modes to high */
|
case 'h': /* SM: toggle modes to high */
|
||||||
case ANSI_QUE('h'):
|
case ANSI_QUE('h'):
|
||||||
compatibility(VT100);
|
compatibility(VT100);
|
||||||
{
|
for (int i = 0; i < term->esc_nargs; i++)
|
||||||
int i;
|
toggle_mode(term, term->esc_args[i],
|
||||||
for (i = 0; i < term->esc_nargs; i++)
|
term->esc_query, true);
|
||||||
toggle_mode(term, term->esc_args[i],
|
|
||||||
term->esc_query, true);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 'i': /* MC: Media copy */
|
case 'i': /* MC: Media copy */
|
||||||
case ANSI_QUE('i'):
|
case ANSI_QUE('i'): {
|
||||||
compatibility(VT100);
|
compatibility(VT100);
|
||||||
{
|
char *printer;
|
||||||
char *printer;
|
if (term->esc_nargs != 1) break;
|
||||||
if (term->esc_nargs != 1) break;
|
if (term->esc_args[0] == 5 &&
|
||||||
if (term->esc_args[0] == 5 &&
|
(printer = conf_get_str(term->conf,
|
||||||
(printer = conf_get_str(term->conf,
|
CONF_printer))[0]) {
|
||||||
CONF_printer))[0]) {
|
term->printing = true;
|
||||||
term->printing = true;
|
term->only_printing = !term->esc_query;
|
||||||
term->only_printing = !term->esc_query;
|
term->print_state = 0;
|
||||||
term->print_state = 0;
|
term_print_setup(term, printer);
|
||||||
term_print_setup(term, printer);
|
} else if (term->esc_args[0] == 4 &&
|
||||||
} else if (term->esc_args[0] == 4 &&
|
term->printing) {
|
||||||
term->printing) {
|
term_print_finish(term);
|
||||||
term_print_finish(term);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 'l': /* RM: toggle modes to low */
|
case 'l': /* RM: toggle modes to low */
|
||||||
case ANSI_QUE('l'):
|
case ANSI_QUE('l'):
|
||||||
compatibility(VT100);
|
compatibility(VT100);
|
||||||
{
|
for (int i = 0; i < term->esc_nargs; i++)
|
||||||
int i;
|
toggle_mode(term, term->esc_args[i],
|
||||||
for (i = 0; i < term->esc_nargs; i++)
|
term->esc_query, false);
|
||||||
toggle_mode(term, term->esc_args[i],
|
|
||||||
term->esc_query, false);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 'g': /* TBC: clear tabs */
|
case 'g': /* TBC: clear tabs */
|
||||||
compatibility(VT100);
|
compatibility(VT100);
|
||||||
@ -4078,222 +4065,217 @@ static void term_out(Terminal *term)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'm': /* SGR: set graphics rendition */
|
case 'm': /* SGR: set graphics rendition */
|
||||||
{
|
/*
|
||||||
/*
|
* A VT100 without the AVO only had one
|
||||||
* A VT100 without the AVO only had one
|
* attribute, either underline or reverse
|
||||||
* attribute, either underline or
|
* video depending on the cursor type, this
|
||||||
* reverse video depending on the
|
* was selected by CSI 7m.
|
||||||
* cursor type, this was selected by
|
*
|
||||||
* CSI 7m.
|
* case 2:
|
||||||
*
|
* This is sometimes DIM, eg on the GIGI and
|
||||||
* case 2:
|
* Linux
|
||||||
* This is sometimes DIM, eg on the
|
* case 8:
|
||||||
* GIGI and Linux
|
* This is sometimes INVIS various ANSI.
|
||||||
* case 8:
|
* case 21:
|
||||||
* This is sometimes INVIS various ANSI.
|
* This like 22 disables BOLD, DIM and INVIS
|
||||||
* case 21:
|
*
|
||||||
* This like 22 disables BOLD, DIM and INVIS
|
* The ANSI colours appear on any terminal
|
||||||
*
|
* that has colour (obviously) but the
|
||||||
* The ANSI colours appear on any
|
* interaction between sgr0 and the colours
|
||||||
* terminal that has colour (obviously)
|
* varies but is usually related to the
|
||||||
* but the interaction between sgr0 and
|
* background colour erase item. The
|
||||||
* the colours varies but is usually
|
* interaction between colour attributes and
|
||||||
* related to the background colour
|
* the mono ones is also very implementation
|
||||||
* erase item. The interaction between
|
* dependent.
|
||||||
* colour attributes and the mono ones
|
*
|
||||||
* is also very implementation
|
* The 39 and 49 attributes are likely to be
|
||||||
* dependent.
|
* unimplemented.
|
||||||
*
|
*/
|
||||||
* The 39 and 49 attributes are likely
|
for (int i = 0; i < term->esc_nargs; i++) {
|
||||||
* to be unimplemented.
|
switch (def(term->esc_args[i], 0)) {
|
||||||
*/
|
case 0: /* restore defaults */
|
||||||
int i;
|
term->curr_attr = term->default_attr;
|
||||||
for (i = 0; i < term->esc_nargs; i++) {
|
term->curr_truecolour =
|
||||||
switch (def(term->esc_args[i], 0)) {
|
term->basic_erase_char.truecolour;
|
||||||
case 0: /* restore defaults */
|
break;
|
||||||
term->curr_attr = term->default_attr;
|
case 1: /* enable bold */
|
||||||
term->curr_truecolour =
|
compatibility(VT100AVO);
|
||||||
term->basic_erase_char.truecolour;
|
term->curr_attr |= ATTR_BOLD;
|
||||||
break;
|
break;
|
||||||
case 1: /* enable bold */
|
case 2: /* enable dim */
|
||||||
compatibility(VT100AVO);
|
compatibility(OTHER);
|
||||||
term->curr_attr |= ATTR_BOLD;
|
term->curr_attr |= ATTR_DIM;
|
||||||
break;
|
break;
|
||||||
case 2: /* enable dim */
|
case 21: /* (enable double underline) */
|
||||||
compatibility(OTHER);
|
compatibility(OTHER);
|
||||||
term->curr_attr |= ATTR_DIM;
|
case 4: /* enable underline */
|
||||||
break;
|
compatibility(VT100AVO);
|
||||||
case 21: /* (enable double underline) */
|
term->curr_attr |= ATTR_UNDER;
|
||||||
compatibility(OTHER);
|
break;
|
||||||
case 4: /* enable underline */
|
case 5: /* enable blink */
|
||||||
compatibility(VT100AVO);
|
compatibility(VT100AVO);
|
||||||
term->curr_attr |= ATTR_UNDER;
|
term->curr_attr |= ATTR_BLINK;
|
||||||
break;
|
break;
|
||||||
case 5: /* enable blink */
|
case 6: /* SCO light bkgrd */
|
||||||
compatibility(VT100AVO);
|
compatibility(SCOANSI);
|
||||||
term->curr_attr |= ATTR_BLINK;
|
term->blink_is_real = false;
|
||||||
break;
|
term->curr_attr |= ATTR_BLINK;
|
||||||
case 6: /* SCO light bkgrd */
|
term_schedule_tblink(term);
|
||||||
compatibility(SCOANSI);
|
break;
|
||||||
term->blink_is_real = false;
|
case 7: /* enable reverse video */
|
||||||
term->curr_attr |= ATTR_BLINK;
|
term->curr_attr |= ATTR_REVERSE;
|
||||||
term_schedule_tblink(term);
|
break;
|
||||||
break;
|
case 10: /* SCO acs off */
|
||||||
case 7: /* enable reverse video */
|
compatibility(SCOANSI);
|
||||||
term->curr_attr |= ATTR_REVERSE;
|
if (term->no_remote_charset) break;
|
||||||
break;
|
term->sco_acs = 0; break;
|
||||||
case 10: /* SCO acs off */
|
case 11: /* SCO acs on */
|
||||||
compatibility(SCOANSI);
|
compatibility(SCOANSI);
|
||||||
if (term->no_remote_charset) break;
|
if (term->no_remote_charset) break;
|
||||||
term->sco_acs = 0; break;
|
term->sco_acs = 1; break;
|
||||||
case 11: /* SCO acs on */
|
case 12: /* SCO acs on, |0x80 */
|
||||||
compatibility(SCOANSI);
|
compatibility(SCOANSI);
|
||||||
if (term->no_remote_charset) break;
|
if (term->no_remote_charset) break;
|
||||||
term->sco_acs = 1; break;
|
term->sco_acs = 2; break;
|
||||||
case 12: /* SCO acs on, |0x80 */
|
case 22: /* disable bold and dim */
|
||||||
compatibility(SCOANSI);
|
compatibility2(OTHER, VT220);
|
||||||
if (term->no_remote_charset) break;
|
term->curr_attr &= ~(ATTR_BOLD | ATTR_DIM);
|
||||||
term->sco_acs = 2; break;
|
break;
|
||||||
case 22: /* disable bold and dim */
|
case 24: /* disable underline */
|
||||||
compatibility2(OTHER, VT220);
|
compatibility2(OTHER, VT220);
|
||||||
term->curr_attr &= ~(ATTR_BOLD | ATTR_DIM);
|
term->curr_attr &= ~ATTR_UNDER;
|
||||||
break;
|
break;
|
||||||
case 24: /* disable underline */
|
case 25: /* disable blink */
|
||||||
compatibility2(OTHER, VT220);
|
compatibility2(OTHER, VT220);
|
||||||
term->curr_attr &= ~ATTR_UNDER;
|
term->curr_attr &= ~ATTR_BLINK;
|
||||||
break;
|
break;
|
||||||
case 25: /* disable blink */
|
case 27: /* disable reverse video */
|
||||||
compatibility2(OTHER, VT220);
|
compatibility2(OTHER, VT220);
|
||||||
term->curr_attr &= ~ATTR_BLINK;
|
term->curr_attr &= ~ATTR_REVERSE;
|
||||||
break;
|
break;
|
||||||
case 27: /* disable reverse video */
|
case 30:
|
||||||
compatibility2(OTHER, VT220);
|
case 31:
|
||||||
term->curr_attr &= ~ATTR_REVERSE;
|
case 32:
|
||||||
break;
|
case 33:
|
||||||
case 30:
|
case 34:
|
||||||
case 31:
|
case 35:
|
||||||
case 32:
|
case 36:
|
||||||
case 33:
|
case 37:
|
||||||
case 34:
|
/* foreground */
|
||||||
case 35:
|
term->curr_truecolour.fg.enabled = false;
|
||||||
case 36:
|
term->curr_attr &= ~ATTR_FGMASK;
|
||||||
case 37:
|
term->curr_attr |=
|
||||||
/* foreground */
|
(term->esc_args[i] - 30)<<ATTR_FGSHIFT;
|
||||||
term->curr_truecolour.fg.enabled = false;
|
break;
|
||||||
term->curr_attr &= ~ATTR_FGMASK;
|
case 90:
|
||||||
term->curr_attr |=
|
case 91:
|
||||||
(term->esc_args[i] - 30)<<ATTR_FGSHIFT;
|
case 92:
|
||||||
break;
|
case 93:
|
||||||
case 90:
|
case 94:
|
||||||
case 91:
|
case 95:
|
||||||
case 92:
|
case 96:
|
||||||
case 93:
|
case 97:
|
||||||
case 94:
|
/* aixterm-style bright foreground */
|
||||||
case 95:
|
term->curr_truecolour.fg.enabled = false;
|
||||||
case 96:
|
term->curr_attr &= ~ATTR_FGMASK;
|
||||||
case 97:
|
term->curr_attr |=
|
||||||
/* aixterm-style bright foreground */
|
((term->esc_args[i] - 90 + 8)
|
||||||
term->curr_truecolour.fg.enabled = false;
|
<< ATTR_FGSHIFT);
|
||||||
term->curr_attr &= ~ATTR_FGMASK;
|
break;
|
||||||
term->curr_attr |=
|
case 39: /* default-foreground */
|
||||||
((term->esc_args[i] - 90 + 8)
|
term->curr_truecolour.fg.enabled = false;
|
||||||
<< ATTR_FGSHIFT);
|
term->curr_attr &= ~ATTR_FGMASK;
|
||||||
break;
|
term->curr_attr |= ATTR_DEFFG;
|
||||||
case 39: /* default-foreground */
|
break;
|
||||||
term->curr_truecolour.fg.enabled = false;
|
case 40:
|
||||||
term->curr_attr &= ~ATTR_FGMASK;
|
case 41:
|
||||||
term->curr_attr |= ATTR_DEFFG;
|
case 42:
|
||||||
break;
|
case 43:
|
||||||
case 40:
|
case 44:
|
||||||
case 41:
|
case 45:
|
||||||
case 42:
|
case 46:
|
||||||
case 43:
|
case 47:
|
||||||
case 44:
|
/* background */
|
||||||
case 45:
|
term->curr_truecolour.bg.enabled = false;
|
||||||
case 46:
|
term->curr_attr &= ~ATTR_BGMASK;
|
||||||
case 47:
|
term->curr_attr |=
|
||||||
/* background */
|
(term->esc_args[i] - 40)<<ATTR_BGSHIFT;
|
||||||
term->curr_truecolour.bg.enabled = false;
|
break;
|
||||||
term->curr_attr &= ~ATTR_BGMASK;
|
case 100:
|
||||||
term->curr_attr |=
|
case 101:
|
||||||
(term->esc_args[i] - 40)<<ATTR_BGSHIFT;
|
case 102:
|
||||||
break;
|
case 103:
|
||||||
case 100:
|
case 104:
|
||||||
case 101:
|
case 105:
|
||||||
case 102:
|
case 106:
|
||||||
case 103:
|
case 107:
|
||||||
case 104:
|
/* aixterm-style bright background */
|
||||||
case 105:
|
term->curr_truecolour.bg.enabled = false;
|
||||||
case 106:
|
term->curr_attr &= ~ATTR_BGMASK;
|
||||||
case 107:
|
term->curr_attr |=
|
||||||
/* aixterm-style bright background */
|
((term->esc_args[i] - 100 + 8)
|
||||||
term->curr_truecolour.bg.enabled = false;
|
<< ATTR_BGSHIFT);
|
||||||
term->curr_attr &= ~ATTR_BGMASK;
|
break;
|
||||||
term->curr_attr |=
|
case 49: /* default-background */
|
||||||
((term->esc_args[i] - 100 + 8)
|
term->curr_truecolour.bg.enabled = false;
|
||||||
<< ATTR_BGSHIFT);
|
term->curr_attr &= ~ATTR_BGMASK;
|
||||||
break;
|
term->curr_attr |= ATTR_DEFBG;
|
||||||
case 49: /* default-background */
|
break;
|
||||||
term->curr_truecolour.bg.enabled = false;
|
|
||||||
term->curr_attr &= ~ATTR_BGMASK;
|
|
||||||
term->curr_attr |= ATTR_DEFBG;
|
|
||||||
break;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 256-colour and true-colour
|
* 256-colour and true-colour
|
||||||
* sequences. A 256-colour
|
* sequences. A 256-colour
|
||||||
* foreground is selected by a
|
* foreground is selected by a
|
||||||
* sequence of 3 arguments in the
|
* sequence of 3 arguments in the
|
||||||
* form 38;5;n, where n is in the
|
* form 38;5;n, where n is in the
|
||||||
* range 0-255. A true-colour RGB
|
* range 0-255. A true-colour RGB
|
||||||
* triple is selected by 5 args of
|
* triple is selected by 5 args of
|
||||||
* the form 38;2;r;g;b. Replacing
|
* the form 38;2;r;g;b. Replacing
|
||||||
* the initial 38 with 48 in both
|
* the initial 38 with 48 in both
|
||||||
* cases selects the same colour
|
* cases selects the same colour
|
||||||
* as the background.
|
* as the background.
|
||||||
*/
|
*/
|
||||||
case 38:
|
case 38:
|
||||||
if (i+2 < term->esc_nargs &&
|
if (i+2 < term->esc_nargs &&
|
||||||
term->esc_args[i+1] == 5) {
|
term->esc_args[i+1] == 5) {
|
||||||
term->curr_attr &= ~ATTR_FGMASK;
|
term->curr_attr &= ~ATTR_FGMASK;
|
||||||
term->curr_attr |=
|
term->curr_attr |=
|
||||||
((term->esc_args[i+2] & 0xFF)
|
((term->esc_args[i+2] & 0xFF)
|
||||||
<< ATTR_FGSHIFT);
|
<< ATTR_FGSHIFT);
|
||||||
term->curr_truecolour.fg =
|
term->curr_truecolour.fg =
|
||||||
optionalrgb_none;
|
optionalrgb_none;
|
||||||
i += 2;
|
i += 2;
|
||||||
}
|
}
|
||||||
if (i + 4 < term->esc_nargs &&
|
if (i + 4 < term->esc_nargs &&
|
||||||
term->esc_args[i + 1] == 2) {
|
term->esc_args[i + 1] == 2) {
|
||||||
parse_optionalrgb(
|
parse_optionalrgb(
|
||||||
&term->curr_truecolour.fg,
|
&term->curr_truecolour.fg,
|
||||||
term->esc_args + (i+2));
|
term->esc_args + (i+2));
|
||||||
i += 4;
|
i += 4;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 48:
|
case 48:
|
||||||
if (i+2 < term->esc_nargs &&
|
if (i+2 < term->esc_nargs &&
|
||||||
term->esc_args[i+1] == 5) {
|
term->esc_args[i+1] == 5) {
|
||||||
term->curr_attr &= ~ATTR_BGMASK;
|
term->curr_attr &= ~ATTR_BGMASK;
|
||||||
term->curr_attr |=
|
term->curr_attr |=
|
||||||
((term->esc_args[i+2] & 0xFF)
|
((term->esc_args[i+2] & 0xFF)
|
||||||
<< ATTR_BGSHIFT);
|
<< ATTR_BGSHIFT);
|
||||||
term->curr_truecolour.bg =
|
term->curr_truecolour.bg =
|
||||||
optionalrgb_none;
|
optionalrgb_none;
|
||||||
i += 2;
|
i += 2;
|
||||||
}
|
}
|
||||||
if (i + 4 < term->esc_nargs &&
|
if (i + 4 < term->esc_nargs &&
|
||||||
term->esc_args[i+1] == 2) {
|
term->esc_args[i+1] == 2) {
|
||||||
parse_optionalrgb(
|
parse_optionalrgb(
|
||||||
&term->curr_truecolour.bg,
|
&term->curr_truecolour.bg,
|
||||||
term->esc_args + (i+2));
|
term->esc_args + (i+2));
|
||||||
i += 4;
|
i += 4;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
set_erase_char(term);
|
|
||||||
}
|
}
|
||||||
|
set_erase_char(term);
|
||||||
break;
|
break;
|
||||||
case 's': /* save cursor */
|
case 's': /* save cursor */
|
||||||
save_cursor(term, true);
|
save_cursor(term, true);
|
||||||
@ -4504,31 +4486,30 @@ static void term_out(Terminal *term)
|
|||||||
deselect(term);
|
deselect(term);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'X': /* ECH: write N spaces w/o moving cursor */
|
case 'X': { /* ECH: write N spaces w/o moving cursor */
|
||||||
/* XXX VTTEST says this is vt220, vt510 manual
|
/* XXX VTTEST says this is vt220, vt510 manual
|
||||||
* says vt100 */
|
* says vt100 */
|
||||||
compatibility(ANSIMIN);
|
compatibility(ANSIMIN);
|
||||||
CLAMP(term->esc_args[0], term->cols);
|
CLAMP(term->esc_args[0], term->cols);
|
||||||
{
|
int n = def(term->esc_args[0], 1);
|
||||||
int n = def(term->esc_args[0], 1);
|
pos cursplus;
|
||||||
pos cursplus;
|
int p = term->curs.x;
|
||||||
int p = term->curs.x;
|
termline *cline = scrlineptr(term->curs.y);
|
||||||
termline *cline = scrlineptr(term->curs.y);
|
|
||||||
|
|
||||||
check_trust_status(term, cline);
|
check_trust_status(term, cline);
|
||||||
if (n > term->cols - term->curs.x)
|
if (n > term->cols - term->curs.x)
|
||||||
n = term->cols - term->curs.x;
|
n = term->cols - term->curs.x;
|
||||||
cursplus = term->curs;
|
cursplus = term->curs;
|
||||||
cursplus.x += n;
|
cursplus.x += n;
|
||||||
check_boundary(term, term->curs.x, term->curs.y);
|
check_boundary(term, term->curs.x, term->curs.y);
|
||||||
check_boundary(term, term->curs.x+n, term->curs.y);
|
check_boundary(term, term->curs.x+n, term->curs.y);
|
||||||
check_selection(term, term->curs, cursplus);
|
check_selection(term, term->curs, cursplus);
|
||||||
while (n--)
|
while (n--)
|
||||||
copy_termchar(cline, p++,
|
copy_termchar(cline, p++,
|
||||||
&term->erase_char);
|
&term->erase_char);
|
||||||
seen_disp_event(term);
|
seen_disp_event(term);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 'x': /* DECREQTPARM: report terminal characteristics */
|
case 'x': /* DECREQTPARM: report terminal characteristics */
|
||||||
compatibility(VT100);
|
compatibility(VT100);
|
||||||
if (term->ldisc) {
|
if (term->ldisc) {
|
||||||
@ -4541,22 +4522,21 @@ static void term_out(Terminal *term)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'Z': /* CBT */
|
case 'Z': { /* CBT */
|
||||||
compatibility(OTHER);
|
compatibility(OTHER);
|
||||||
CLAMP(term->esc_args[0], term->cols);
|
CLAMP(term->esc_args[0], term->cols);
|
||||||
{
|
int i = def(term->esc_args[0], 1);
|
||||||
int i = def(term->esc_args[0], 1);
|
pos old_curs = term->curs;
|
||||||
pos old_curs = term->curs;
|
|
||||||
|
|
||||||
for(;i>0 && term->curs.x>0; i--) {
|
for(;i>0 && term->curs.x>0; i--) {
|
||||||
do {
|
do {
|
||||||
term->curs.x--;
|
term->curs.x--;
|
||||||
} while (term->curs.x >0 &&
|
} while (term->curs.x >0 &&
|
||||||
!term->tabs[term->curs.x]);
|
!term->tabs[term->curs.x]);
|
||||||
}
|
|
||||||
check_selection(term, old_curs, term->curs);
|
|
||||||
}
|
}
|
||||||
|
check_selection(term, old_curs, term->curs);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case ANSI('c', '='): /* Hide or Show Cursor */
|
case ANSI('c', '='): /* Hide or Show Cursor */
|
||||||
compatibility(SCOANSI);
|
compatibility(SCOANSI);
|
||||||
switch(term->esc_args[0]) {
|
switch(term->esc_args[0]) {
|
||||||
@ -4808,32 +4788,31 @@ static void term_out(Terminal *term)
|
|||||||
else if (term->osc_strlen < OSC_STR_MAX)
|
else if (term->osc_strlen < OSC_STR_MAX)
|
||||||
term->osc_string[term->osc_strlen++] = (char)c;
|
term->osc_string[term->osc_strlen++] = (char)c;
|
||||||
break;
|
break;
|
||||||
case SEEN_OSC_P:
|
case SEEN_OSC_P: {
|
||||||
{
|
int max = (term->osc_strlen == 0 ? 21 : 15);
|
||||||
int max = (term->osc_strlen == 0 ? 21 : 15);
|
int val;
|
||||||
int val;
|
if ((int)c >= '0' && (int)c <= '9')
|
||||||
if ((int)c >= '0' && (int)c <= '9')
|
val = c - '0';
|
||||||
val = c - '0';
|
else if ((int)c >= 'A' && (int)c <= 'A' + max - 10)
|
||||||
else if ((int)c >= 'A' && (int)c <= 'A' + max - 10)
|
val = c - 'A' + 10;
|
||||||
val = c - 'A' + 10;
|
else if ((int)c >= 'a' && (int)c <= 'a' + max - 10)
|
||||||
else if ((int)c >= 'a' && (int)c <= 'a' + max - 10)
|
val = c - 'a' + 10;
|
||||||
val = c - 'a' + 10;
|
else {
|
||||||
else {
|
term->termstate = TOPLEVEL;
|
||||||
term->termstate = TOPLEVEL;
|
break;
|
||||||
break;
|
}
|
||||||
}
|
term->osc_string[term->osc_strlen++] = val;
|
||||||
term->osc_string[term->osc_strlen++] = val;
|
if (term->osc_strlen >= 7) {
|
||||||
if (term->osc_strlen >= 7) {
|
win_palette_set(
|
||||||
win_palette_set(
|
term->win, term->osc_string[0],
|
||||||
term->win, term->osc_string[0],
|
term->osc_string[1] * 16 + term->osc_string[2],
|
||||||
term->osc_string[1] * 16 + term->osc_string[2],
|
term->osc_string[3] * 16 + term->osc_string[4],
|
||||||
term->osc_string[3] * 16 + term->osc_string[4],
|
term->osc_string[5] * 16 + term->osc_string[6]);
|
||||||
term->osc_string[5] * 16 + term->osc_string[6]);
|
term_invalidate(term);
|
||||||
term_invalidate(term);
|
term->termstate = TOPLEVEL;
|
||||||
term->termstate = TOPLEVEL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case SEEN_OSC_W:
|
case SEEN_OSC_W:
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '0':
|
case '0':
|
||||||
|
@ -422,30 +422,29 @@ static dr_emit_flags_t instrument_instr(
|
|||||||
case OP_rol:
|
case OP_rol:
|
||||||
case OP_ror:
|
case OP_ror:
|
||||||
case OP_rcl:
|
case OP_rcl:
|
||||||
case OP_rcr:
|
case OP_rcr: {
|
||||||
/*
|
/*
|
||||||
* Shift instructions. If they're register-controlled, log the
|
* Shift instructions. If they're register-controlled, log the
|
||||||
* shift count.
|
* shift count.
|
||||||
*/
|
*/
|
||||||
{
|
opnd_t shiftcount = instr_get_src(instr, 0);
|
||||||
opnd_t shiftcount = instr_get_src(instr, 0);
|
if (!opnd_is_immed(shiftcount)) {
|
||||||
if (!opnd_is_immed(shiftcount)) {
|
reg_id_t r0;
|
||||||
reg_id_t r0;
|
drreg_status_t st;
|
||||||
drreg_status_t st;
|
st = drreg_reserve_register(drcontext, bb, instr, NULL, &r0);
|
||||||
st = drreg_reserve_register(drcontext, bb, instr, NULL, &r0);
|
DR_ASSERT(st == DRREG_SUCCESS);
|
||||||
DR_ASSERT(st == DRREG_SUCCESS);
|
opnd_t op_r0 = opnd_create_reg(r0);
|
||||||
opnd_t op_r0 = opnd_create_reg(r0);
|
instrlist_preinsert(bb, instr, INSTR_CREATE_movzx(
|
||||||
instrlist_preinsert(bb, instr, INSTR_CREATE_movzx(
|
drcontext, op_r0, shiftcount));
|
||||||
drcontext, op_r0, shiftcount));
|
instr_format_location(instr, &loc);
|
||||||
instr_format_location(instr, &loc);
|
dr_insert_clean_call(
|
||||||
dr_insert_clean_call(
|
drcontext, bb, instr, (void *)log_var_shift, false,
|
||||||
drcontext, bb, instr, (void *)log_var_shift, false,
|
2, op_r0, OPND_CREATE_INTPTR(loc));
|
||||||
2, op_r0, OPND_CREATE_INTPTR(loc));
|
st = drreg_unreserve_register(drcontext, bb, instr, r0);
|
||||||
st = drreg_unreserve_register(drcontext, bb, instr, r0);
|
DR_ASSERT(st == DRREG_SUCCESS);
|
||||||
DR_ASSERT(st == DRREG_SUCCESS);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return DR_EMIT_DEFAULT;
|
return DR_EMIT_DEFAULT;
|
||||||
|
420
unix/gtkdlg.c
420
unix/gtkdlg.c
@ -974,14 +974,11 @@ void dlg_set_focus(union control *ctrl, dlgparam *dp)
|
|||||||
* Radio buttons: we find the currently selected button and
|
* Radio buttons: we find the currently selected button and
|
||||||
* focus it.
|
* focus it.
|
||||||
*/
|
*/
|
||||||
{
|
for (int i = 0; i < ctrl->radio.nbuttons; i++)
|
||||||
int i;
|
if (gtk_toggle_button_get_active
|
||||||
for (i = 0; i < ctrl->radio.nbuttons; i++)
|
(GTK_TOGGLE_BUTTON(uc->buttons[i]))) {
|
||||||
if (gtk_toggle_button_get_active
|
gtk_widget_grab_focus(uc->buttons[i]);
|
||||||
(GTK_TOGGLE_BUTTON(uc->buttons[i]))) {
|
}
|
||||||
gtk_widget_grab_focus(uc->buttons[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case CTRL_LISTBOX:
|
case CTRL_LISTBOX:
|
||||||
#if !GTK_CHECK_VERSION(2,4,0)
|
#if !GTK_CHECK_VERSION(2,4,0)
|
||||||
@ -1885,21 +1882,19 @@ GtkWidget *layout_ctrls(
|
|||||||
GtkWidget *w = NULL;
|
GtkWidget *w = NULL;
|
||||||
|
|
||||||
switch (ctrl->generic.type) {
|
switch (ctrl->generic.type) {
|
||||||
case CTRL_COLUMNS:
|
case CTRL_COLUMNS: {
|
||||||
{
|
static const int simplecols[1] = { 100 };
|
||||||
static const int simplecols[1] = { 100 };
|
columns_set_cols(cols, ctrl->columns.ncols,
|
||||||
columns_set_cols(cols, ctrl->columns.ncols,
|
(ctrl->columns.percentages ?
|
||||||
(ctrl->columns.percentages ?
|
ctrl->columns.percentages : simplecols));
|
||||||
ctrl->columns.percentages : simplecols));
|
|
||||||
}
|
|
||||||
continue; /* no actual control created */
|
continue; /* no actual control created */
|
||||||
case CTRL_TABDELAY:
|
}
|
||||||
{
|
case CTRL_TABDELAY: {
|
||||||
struct uctrl *uc = dlg_find_byctrl(dp, ctrl->tabdelay.ctrl);
|
struct uctrl *uc = dlg_find_byctrl(dp, ctrl->tabdelay.ctrl);
|
||||||
if (uc)
|
if (uc)
|
||||||
columns_taborder_last(cols, uc->toplevel);
|
columns_taborder_last(cols, uc->toplevel);
|
||||||
}
|
|
||||||
continue; /* no actual control created */
|
continue; /* no actual control created */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uc = snew(struct uctrl);
|
uc = snew(struct uctrl);
|
||||||
@ -1947,223 +1942,220 @@ GtkWidget *layout_ctrls(
|
|||||||
ctrl->checkbox.shortcut, SHORTCUT_UCTRL, uc);
|
ctrl->checkbox.shortcut, SHORTCUT_UCTRL, uc);
|
||||||
left = true;
|
left = true;
|
||||||
break;
|
break;
|
||||||
case CTRL_RADIO:
|
case CTRL_RADIO: {
|
||||||
/*
|
/*
|
||||||
* Radio buttons get to go inside their own Columns, no
|
* Radio buttons get to go inside their own Columns, no
|
||||||
* matter what.
|
* matter what.
|
||||||
*/
|
*/
|
||||||
{
|
gint i, *percentages;
|
||||||
gint i, *percentages;
|
GSList *group;
|
||||||
GSList *group;
|
|
||||||
|
|
||||||
w = columns_new(0);
|
w = columns_new(0);
|
||||||
if (ctrl->generic.label) {
|
if (ctrl->generic.label) {
|
||||||
GtkWidget *label = gtk_label_new(ctrl->generic.label);
|
GtkWidget *label = gtk_label_new(ctrl->generic.label);
|
||||||
columns_add(COLUMNS(w), label, 0, 1);
|
columns_add(COLUMNS(w), label, 0, 1);
|
||||||
columns_force_left_align(COLUMNS(w), label);
|
columns_force_left_align(COLUMNS(w), label);
|
||||||
gtk_widget_show(label);
|
gtk_widget_show(label);
|
||||||
shortcut_add(scs, label, ctrl->radio.shortcut,
|
shortcut_add(scs, label, ctrl->radio.shortcut,
|
||||||
SHORTCUT_UCTRL, uc);
|
SHORTCUT_UCTRL, uc);
|
||||||
uc->label = label;
|
uc->label = label;
|
||||||
}
|
}
|
||||||
percentages = g_new(gint, ctrl->radio.ncolumns);
|
percentages = g_new(gint, ctrl->radio.ncolumns);
|
||||||
for (i = 0; i < ctrl->radio.ncolumns; i++) {
|
for (i = 0; i < ctrl->radio.ncolumns; i++) {
|
||||||
percentages[i] =
|
percentages[i] =
|
||||||
((100 * (i+1) / ctrl->radio.ncolumns) -
|
((100 * (i+1) / ctrl->radio.ncolumns) -
|
||||||
100 * i / ctrl->radio.ncolumns);
|
100 * i / ctrl->radio.ncolumns);
|
||||||
}
|
}
|
||||||
columns_set_cols(COLUMNS(w), ctrl->radio.ncolumns,
|
columns_set_cols(COLUMNS(w), ctrl->radio.ncolumns,
|
||||||
percentages);
|
percentages);
|
||||||
g_free(percentages);
|
g_free(percentages);
|
||||||
group = NULL;
|
group = NULL;
|
||||||
|
|
||||||
uc->nbuttons = ctrl->radio.nbuttons;
|
uc->nbuttons = ctrl->radio.nbuttons;
|
||||||
uc->buttons = snewn(uc->nbuttons, GtkWidget *);
|
uc->buttons = snewn(uc->nbuttons, GtkWidget *);
|
||||||
|
|
||||||
for (i = 0; i < ctrl->radio.nbuttons; i++) {
|
for (i = 0; i < ctrl->radio.nbuttons; i++) {
|
||||||
GtkWidget *b;
|
GtkWidget *b;
|
||||||
gint colstart;
|
gint colstart;
|
||||||
|
|
||||||
b = (gtk_radio_button_new_with_label
|
b = (gtk_radio_button_new_with_label
|
||||||
(group, ctrl->radio.buttons[i]));
|
(group, ctrl->radio.buttons[i]));
|
||||||
uc->buttons[i] = b;
|
uc->buttons[i] = b;
|
||||||
group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(b));
|
group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(b));
|
||||||
colstart = i % ctrl->radio.ncolumns;
|
colstart = i % ctrl->radio.ncolumns;
|
||||||
columns_add(COLUMNS(w), b, colstart,
|
columns_add(COLUMNS(w), b, colstart,
|
||||||
(i == ctrl->radio.nbuttons-1 ?
|
(i == ctrl->radio.nbuttons-1 ?
|
||||||
ctrl->radio.ncolumns - colstart : 1));
|
ctrl->radio.ncolumns - colstart : 1));
|
||||||
columns_force_left_align(COLUMNS(w), b);
|
columns_force_left_align(COLUMNS(w), b);
|
||||||
gtk_widget_show(b);
|
gtk_widget_show(b);
|
||||||
g_signal_connect(G_OBJECT(b), "toggled",
|
g_signal_connect(G_OBJECT(b), "toggled",
|
||||||
G_CALLBACK(button_toggled), dp);
|
G_CALLBACK(button_toggled), dp);
|
||||||
g_signal_connect(G_OBJECT(b), "focus_in_event",
|
g_signal_connect(G_OBJECT(b), "focus_in_event",
|
||||||
G_CALLBACK(widget_focus), dp);
|
G_CALLBACK(widget_focus), dp);
|
||||||
if (ctrl->radio.shortcuts) {
|
if (ctrl->radio.shortcuts) {
|
||||||
shortcut_add(scs, gtk_bin_get_child(GTK_BIN(b)),
|
shortcut_add(scs, gtk_bin_get_child(GTK_BIN(b)),
|
||||||
ctrl->radio.shortcuts[i],
|
ctrl->radio.shortcuts[i],
|
||||||
SHORTCUT_UCTRL, uc);
|
SHORTCUT_UCTRL, uc);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CTRL_EDITBOX:
|
}
|
||||||
{
|
case CTRL_EDITBOX: {
|
||||||
GtkWidget *signalobject;
|
GtkWidget *signalobject;
|
||||||
|
|
||||||
if (ctrl->editbox.has_list) {
|
if (ctrl->editbox.has_list) {
|
||||||
#if !GTK_CHECK_VERSION(2,4,0)
|
#if !GTK_CHECK_VERSION(2,4,0)
|
||||||
/*
|
/*
|
||||||
* GTK 1 combo box.
|
* GTK 1 combo box.
|
||||||
*/
|
*/
|
||||||
w = gtk_combo_new();
|
w = gtk_combo_new();
|
||||||
gtk_combo_set_value_in_list(GTK_COMBO(w), false, true);
|
gtk_combo_set_value_in_list(GTK_COMBO(w), false, true);
|
||||||
uc->entry = GTK_COMBO(w)->entry;
|
uc->entry = GTK_COMBO(w)->entry;
|
||||||
uc->list = GTK_COMBO(w)->list;
|
uc->list = GTK_COMBO(w)->list;
|
||||||
signalobject = uc->entry;
|
signalobject = uc->entry;
|
||||||
#else
|
#else
|
||||||
/*
|
/*
|
||||||
* GTK 2 combo box.
|
* GTK 2 combo box.
|
||||||
*/
|
*/
|
||||||
uc->listmodel = gtk_list_store_new(2, G_TYPE_INT,
|
uc->listmodel = gtk_list_store_new(2, G_TYPE_INT,
|
||||||
G_TYPE_STRING);
|
G_TYPE_STRING);
|
||||||
w = gtk_combo_box_new_with_model_and_entry
|
w = gtk_combo_box_new_with_model_and_entry
|
||||||
(GTK_TREE_MODEL(uc->listmodel));
|
(GTK_TREE_MODEL(uc->listmodel));
|
||||||
g_object_set(G_OBJECT(w), "entry-text-column", 1,
|
g_object_set(G_OBJECT(w), "entry-text-column", 1,
|
||||||
(const char *)NULL);
|
(const char *)NULL);
|
||||||
/* We cannot support password combo boxes. */
|
/* We cannot support password combo boxes. */
|
||||||
assert(!ctrl->editbox.password);
|
assert(!ctrl->editbox.password);
|
||||||
uc->combo = w;
|
uc->combo = w;
|
||||||
signalobject = uc->combo;
|
signalobject = uc->combo;
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
w = gtk_entry_new();
|
w = gtk_entry_new();
|
||||||
if (ctrl->editbox.password)
|
if (ctrl->editbox.password)
|
||||||
gtk_entry_set_visibility(GTK_ENTRY(w), false);
|
gtk_entry_set_visibility(GTK_ENTRY(w), false);
|
||||||
uc->entry = w;
|
uc->entry = w;
|
||||||
signalobject = w;
|
signalobject = w;
|
||||||
}
|
}
|
||||||
uc->entrysig =
|
uc->entrysig =
|
||||||
g_signal_connect(G_OBJECT(signalobject), "changed",
|
g_signal_connect(G_OBJECT(signalobject), "changed",
|
||||||
G_CALLBACK(editbox_changed), dp);
|
G_CALLBACK(editbox_changed), dp);
|
||||||
g_signal_connect(G_OBJECT(signalobject), "key_press_event",
|
g_signal_connect(G_OBJECT(signalobject), "key_press_event",
|
||||||
G_CALLBACK(editbox_key), dp);
|
G_CALLBACK(editbox_key), dp);
|
||||||
g_signal_connect(G_OBJECT(signalobject), "focus_in_event",
|
g_signal_connect(G_OBJECT(signalobject), "focus_in_event",
|
||||||
G_CALLBACK(widget_focus), dp);
|
G_CALLBACK(widget_focus), dp);
|
||||||
g_signal_connect(G_OBJECT(signalobject), "focus_out_event",
|
g_signal_connect(G_OBJECT(signalobject), "focus_out_event",
|
||||||
G_CALLBACK(editbox_lostfocus), dp);
|
G_CALLBACK(editbox_lostfocus), dp);
|
||||||
g_signal_connect(G_OBJECT(signalobject), "focus_out_event",
|
g_signal_connect(G_OBJECT(signalobject), "focus_out_event",
|
||||||
G_CALLBACK(editbox_lostfocus), dp);
|
G_CALLBACK(editbox_lostfocus), dp);
|
||||||
|
|
||||||
#if !GTK_CHECK_VERSION(3,0,0)
|
#if !GTK_CHECK_VERSION(3,0,0)
|
||||||
/*
|
/*
|
||||||
* Edit boxes, for some strange reason, have a minimum
|
* Edit boxes, for some strange reason, have a minimum
|
||||||
* width of 150 in GTK 1.2. We don't want this - we'd
|
* width of 150 in GTK 1.2. We don't want this - we'd
|
||||||
* rather the edit boxes acquired their natural width
|
* rather the edit boxes acquired their natural width
|
||||||
* from the column layout of the rest of the box.
|
* from the column layout of the rest of the box.
|
||||||
*/
|
*/
|
||||||
{
|
|
||||||
GtkRequisition req;
|
|
||||||
gtk_widget_size_request(w, &req);
|
|
||||||
gtk_widget_set_size_request(w, 10, req.height);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
/*
|
|
||||||
* In GTK 3, this is still true, but there's a special
|
|
||||||
* method for GtkEntry in particular to fix it.
|
|
||||||
*/
|
|
||||||
if (GTK_IS_ENTRY(w))
|
|
||||||
gtk_entry_set_width_chars(GTK_ENTRY(w), 1);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (ctrl->generic.label) {
|
|
||||||
GtkWidget *label, *container;
|
|
||||||
|
|
||||||
label = gtk_label_new(ctrl->generic.label);
|
|
||||||
|
|
||||||
shortcut_add(scs, label, ctrl->editbox.shortcut,
|
|
||||||
SHORTCUT_FOCUS, uc->entry);
|
|
||||||
|
|
||||||
container = columns_new(4);
|
|
||||||
if (ctrl->editbox.percentwidth == 100) {
|
|
||||||
columns_add(COLUMNS(container), label, 0, 1);
|
|
||||||
columns_force_left_align(COLUMNS(container), label);
|
|
||||||
columns_add(COLUMNS(container), w, 0, 1);
|
|
||||||
} else {
|
|
||||||
gint percentages[2];
|
|
||||||
percentages[1] = ctrl->editbox.percentwidth;
|
|
||||||
percentages[0] = 100 - ctrl->editbox.percentwidth;
|
|
||||||
columns_set_cols(COLUMNS(container), 2, percentages);
|
|
||||||
columns_add(COLUMNS(container), label, 0, 1);
|
|
||||||
columns_force_left_align(COLUMNS(container), label);
|
|
||||||
columns_add(COLUMNS(container), w, 1, 1);
|
|
||||||
columns_force_same_height(COLUMNS(container),
|
|
||||||
label, w);
|
|
||||||
}
|
|
||||||
gtk_widget_show(label);
|
|
||||||
gtk_widget_show(w);
|
|
||||||
|
|
||||||
w = container;
|
|
||||||
uc->label = label;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case CTRL_FILESELECT:
|
|
||||||
case CTRL_FONTSELECT:
|
|
||||||
{
|
{
|
||||||
GtkWidget *ww;
|
GtkRequisition req;
|
||||||
const char *browsebtn =
|
gtk_widget_size_request(w, &req);
|
||||||
(ctrl->generic.type == CTRL_FILESELECT ?
|
gtk_widget_set_size_request(w, 10, req.height);
|
||||||
"Browse..." : "Change...");
|
}
|
||||||
|
|
||||||
gint percentages[] = { 75, 25 };
|
|
||||||
w = columns_new(4);
|
|
||||||
columns_set_cols(COLUMNS(w), 2, percentages);
|
|
||||||
|
|
||||||
if (ctrl->generic.label) {
|
|
||||||
ww = gtk_label_new(ctrl->generic.label);
|
|
||||||
columns_add(COLUMNS(w), ww, 0, 2);
|
|
||||||
columns_force_left_align(COLUMNS(w), ww);
|
|
||||||
gtk_widget_show(ww);
|
|
||||||
shortcut_add(scs, ww,
|
|
||||||
(ctrl->generic.type == CTRL_FILESELECT ?
|
|
||||||
ctrl->fileselect.shortcut :
|
|
||||||
ctrl->fontselect.shortcut),
|
|
||||||
SHORTCUT_UCTRL, uc);
|
|
||||||
uc->label = ww;
|
|
||||||
}
|
|
||||||
|
|
||||||
uc->entry = ww = gtk_entry_new();
|
|
||||||
#if !GTK_CHECK_VERSION(3,0,0)
|
|
||||||
{
|
|
||||||
GtkRequisition req;
|
|
||||||
gtk_widget_size_request(ww, &req);
|
|
||||||
gtk_widget_set_size_request(ww, 10, req.height);
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
gtk_entry_set_width_chars(GTK_ENTRY(ww), 1);
|
/*
|
||||||
|
* In GTK 3, this is still true, but there's a special
|
||||||
|
* method for GtkEntry in particular to fix it.
|
||||||
|
*/
|
||||||
|
if (GTK_IS_ENTRY(w))
|
||||||
|
gtk_entry_set_width_chars(GTK_ENTRY(w), 1);
|
||||||
#endif
|
#endif
|
||||||
columns_add(COLUMNS(w), ww, 0, 1);
|
|
||||||
gtk_widget_show(ww);
|
|
||||||
|
|
||||||
uc->button = ww = gtk_button_new_with_label(browsebtn);
|
if (ctrl->generic.label) {
|
||||||
columns_add(COLUMNS(w), ww, 1, 1);
|
GtkWidget *label, *container;
|
||||||
gtk_widget_show(ww);
|
|
||||||
|
|
||||||
columns_force_same_height(COLUMNS(w), uc->entry, uc->button);
|
label = gtk_label_new(ctrl->generic.label);
|
||||||
|
|
||||||
g_signal_connect(G_OBJECT(uc->entry), "key_press_event",
|
shortcut_add(scs, label, ctrl->editbox.shortcut,
|
||||||
G_CALLBACK(editbox_key), dp);
|
SHORTCUT_FOCUS, uc->entry);
|
||||||
uc->entrysig =
|
|
||||||
g_signal_connect(G_OBJECT(uc->entry), "changed",
|
container = columns_new(4);
|
||||||
G_CALLBACK(editbox_changed), dp);
|
if (ctrl->editbox.percentwidth == 100) {
|
||||||
g_signal_connect(G_OBJECT(uc->entry), "focus_in_event",
|
columns_add(COLUMNS(container), label, 0, 1);
|
||||||
G_CALLBACK(widget_focus), dp);
|
columns_force_left_align(COLUMNS(container), label);
|
||||||
g_signal_connect(G_OBJECT(uc->button), "focus_in_event",
|
columns_add(COLUMNS(container), w, 0, 1);
|
||||||
G_CALLBACK(widget_focus), dp);
|
} else {
|
||||||
g_signal_connect(G_OBJECT(ww), "clicked",
|
gint percentages[2];
|
||||||
G_CALLBACK(filefont_clicked), dp);
|
percentages[1] = ctrl->editbox.percentwidth;
|
||||||
|
percentages[0] = 100 - ctrl->editbox.percentwidth;
|
||||||
|
columns_set_cols(COLUMNS(container), 2, percentages);
|
||||||
|
columns_add(COLUMNS(container), label, 0, 1);
|
||||||
|
columns_force_left_align(COLUMNS(container), label);
|
||||||
|
columns_add(COLUMNS(container), w, 1, 1);
|
||||||
|
columns_force_same_height(COLUMNS(container),
|
||||||
|
label, w);
|
||||||
|
}
|
||||||
|
gtk_widget_show(label);
|
||||||
|
gtk_widget_show(w);
|
||||||
|
|
||||||
|
w = container;
|
||||||
|
uc->label = label;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
case CTRL_FILESELECT:
|
||||||
|
case CTRL_FONTSELECT: {
|
||||||
|
GtkWidget *ww;
|
||||||
|
const char *browsebtn =
|
||||||
|
(ctrl->generic.type == CTRL_FILESELECT ?
|
||||||
|
"Browse..." : "Change...");
|
||||||
|
|
||||||
|
gint percentages[] = { 75, 25 };
|
||||||
|
w = columns_new(4);
|
||||||
|
columns_set_cols(COLUMNS(w), 2, percentages);
|
||||||
|
|
||||||
|
if (ctrl->generic.label) {
|
||||||
|
ww = gtk_label_new(ctrl->generic.label);
|
||||||
|
columns_add(COLUMNS(w), ww, 0, 2);
|
||||||
|
columns_force_left_align(COLUMNS(w), ww);
|
||||||
|
gtk_widget_show(ww);
|
||||||
|
shortcut_add(scs, ww,
|
||||||
|
(ctrl->generic.type == CTRL_FILESELECT ?
|
||||||
|
ctrl->fileselect.shortcut :
|
||||||
|
ctrl->fontselect.shortcut),
|
||||||
|
SHORTCUT_UCTRL, uc);
|
||||||
|
uc->label = ww;
|
||||||
|
}
|
||||||
|
|
||||||
|
uc->entry = ww = gtk_entry_new();
|
||||||
|
#if !GTK_CHECK_VERSION(3,0,0)
|
||||||
|
{
|
||||||
|
GtkRequisition req;
|
||||||
|
gtk_widget_size_request(ww, &req);
|
||||||
|
gtk_widget_set_size_request(ww, 10, req.height);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
gtk_entry_set_width_chars(GTK_ENTRY(ww), 1);
|
||||||
|
#endif
|
||||||
|
columns_add(COLUMNS(w), ww, 0, 1);
|
||||||
|
gtk_widget_show(ww);
|
||||||
|
|
||||||
|
uc->button = ww = gtk_button_new_with_label(browsebtn);
|
||||||
|
columns_add(COLUMNS(w), ww, 1, 1);
|
||||||
|
gtk_widget_show(ww);
|
||||||
|
|
||||||
|
columns_force_same_height(COLUMNS(w), uc->entry, uc->button);
|
||||||
|
|
||||||
|
g_signal_connect(G_OBJECT(uc->entry), "key_press_event",
|
||||||
|
G_CALLBACK(editbox_key), dp);
|
||||||
|
uc->entrysig =
|
||||||
|
g_signal_connect(G_OBJECT(uc->entry), "changed",
|
||||||
|
G_CALLBACK(editbox_changed), dp);
|
||||||
|
g_signal_connect(G_OBJECT(uc->entry), "focus_in_event",
|
||||||
|
G_CALLBACK(widget_focus), dp);
|
||||||
|
g_signal_connect(G_OBJECT(uc->button), "focus_in_event",
|
||||||
|
G_CALLBACK(widget_focus), dp);
|
||||||
|
g_signal_connect(G_OBJECT(ww), "clicked",
|
||||||
|
G_CALLBACK(filefont_clicked), dp);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case CTRL_LISTBOX:
|
case CTRL_LISTBOX:
|
||||||
|
|
||||||
#if GTK_CHECK_VERSION(2,0,0)
|
#if GTK_CHECK_VERSION(2,0,0)
|
||||||
|
@ -5044,17 +5044,16 @@ static void gtk_seat_update_specials_menu(Seat *seat)
|
|||||||
case SS_SEP:
|
case SS_SEP:
|
||||||
menuitem = gtk_menu_item_new();
|
menuitem = gtk_menu_item_new();
|
||||||
break;
|
break;
|
||||||
default:
|
default: {
|
||||||
menuitem = gtk_menu_item_new_with_label(specials[i].name);
|
menuitem = gtk_menu_item_new_with_label(specials[i].name);
|
||||||
{
|
SessionSpecial *sc = snew(SessionSpecial);
|
||||||
SessionSpecial *sc = snew(SessionSpecial);
|
*sc = specials[i]; /* structure copy */
|
||||||
*sc = specials[i]; /* structure copy */
|
g_object_set_data_full(G_OBJECT(menuitem), "user-data",
|
||||||
g_object_set_data_full(G_OBJECT(menuitem), "user-data",
|
sc, free_special_cmd);
|
||||||
sc, free_special_cmd);
|
|
||||||
}
|
|
||||||
g_signal_connect(G_OBJECT(menuitem), "activate",
|
g_signal_connect(G_OBJECT(menuitem), "activate",
|
||||||
G_CALLBACK(special_menuitem), inst);
|
G_CALLBACK(special_menuitem), inst);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (menuitem) {
|
if (menuitem) {
|
||||||
gtk_container_add(GTK_CONTAINER(menu), menuitem);
|
gtk_container_add(GTK_CONTAINER(menu), menuitem);
|
||||||
|
@ -22,44 +22,43 @@ static LRESULT CALLBACK SizeTipWndProc(HWND hWnd, UINT nMsg,
|
|||||||
case WM_ERASEBKGND:
|
case WM_ERASEBKGND:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case WM_PAINT:
|
case WM_PAINT: {
|
||||||
{
|
HBRUSH hbr;
|
||||||
HBRUSH hbr;
|
HGDIOBJ holdbr;
|
||||||
HGDIOBJ holdbr;
|
RECT cr;
|
||||||
RECT cr;
|
int wtlen;
|
||||||
int wtlen;
|
LPTSTR wt;
|
||||||
LPTSTR wt;
|
HDC hdc;
|
||||||
HDC hdc;
|
|
||||||
|
|
||||||
PAINTSTRUCT ps;
|
PAINTSTRUCT ps;
|
||||||
hdc = BeginPaint(hWnd, &ps);
|
hdc = BeginPaint(hWnd, &ps);
|
||||||
|
|
||||||
SelectObject(hdc, tip_font);
|
SelectObject(hdc, tip_font);
|
||||||
SelectObject(hdc, GetStockObject(BLACK_PEN));
|
SelectObject(hdc, GetStockObject(BLACK_PEN));
|
||||||
|
|
||||||
hbr = CreateSolidBrush(tip_bg);
|
hbr = CreateSolidBrush(tip_bg);
|
||||||
holdbr = SelectObject(hdc, hbr);
|
holdbr = SelectObject(hdc, hbr);
|
||||||
|
|
||||||
GetClientRect(hWnd, &cr);
|
GetClientRect(hWnd, &cr);
|
||||||
Rectangle(hdc, cr.left, cr.top, cr.right, cr.bottom);
|
Rectangle(hdc, cr.left, cr.top, cr.right, cr.bottom);
|
||||||
|
|
||||||
wtlen = GetWindowTextLength(hWnd);
|
wtlen = GetWindowTextLength(hWnd);
|
||||||
wt = (LPTSTR) snewn(wtlen + 1, TCHAR);
|
wt = (LPTSTR) snewn(wtlen + 1, TCHAR);
|
||||||
GetWindowText(hWnd, wt, wtlen + 1);
|
GetWindowText(hWnd, wt, wtlen + 1);
|
||||||
|
|
||||||
SetTextColor(hdc, tip_text);
|
SetTextColor(hdc, tip_text);
|
||||||
SetBkColor(hdc, tip_bg);
|
SetBkColor(hdc, tip_bg);
|
||||||
|
|
||||||
TextOut(hdc, cr.left + 3, cr.top + 3, wt, wtlen);
|
TextOut(hdc, cr.left + 3, cr.top + 3, wt, wtlen);
|
||||||
|
|
||||||
sfree(wt);
|
sfree(wt);
|
||||||
|
|
||||||
SelectObject(hdc, holdbr);
|
SelectObject(hdc, holdbr);
|
||||||
DeleteObject(hbr);
|
DeleteObject(hbr);
|
||||||
|
|
||||||
EndPaint(hWnd, &ps);
|
EndPaint(hWnd, &ps);
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
case WM_NCHITTEST:
|
case WM_NCHITTEST:
|
||||||
return HTTRANSPARENT;
|
return HTTRANSPARENT;
|
||||||
@ -69,22 +68,21 @@ static LRESULT CALLBACK SizeTipWndProc(HWND hWnd, UINT nMsg,
|
|||||||
tip_font = NULL;
|
tip_font = NULL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_SETTEXT:
|
case WM_SETTEXT: {
|
||||||
{
|
LPCTSTR str = (LPCTSTR) lParam;
|
||||||
LPCTSTR str = (LPCTSTR) lParam;
|
SIZE sz;
|
||||||
SIZE sz;
|
HDC hdc = CreateCompatibleDC(NULL);
|
||||||
HDC hdc = CreateCompatibleDC(NULL);
|
|
||||||
|
|
||||||
SelectObject(hdc, tip_font);
|
SelectObject(hdc, tip_font);
|
||||||
GetTextExtentPoint32(hdc, str, _tcslen(str), &sz);
|
GetTextExtentPoint32(hdc, str, _tcslen(str), &sz);
|
||||||
|
|
||||||
SetWindowPos(hWnd, NULL, 0, 0, sz.cx + 6, sz.cy + 6,
|
SetWindowPos(hWnd, NULL, 0, 0, sz.cx + 6, sz.cy + 6,
|
||||||
SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
|
SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
|
||||||
InvalidateRect(hWnd, NULL, false);
|
InvalidateRect(hWnd, NULL, false);
|
||||||
|
|
||||||
DeleteDC(hdc);
|
DeleteDC(hdc);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return DefWindowProc(hWnd, nMsg, wParam, lParam);
|
return DefWindowProc(hWnd, nMsg, wParam, lParam);
|
||||||
|
@ -925,20 +925,18 @@ void prefslist(struct prefslist *hdl, struct ctlpos *cp, int lines,
|
|||||||
wid = xpos - left;
|
wid = xpos - left;
|
||||||
|
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 1:
|
case 1: {
|
||||||
/* The drag list box. */
|
/* The drag list box. */
|
||||||
r.left = left; r.right = wid;
|
r.left = left; r.right = wid;
|
||||||
r.top = cp->ypos; r.bottom = listheight;
|
r.top = cp->ypos; r.bottom = listheight;
|
||||||
{
|
HWND ctl = doctl(cp, r, "LISTBOX",
|
||||||
HWND ctl;
|
WS_CHILD | WS_VISIBLE | WS_TABSTOP |
|
||||||
ctl = doctl(cp, r, "LISTBOX",
|
WS_VSCROLL | LBS_HASSTRINGS | LBS_USETABSTOPS,
|
||||||
WS_CHILD | WS_VISIBLE | WS_TABSTOP |
|
WS_EX_CLIENTEDGE,
|
||||||
WS_VSCROLL | LBS_HASSTRINGS | LBS_USETABSTOPS,
|
"", listid);
|
||||||
WS_EX_CLIENTEDGE,
|
p_MakeDragList(ctl);
|
||||||
"", listid);
|
|
||||||
p_MakeDragList(ctl);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
/* The "Up" and "Down" buttons. */
|
/* The "Up" and "Down" buttons. */
|
||||||
@ -1496,19 +1494,18 @@ void winctrl_layout(struct dlgparam *dp, struct winctrls *wc,
|
|||||||
* switching on its type.
|
* switching on its type.
|
||||||
*/
|
*/
|
||||||
switch (ctrl->generic.type) {
|
switch (ctrl->generic.type) {
|
||||||
case CTRL_TEXT:
|
case CTRL_TEXT: {
|
||||||
{
|
char *wrapped, *escaped;
|
||||||
char *wrapped, *escaped;
|
int lines;
|
||||||
int lines;
|
num_ids = 1;
|
||||||
num_ids = 1;
|
wrapped = staticwrap(&pos, cp->hwnd,
|
||||||
wrapped = staticwrap(&pos, cp->hwnd,
|
ctrl->generic.label, &lines);
|
||||||
ctrl->generic.label, &lines);
|
escaped = shortcut_escape(wrapped, NO_SHORTCUT);
|
||||||
escaped = shortcut_escape(wrapped, NO_SHORTCUT);
|
statictext(&pos, escaped, lines, base_id);
|
||||||
statictext(&pos, escaped, lines, base_id);
|
sfree(escaped);
|
||||||
sfree(escaped);
|
sfree(wrapped);
|
||||||
sfree(wrapped);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case CTRL_EDITBOX:
|
case CTRL_EDITBOX:
|
||||||
num_ids = 2; /* static, edit */
|
num_ids = 2; /* static, edit */
|
||||||
escaped = shortcut_escape(ctrl->editbox.label,
|
escaped = shortcut_escape(ctrl->editbox.label,
|
||||||
@ -1533,42 +1530,41 @@ void winctrl_layout(struct dlgparam *dp, struct winctrls *wc,
|
|||||||
}
|
}
|
||||||
sfree(escaped);
|
sfree(escaped);
|
||||||
break;
|
break;
|
||||||
case CTRL_RADIO:
|
case CTRL_RADIO: {
|
||||||
num_ids = ctrl->radio.nbuttons + 1; /* label as well */
|
num_ids = ctrl->radio.nbuttons + 1; /* label as well */
|
||||||
{
|
struct radio *buttons;
|
||||||
struct radio *buttons;
|
int i;
|
||||||
int i;
|
|
||||||
|
|
||||||
escaped = shortcut_escape(ctrl->radio.label,
|
escaped = shortcut_escape(ctrl->radio.label,
|
||||||
ctrl->radio.shortcut);
|
ctrl->radio.shortcut);
|
||||||
shortcuts[nshortcuts++] = ctrl->radio.shortcut;
|
shortcuts[nshortcuts++] = ctrl->radio.shortcut;
|
||||||
|
|
||||||
buttons = snewn(ctrl->radio.nbuttons, struct radio);
|
buttons = snewn(ctrl->radio.nbuttons, struct radio);
|
||||||
|
|
||||||
for (i = 0; i < ctrl->radio.nbuttons; i++) {
|
for (i = 0; i < ctrl->radio.nbuttons; i++) {
|
||||||
buttons[i].text =
|
buttons[i].text =
|
||||||
shortcut_escape(ctrl->radio.buttons[i],
|
shortcut_escape(ctrl->radio.buttons[i],
|
||||||
(char)(ctrl->radio.shortcuts ?
|
(char)(ctrl->radio.shortcuts ?
|
||||||
ctrl->radio.shortcuts[i] :
|
ctrl->radio.shortcuts[i] :
|
||||||
NO_SHORTCUT));
|
NO_SHORTCUT));
|
||||||
buttons[i].id = base_id + 1 + i;
|
buttons[i].id = base_id + 1 + i;
|
||||||
if (ctrl->radio.shortcuts) {
|
if (ctrl->radio.shortcuts) {
|
||||||
assert(nshortcuts < MAX_SHORTCUTS_PER_CTRL);
|
assert(nshortcuts < MAX_SHORTCUTS_PER_CTRL);
|
||||||
shortcuts[nshortcuts++] = ctrl->radio.shortcuts[i];
|
shortcuts[nshortcuts++] = ctrl->radio.shortcuts[i];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
radioline_common(&pos, escaped, base_id,
|
|
||||||
ctrl->radio.ncolumns,
|
|
||||||
buttons, ctrl->radio.nbuttons);
|
|
||||||
|
|
||||||
for (i = 0; i < ctrl->radio.nbuttons; i++) {
|
|
||||||
sfree(buttons[i].text);
|
|
||||||
}
|
|
||||||
sfree(buttons);
|
|
||||||
sfree(escaped);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
radioline_common(&pos, escaped, base_id,
|
||||||
|
ctrl->radio.ncolumns,
|
||||||
|
buttons, ctrl->radio.nbuttons);
|
||||||
|
|
||||||
|
for (i = 0; i < ctrl->radio.nbuttons; i++) {
|
||||||
|
sfree(buttons[i].text);
|
||||||
|
}
|
||||||
|
sfree(buttons);
|
||||||
|
sfree(escaped);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case CTRL_CHECKBOX:
|
case CTRL_CHECKBOX:
|
||||||
num_ids = 1;
|
num_ids = 1;
|
||||||
escaped = shortcut_escape(ctrl->checkbox.label,
|
escaped = shortcut_escape(ctrl->checkbox.label,
|
||||||
|
@ -88,17 +88,15 @@ static INT_PTR CALLBACK LogProc(HWND hwnd, UINT msg,
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG: {
|
||||||
{
|
char *str = dupprintf("%s Event Log", appname);
|
||||||
char *str = dupprintf("%s Event Log", appname);
|
SetWindowText(hwnd, str);
|
||||||
SetWindowText(hwnd, str);
|
sfree(str);
|
||||||
sfree(str);
|
|
||||||
}
|
static int tabs[4] = { 78, 108 };
|
||||||
{
|
SendDlgItemMessage(hwnd, IDN_LIST, LB_SETTABSTOPS, 2,
|
||||||
static int tabs[4] = { 78, 108 };
|
(LPARAM) tabs);
|
||||||
SendDlgItemMessage(hwnd, IDN_LIST, LB_SETTABSTOPS, 2,
|
|
||||||
(LPARAM) tabs);
|
|
||||||
}
|
|
||||||
for (i = 0; i < ninitial; i++)
|
for (i = 0; i < ninitial; i++)
|
||||||
SendDlgItemMessage(hwnd, IDN_LIST, LB_ADDSTRING,
|
SendDlgItemMessage(hwnd, IDN_LIST, LB_ADDSTRING,
|
||||||
0, (LPARAM) events_initial[i]);
|
0, (LPARAM) events_initial[i]);
|
||||||
@ -106,6 +104,7 @@ static INT_PTR CALLBACK LogProc(HWND hwnd, UINT msg,
|
|||||||
SendDlgItemMessage(hwnd, IDN_LIST, LB_ADDSTRING,
|
SendDlgItemMessage(hwnd, IDN_LIST, LB_ADDSTRING,
|
||||||
0, (LPARAM) events_circular[(circular_first + i) % LOGEVENT_CIRCULAR_MAX]);
|
0, (LPARAM) events_circular[(circular_first + i) % LOGEVENT_CIRCULAR_MAX]);
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
switch (LOWORD(wParam)) {
|
switch (LOWORD(wParam)) {
|
||||||
case IDOK:
|
case IDOK:
|
||||||
@ -184,14 +183,13 @@ static INT_PTR CALLBACK LicenceProc(HWND hwnd, UINT msg,
|
|||||||
WPARAM wParam, LPARAM lParam)
|
WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG: {
|
||||||
{
|
char *str = dupprintf("%s Licence", appname);
|
||||||
char *str = dupprintf("%s Licence", appname);
|
SetWindowText(hwnd, str);
|
||||||
SetWindowText(hwnd, str);
|
sfree(str);
|
||||||
sfree(str);
|
SetDlgItemText(hwnd, IDA_TEXT, LICENCE_TEXT("\r\n\r\n"));
|
||||||
SetDlgItemText(hwnd, IDA_TEXT, LICENCE_TEXT("\r\n\r\n"));
|
|
||||||
}
|
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
switch (LOWORD(wParam)) {
|
switch (LOWORD(wParam)) {
|
||||||
case IDOK:
|
case IDOK:
|
||||||
@ -213,21 +211,20 @@ static INT_PTR CALLBACK AboutProc(HWND hwnd, UINT msg,
|
|||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG: {
|
||||||
str = dupprintf("About %s", appname);
|
str = dupprintf("About %s", appname);
|
||||||
SetWindowText(hwnd, str);
|
SetWindowText(hwnd, str);
|
||||||
sfree(str);
|
sfree(str);
|
||||||
{
|
char *buildinfo_text = buildinfo("\r\n");
|
||||||
char *buildinfo_text = buildinfo("\r\n");
|
char *text = dupprintf
|
||||||
char *text = dupprintf
|
("%s\r\n\r\n%s\r\n\r\n%s\r\n\r\n%s",
|
||||||
("%s\r\n\r\n%s\r\n\r\n%s\r\n\r\n%s",
|
appname, ver, buildinfo_text,
|
||||||
appname, ver, buildinfo_text,
|
"\251 " SHORT_COPYRIGHT_DETAILS ". All rights reserved.");
|
||||||
"\251 " SHORT_COPYRIGHT_DETAILS ". All rights reserved.");
|
sfree(buildinfo_text);
|
||||||
sfree(buildinfo_text);
|
SetDlgItemText(hwnd, IDA_TEXT, text);
|
||||||
SetDlgItemText(hwnd, IDA_TEXT, text);
|
sfree(text);
|
||||||
sfree(text);
|
|
||||||
}
|
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
switch (LOWORD(wParam)) {
|
switch (LOWORD(wParam)) {
|
||||||
case IDOK:
|
case IDOK:
|
||||||
|
910
windows/window.c
910
windows/window.c
@ -2180,20 +2180,19 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
|||||||
return 0;
|
return 0;
|
||||||
case WM_CREATE:
|
case WM_CREATE:
|
||||||
break;
|
break;
|
||||||
case WM_CLOSE:
|
case WM_CLOSE: {
|
||||||
{
|
char *str;
|
||||||
char *str;
|
show_mouseptr(true);
|
||||||
show_mouseptr(true);
|
str = dupprintf("%s Exit Confirmation", appname);
|
||||||
str = dupprintf("%s Exit Confirmation", appname);
|
if (session_closed || !conf_get_bool(conf, CONF_warn_on_close) ||
|
||||||
if (session_closed || !conf_get_bool(conf, CONF_warn_on_close) ||
|
MessageBox(hwnd,
|
||||||
MessageBox(hwnd,
|
"Are you sure you want to close this session?",
|
||||||
"Are you sure you want to close this session?",
|
str, MB_ICONWARNING | MB_OKCANCEL | MB_DEFBUTTON1)
|
||||||
str, MB_ICONWARNING | MB_OKCANCEL | MB_DEFBUTTON1)
|
== IDOK)
|
||||||
== IDOK)
|
DestroyWindow(hwnd);
|
||||||
DestroyWindow(hwnd);
|
sfree(str);
|
||||||
sfree(str);
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
show_mouseptr(true);
|
show_mouseptr(true);
|
||||||
PostQuitMessage(0);
|
PostQuitMessage(0);
|
||||||
@ -2216,88 +2215,87 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
|||||||
break;
|
break;
|
||||||
case IDM_NEWSESS:
|
case IDM_NEWSESS:
|
||||||
case IDM_DUPSESS:
|
case IDM_DUPSESS:
|
||||||
case IDM_SAVEDSESS:
|
case IDM_SAVEDSESS: {
|
||||||
{
|
char b[2048];
|
||||||
char b[2048];
|
char *cl;
|
||||||
char *cl;
|
const char *argprefix;
|
||||||
const char *argprefix;
|
bool inherit_handles;
|
||||||
bool inherit_handles;
|
STARTUPINFO si;
|
||||||
STARTUPINFO si;
|
PROCESS_INFORMATION pi;
|
||||||
PROCESS_INFORMATION pi;
|
HANDLE filemap = NULL;
|
||||||
HANDLE filemap = NULL;
|
|
||||||
|
|
||||||
if (restricted_acl())
|
if (restricted_acl())
|
||||||
argprefix = "&R";
|
argprefix = "&R";
|
||||||
else
|
else
|
||||||
argprefix = "";
|
argprefix = "";
|
||||||
|
|
||||||
if (wParam == IDM_DUPSESS) {
|
if (wParam == IDM_DUPSESS) {
|
||||||
/*
|
/*
|
||||||
* Allocate a file-mapping memory chunk for the
|
* Allocate a file-mapping memory chunk for the
|
||||||
* config structure.
|
* config structure.
|
||||||
*/
|
*/
|
||||||
SECURITY_ATTRIBUTES sa;
|
SECURITY_ATTRIBUTES sa;
|
||||||
strbuf *serbuf;
|
strbuf *serbuf;
|
||||||
void *p;
|
void *p;
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
serbuf = strbuf_new();
|
serbuf = strbuf_new();
|
||||||
conf_serialise(BinarySink_UPCAST(serbuf), conf);
|
conf_serialise(BinarySink_UPCAST(serbuf), conf);
|
||||||
size = serbuf->len;
|
size = serbuf->len;
|
||||||
|
|
||||||
sa.nLength = sizeof(sa);
|
sa.nLength = sizeof(sa);
|
||||||
sa.lpSecurityDescriptor = NULL;
|
sa.lpSecurityDescriptor = NULL;
|
||||||
sa.bInheritHandle = true;
|
sa.bInheritHandle = true;
|
||||||
filemap = CreateFileMapping(INVALID_HANDLE_VALUE,
|
filemap = CreateFileMapping(INVALID_HANDLE_VALUE,
|
||||||
&sa,
|
&sa,
|
||||||
PAGE_READWRITE,
|
PAGE_READWRITE,
|
||||||
0, size, NULL);
|
0, size, NULL);
|
||||||
if (filemap && filemap != INVALID_HANDLE_VALUE) {
|
if (filemap && filemap != INVALID_HANDLE_VALUE) {
|
||||||
p = MapViewOfFile(filemap, FILE_MAP_WRITE, 0, 0, size);
|
p = MapViewOfFile(filemap, FILE_MAP_WRITE, 0, 0, size);
|
||||||
if (p) {
|
if (p) {
|
||||||
memcpy(p, serbuf->s, size);
|
memcpy(p, serbuf->s, size);
|
||||||
UnmapViewOfFile(p);
|
UnmapViewOfFile(p);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
strbuf_free(serbuf);
|
|
||||||
inherit_handles = true;
|
|
||||||
cl = dupprintf("putty %s&%p:%u", argprefix,
|
|
||||||
filemap, (unsigned)size);
|
|
||||||
} else if (wParam == IDM_SAVEDSESS) {
|
|
||||||
unsigned int sessno = ((lParam - IDM_SAVED_MIN)
|
|
||||||
/ MENU_SAVED_STEP) + 1;
|
|
||||||
if (sessno < (unsigned)sesslist.nsessions) {
|
|
||||||
const char *session = sesslist.sessions[sessno];
|
|
||||||
cl = dupprintf("putty %s@%s", argprefix, session);
|
|
||||||
inherit_handles = false;
|
|
||||||
} else
|
|
||||||
break;
|
|
||||||
} else /* IDM_NEWSESS */ {
|
|
||||||
cl = dupprintf("putty%s%s",
|
|
||||||
*argprefix ? " " : "",
|
|
||||||
argprefix);
|
|
||||||
inherit_handles = false;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GetModuleFileName(NULL, b, sizeof(b) - 1);
|
strbuf_free(serbuf);
|
||||||
si.cb = sizeof(si);
|
inherit_handles = true;
|
||||||
si.lpReserved = NULL;
|
cl = dupprintf("putty %s&%p:%u", argprefix,
|
||||||
si.lpDesktop = NULL;
|
filemap, (unsigned)size);
|
||||||
si.lpTitle = NULL;
|
} else if (wParam == IDM_SAVEDSESS) {
|
||||||
si.dwFlags = 0;
|
unsigned int sessno = ((lParam - IDM_SAVED_MIN)
|
||||||
si.cbReserved2 = 0;
|
/ MENU_SAVED_STEP) + 1;
|
||||||
si.lpReserved2 = NULL;
|
if (sessno < (unsigned)sesslist.nsessions) {
|
||||||
CreateProcess(b, cl, NULL, NULL, inherit_handles,
|
const char *session = sesslist.sessions[sessno];
|
||||||
NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi);
|
cl = dupprintf("putty %s@%s", argprefix, session);
|
||||||
CloseHandle(pi.hProcess);
|
inherit_handles = false;
|
||||||
CloseHandle(pi.hThread);
|
} else
|
||||||
|
break;
|
||||||
if (filemap)
|
} else /* IDM_NEWSESS */ {
|
||||||
CloseHandle(filemap);
|
cl = dupprintf("putty%s%s",
|
||||||
sfree(cl);
|
*argprefix ? " " : "",
|
||||||
|
argprefix);
|
||||||
|
inherit_handles = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GetModuleFileName(NULL, b, sizeof(b) - 1);
|
||||||
|
si.cb = sizeof(si);
|
||||||
|
si.lpReserved = NULL;
|
||||||
|
si.lpDesktop = NULL;
|
||||||
|
si.lpTitle = NULL;
|
||||||
|
si.dwFlags = 0;
|
||||||
|
si.cbReserved2 = 0;
|
||||||
|
si.lpReserved2 = NULL;
|
||||||
|
CreateProcess(b, cl, NULL, NULL, inherit_handles,
|
||||||
|
NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi);
|
||||||
|
CloseHandle(pi.hProcess);
|
||||||
|
CloseHandle(pi.hThread);
|
||||||
|
|
||||||
|
if (filemap)
|
||||||
|
CloseHandle(filemap);
|
||||||
|
sfree(cl);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case IDM_RESTART:
|
case IDM_RESTART:
|
||||||
if (!backend) {
|
if (!backend) {
|
||||||
lp_eventlog(&wgs.logpolicy, "----- Session restarted -----");
|
lp_eventlog(&wgs.logpolicy, "----- Session restarted -----");
|
||||||
@ -2306,193 +2304,192 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
|||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case IDM_RECONF:
|
case IDM_RECONF: {
|
||||||
{
|
Conf *prev_conf;
|
||||||
Conf *prev_conf;
|
int init_lvl = 1;
|
||||||
int init_lvl = 1;
|
bool reconfig_result;
|
||||||
bool reconfig_result;
|
|
||||||
|
|
||||||
if (reconfiguring)
|
if (reconfiguring)
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
reconfiguring = true;
|
reconfiguring = true;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copy the current window title into the stored
|
* Copy the current window title into the stored
|
||||||
* previous configuration, so that doing nothing to
|
* previous configuration, so that doing nothing to
|
||||||
* the window title field in the config box doesn't
|
* the window title field in the config box doesn't
|
||||||
* reset the title to its startup state.
|
* reset the title to its startup state.
|
||||||
*/
|
*/
|
||||||
conf_set_str(conf, CONF_wintitle, window_name);
|
conf_set_str(conf, CONF_wintitle, window_name);
|
||||||
|
|
||||||
prev_conf = conf_copy(conf);
|
prev_conf = conf_copy(conf);
|
||||||
|
|
||||||
reconfig_result = do_reconfig(
|
reconfig_result = do_reconfig(
|
||||||
hwnd, conf, backend ? backend_cfg_info(backend) : 0);
|
hwnd, conf, backend ? backend_cfg_info(backend) : 0);
|
||||||
reconfiguring = false;
|
reconfiguring = false;
|
||||||
if (!reconfig_result) {
|
if (!reconfig_result) {
|
||||||
conf_free(prev_conf);
|
conf_free(prev_conf);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
conf_cache_data();
|
|
||||||
|
|
||||||
resize_action = conf_get_int(conf, CONF_resize_action);
|
|
||||||
{
|
|
||||||
/* Disable full-screen if resizing forbidden */
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < lenof(popup_menus); i++)
|
|
||||||
EnableMenuItem(popup_menus[i].menu, IDM_FULLSCREEN,
|
|
||||||
MF_BYCOMMAND |
|
|
||||||
(resize_action == RESIZE_DISABLED
|
|
||||||
? MF_GRAYED : MF_ENABLED));
|
|
||||||
/* Gracefully unzoom if necessary */
|
|
||||||
if (IsZoomed(hwnd) && (resize_action == RESIZE_DISABLED))
|
|
||||||
ShowWindow(hwnd, SW_RESTORE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Pass new config data to the logging module */
|
|
||||||
log_reconfig(logctx, conf);
|
|
||||||
|
|
||||||
sfree(logpal);
|
|
||||||
/*
|
|
||||||
* Flush the line discipline's edit buffer in the
|
|
||||||
* case where local editing has just been disabled.
|
|
||||||
*/
|
|
||||||
if (ldisc) {
|
|
||||||
ldisc_configure(ldisc, conf);
|
|
||||||
ldisc_echoedit_update(ldisc);
|
|
||||||
}
|
|
||||||
if (pal)
|
|
||||||
DeleteObject(pal);
|
|
||||||
logpal = NULL;
|
|
||||||
pal = NULL;
|
|
||||||
conftopalette();
|
|
||||||
init_palette();
|
|
||||||
|
|
||||||
/* Pass new config data to the terminal */
|
|
||||||
term_reconfig(term, conf);
|
|
||||||
setup_clipboards(term, conf);
|
|
||||||
|
|
||||||
/* Pass new config data to the back end */
|
|
||||||
if (backend)
|
|
||||||
backend_reconfig(backend, conf);
|
|
||||||
|
|
||||||
/* Screen size changed ? */
|
|
||||||
if (conf_get_int(conf, CONF_height) !=
|
|
||||||
conf_get_int(prev_conf, CONF_height) ||
|
|
||||||
conf_get_int(conf, CONF_width) !=
|
|
||||||
conf_get_int(prev_conf, CONF_width) ||
|
|
||||||
conf_get_int(conf, CONF_savelines) !=
|
|
||||||
conf_get_int(prev_conf, CONF_savelines) ||
|
|
||||||
resize_action == RESIZE_FONT ||
|
|
||||||
(resize_action == RESIZE_EITHER && IsZoomed(hwnd)) ||
|
|
||||||
resize_action == RESIZE_DISABLED)
|
|
||||||
term_size(term, conf_get_int(conf, CONF_height),
|
|
||||||
conf_get_int(conf, CONF_width),
|
|
||||||
conf_get_int(conf, CONF_savelines));
|
|
||||||
|
|
||||||
/* Enable or disable the scroll bar, etc */
|
|
||||||
{
|
|
||||||
LONG nflg, flag = GetWindowLongPtr(hwnd, GWL_STYLE);
|
|
||||||
LONG nexflag, exflag =
|
|
||||||
GetWindowLongPtr(hwnd, GWL_EXSTYLE);
|
|
||||||
|
|
||||||
nexflag = exflag;
|
|
||||||
if (conf_get_bool(conf, CONF_alwaysontop) !=
|
|
||||||
conf_get_bool(prev_conf, CONF_alwaysontop)) {
|
|
||||||
if (conf_get_bool(conf, CONF_alwaysontop)) {
|
|
||||||
nexflag |= WS_EX_TOPMOST;
|
|
||||||
SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0,
|
|
||||||
SWP_NOMOVE | SWP_NOSIZE);
|
|
||||||
} else {
|
|
||||||
nexflag &= ~(WS_EX_TOPMOST);
|
|
||||||
SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0,
|
|
||||||
SWP_NOMOVE | SWP_NOSIZE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (conf_get_bool(conf, CONF_sunken_edge))
|
|
||||||
nexflag |= WS_EX_CLIENTEDGE;
|
|
||||||
else
|
|
||||||
nexflag &= ~(WS_EX_CLIENTEDGE);
|
|
||||||
|
|
||||||
nflg = flag;
|
|
||||||
if (conf_get_bool(conf, is_full_screen() ?
|
|
||||||
CONF_scrollbar_in_fullscreen :
|
|
||||||
CONF_scrollbar))
|
|
||||||
nflg |= WS_VSCROLL;
|
|
||||||
else
|
|
||||||
nflg &= ~WS_VSCROLL;
|
|
||||||
|
|
||||||
if (resize_action == RESIZE_DISABLED ||
|
|
||||||
is_full_screen())
|
|
||||||
nflg &= ~WS_THICKFRAME;
|
|
||||||
else
|
|
||||||
nflg |= WS_THICKFRAME;
|
|
||||||
|
|
||||||
if (resize_action == RESIZE_DISABLED)
|
|
||||||
nflg &= ~WS_MAXIMIZEBOX;
|
|
||||||
else
|
|
||||||
nflg |= WS_MAXIMIZEBOX;
|
|
||||||
|
|
||||||
if (nflg != flag || nexflag != exflag) {
|
|
||||||
if (nflg != flag)
|
|
||||||
SetWindowLongPtr(hwnd, GWL_STYLE, nflg);
|
|
||||||
if (nexflag != exflag)
|
|
||||||
SetWindowLongPtr(hwnd, GWL_EXSTYLE, nexflag);
|
|
||||||
|
|
||||||
SetWindowPos(hwnd, NULL, 0, 0, 0, 0,
|
|
||||||
SWP_NOACTIVATE | SWP_NOCOPYBITS |
|
|
||||||
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
|
|
||||||
SWP_FRAMECHANGED);
|
|
||||||
|
|
||||||
init_lvl = 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Oops */
|
|
||||||
if (resize_action == RESIZE_DISABLED && IsZoomed(hwnd)) {
|
|
||||||
force_normal(hwnd);
|
|
||||||
init_lvl = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
win_set_title(wintw, conf_get_str(conf, CONF_wintitle));
|
|
||||||
if (IsIconic(hwnd)) {
|
|
||||||
SetWindowText(hwnd,
|
|
||||||
conf_get_bool(conf, CONF_win_name_always) ?
|
|
||||||
window_name : icon_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
FontSpec *font = conf_get_fontspec(conf, CONF_font);
|
|
||||||
FontSpec *prev_font = conf_get_fontspec(prev_conf,
|
|
||||||
CONF_font);
|
|
||||||
|
|
||||||
if (!strcmp(font->name, prev_font->name) ||
|
|
||||||
!strcmp(conf_get_str(conf, CONF_line_codepage),
|
|
||||||
conf_get_str(prev_conf, CONF_line_codepage)) ||
|
|
||||||
font->isbold != prev_font->isbold ||
|
|
||||||
font->height != prev_font->height ||
|
|
||||||
font->charset != prev_font->charset ||
|
|
||||||
conf_get_int(conf, CONF_font_quality) !=
|
|
||||||
conf_get_int(prev_conf, CONF_font_quality) ||
|
|
||||||
conf_get_int(conf, CONF_vtmode) !=
|
|
||||||
conf_get_int(prev_conf, CONF_vtmode) ||
|
|
||||||
conf_get_int(conf, CONF_bold_style) !=
|
|
||||||
conf_get_int(prev_conf, CONF_bold_style) ||
|
|
||||||
resize_action == RESIZE_DISABLED ||
|
|
||||||
resize_action == RESIZE_EITHER ||
|
|
||||||
resize_action != conf_get_int(prev_conf,
|
|
||||||
CONF_resize_action))
|
|
||||||
init_lvl = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
InvalidateRect(hwnd, NULL, true);
|
|
||||||
reset_window(init_lvl);
|
|
||||||
|
|
||||||
conf_free(prev_conf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
conf_cache_data();
|
||||||
|
|
||||||
|
resize_action = conf_get_int(conf, CONF_resize_action);
|
||||||
|
{
|
||||||
|
/* Disable full-screen if resizing forbidden */
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < lenof(popup_menus); i++)
|
||||||
|
EnableMenuItem(popup_menus[i].menu, IDM_FULLSCREEN,
|
||||||
|
MF_BYCOMMAND |
|
||||||
|
(resize_action == RESIZE_DISABLED
|
||||||
|
? MF_GRAYED : MF_ENABLED));
|
||||||
|
/* Gracefully unzoom if necessary */
|
||||||
|
if (IsZoomed(hwnd) && (resize_action == RESIZE_DISABLED))
|
||||||
|
ShowWindow(hwnd, SW_RESTORE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Pass new config data to the logging module */
|
||||||
|
log_reconfig(logctx, conf);
|
||||||
|
|
||||||
|
sfree(logpal);
|
||||||
|
/*
|
||||||
|
* Flush the line discipline's edit buffer in the
|
||||||
|
* case where local editing has just been disabled.
|
||||||
|
*/
|
||||||
|
if (ldisc) {
|
||||||
|
ldisc_configure(ldisc, conf);
|
||||||
|
ldisc_echoedit_update(ldisc);
|
||||||
|
}
|
||||||
|
if (pal)
|
||||||
|
DeleteObject(pal);
|
||||||
|
logpal = NULL;
|
||||||
|
pal = NULL;
|
||||||
|
conftopalette();
|
||||||
|
init_palette();
|
||||||
|
|
||||||
|
/* Pass new config data to the terminal */
|
||||||
|
term_reconfig(term, conf);
|
||||||
|
setup_clipboards(term, conf);
|
||||||
|
|
||||||
|
/* Pass new config data to the back end */
|
||||||
|
if (backend)
|
||||||
|
backend_reconfig(backend, conf);
|
||||||
|
|
||||||
|
/* Screen size changed ? */
|
||||||
|
if (conf_get_int(conf, CONF_height) !=
|
||||||
|
conf_get_int(prev_conf, CONF_height) ||
|
||||||
|
conf_get_int(conf, CONF_width) !=
|
||||||
|
conf_get_int(prev_conf, CONF_width) ||
|
||||||
|
conf_get_int(conf, CONF_savelines) !=
|
||||||
|
conf_get_int(prev_conf, CONF_savelines) ||
|
||||||
|
resize_action == RESIZE_FONT ||
|
||||||
|
(resize_action == RESIZE_EITHER && IsZoomed(hwnd)) ||
|
||||||
|
resize_action == RESIZE_DISABLED)
|
||||||
|
term_size(term, conf_get_int(conf, CONF_height),
|
||||||
|
conf_get_int(conf, CONF_width),
|
||||||
|
conf_get_int(conf, CONF_savelines));
|
||||||
|
|
||||||
|
/* Enable or disable the scroll bar, etc */
|
||||||
|
{
|
||||||
|
LONG nflg, flag = GetWindowLongPtr(hwnd, GWL_STYLE);
|
||||||
|
LONG nexflag, exflag =
|
||||||
|
GetWindowLongPtr(hwnd, GWL_EXSTYLE);
|
||||||
|
|
||||||
|
nexflag = exflag;
|
||||||
|
if (conf_get_bool(conf, CONF_alwaysontop) !=
|
||||||
|
conf_get_bool(prev_conf, CONF_alwaysontop)) {
|
||||||
|
if (conf_get_bool(conf, CONF_alwaysontop)) {
|
||||||
|
nexflag |= WS_EX_TOPMOST;
|
||||||
|
SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0,
|
||||||
|
SWP_NOMOVE | SWP_NOSIZE);
|
||||||
|
} else {
|
||||||
|
nexflag &= ~(WS_EX_TOPMOST);
|
||||||
|
SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0,
|
||||||
|
SWP_NOMOVE | SWP_NOSIZE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (conf_get_bool(conf, CONF_sunken_edge))
|
||||||
|
nexflag |= WS_EX_CLIENTEDGE;
|
||||||
|
else
|
||||||
|
nexflag &= ~(WS_EX_CLIENTEDGE);
|
||||||
|
|
||||||
|
nflg = flag;
|
||||||
|
if (conf_get_bool(conf, is_full_screen() ?
|
||||||
|
CONF_scrollbar_in_fullscreen :
|
||||||
|
CONF_scrollbar))
|
||||||
|
nflg |= WS_VSCROLL;
|
||||||
|
else
|
||||||
|
nflg &= ~WS_VSCROLL;
|
||||||
|
|
||||||
|
if (resize_action == RESIZE_DISABLED ||
|
||||||
|
is_full_screen())
|
||||||
|
nflg &= ~WS_THICKFRAME;
|
||||||
|
else
|
||||||
|
nflg |= WS_THICKFRAME;
|
||||||
|
|
||||||
|
if (resize_action == RESIZE_DISABLED)
|
||||||
|
nflg &= ~WS_MAXIMIZEBOX;
|
||||||
|
else
|
||||||
|
nflg |= WS_MAXIMIZEBOX;
|
||||||
|
|
||||||
|
if (nflg != flag || nexflag != exflag) {
|
||||||
|
if (nflg != flag)
|
||||||
|
SetWindowLongPtr(hwnd, GWL_STYLE, nflg);
|
||||||
|
if (nexflag != exflag)
|
||||||
|
SetWindowLongPtr(hwnd, GWL_EXSTYLE, nexflag);
|
||||||
|
|
||||||
|
SetWindowPos(hwnd, NULL, 0, 0, 0, 0,
|
||||||
|
SWP_NOACTIVATE | SWP_NOCOPYBITS |
|
||||||
|
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
|
||||||
|
SWP_FRAMECHANGED);
|
||||||
|
|
||||||
|
init_lvl = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Oops */
|
||||||
|
if (resize_action == RESIZE_DISABLED && IsZoomed(hwnd)) {
|
||||||
|
force_normal(hwnd);
|
||||||
|
init_lvl = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
win_set_title(wintw, conf_get_str(conf, CONF_wintitle));
|
||||||
|
if (IsIconic(hwnd)) {
|
||||||
|
SetWindowText(hwnd,
|
||||||
|
conf_get_bool(conf, CONF_win_name_always) ?
|
||||||
|
window_name : icon_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
FontSpec *font = conf_get_fontspec(conf, CONF_font);
|
||||||
|
FontSpec *prev_font = conf_get_fontspec(prev_conf,
|
||||||
|
CONF_font);
|
||||||
|
|
||||||
|
if (!strcmp(font->name, prev_font->name) ||
|
||||||
|
!strcmp(conf_get_str(conf, CONF_line_codepage),
|
||||||
|
conf_get_str(prev_conf, CONF_line_codepage)) ||
|
||||||
|
font->isbold != prev_font->isbold ||
|
||||||
|
font->height != prev_font->height ||
|
||||||
|
font->charset != prev_font->charset ||
|
||||||
|
conf_get_int(conf, CONF_font_quality) !=
|
||||||
|
conf_get_int(prev_conf, CONF_font_quality) ||
|
||||||
|
conf_get_int(conf, CONF_vtmode) !=
|
||||||
|
conf_get_int(prev_conf, CONF_vtmode) ||
|
||||||
|
conf_get_int(conf, CONF_bold_style) !=
|
||||||
|
conf_get_int(prev_conf, CONF_bold_style) ||
|
||||||
|
resize_action == RESIZE_DISABLED ||
|
||||||
|
resize_action == RESIZE_EITHER ||
|
||||||
|
resize_action != conf_get_int(prev_conf,
|
||||||
|
CONF_resize_action))
|
||||||
|
init_lvl = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
InvalidateRect(hwnd, NULL, true);
|
||||||
|
reset_window(init_lvl);
|
||||||
|
|
||||||
|
conf_free(prev_conf);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case IDM_COPYALL:
|
case IDM_COPYALL:
|
||||||
term_copyall(term, clips_system, lenof(clips_system));
|
term_copyall(term, clips_system, lenof(clips_system));
|
||||||
break;
|
break;
|
||||||
@ -2680,21 +2677,19 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
case WM_MOUSEMOVE:
|
case WM_MOUSEMOVE: {
|
||||||
{
|
/*
|
||||||
/*
|
* Windows seems to like to occasionally send MOUSEMOVE
|
||||||
* Windows seems to like to occasionally send MOUSEMOVE
|
* events even if the mouse hasn't moved. Don't unhide
|
||||||
* events even if the mouse hasn't moved. Don't unhide
|
* the mouse pointer in this case.
|
||||||
* the mouse pointer in this case.
|
*/
|
||||||
*/
|
static WPARAM wp = 0;
|
||||||
static WPARAM wp = 0;
|
static LPARAM lp = 0;
|
||||||
static LPARAM lp = 0;
|
if (wParam != wp || lParam != lp ||
|
||||||
if (wParam != wp || lParam != lp ||
|
last_mousemove != WM_MOUSEMOVE) {
|
||||||
last_mousemove != WM_MOUSEMOVE) {
|
show_mouseptr(true);
|
||||||
show_mouseptr(true);
|
wp = wParam; lp = lParam;
|
||||||
wp = wParam; lp = lParam;
|
last_mousemove = WM_MOUSEMOVE;
|
||||||
last_mousemove = WM_MOUSEMOVE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Add the mouse position and message time to the random
|
* Add the mouse position and message time to the random
|
||||||
@ -2717,19 +2712,19 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
|||||||
wParam & MK_CONTROL, is_alt_pressed());
|
wParam & MK_CONTROL, is_alt_pressed());
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
case WM_NCMOUSEMOVE:
|
}
|
||||||
{
|
case WM_NCMOUSEMOVE: {
|
||||||
static WPARAM wp = 0;
|
static WPARAM wp = 0;
|
||||||
static LPARAM lp = 0;
|
static LPARAM lp = 0;
|
||||||
if (wParam != wp || lParam != lp ||
|
if (wParam != wp || lParam != lp ||
|
||||||
last_mousemove != WM_NCMOUSEMOVE) {
|
last_mousemove != WM_NCMOUSEMOVE) {
|
||||||
show_mouseptr(true);
|
show_mouseptr(true);
|
||||||
wp = wParam; lp = lParam;
|
wp = wParam; lp = lParam;
|
||||||
last_mousemove = WM_NCMOUSEMOVE;
|
last_mousemove = WM_NCMOUSEMOVE;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
noise_ultralight(NOISE_SOURCE_MOUSEPOS, lParam);
|
noise_ultralight(NOISE_SOURCE_MOUSEPOS, lParam);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case WM_IGNORE_CLIP:
|
case WM_IGNORE_CLIP:
|
||||||
ignore_clip = wParam; /* don't panic on DESTROYCLIPBOARD */
|
ignore_clip = wParam; /* don't panic on DESTROYCLIPBOARD */
|
||||||
break;
|
break;
|
||||||
@ -2738,122 +2733,120 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
|||||||
term_lost_clipboard_ownership(term, CLIP_SYSTEM);
|
term_lost_clipboard_ownership(term, CLIP_SYSTEM);
|
||||||
ignore_clip = false;
|
ignore_clip = false;
|
||||||
return 0;
|
return 0;
|
||||||
case WM_PAINT:
|
case WM_PAINT: {
|
||||||
{
|
PAINTSTRUCT p;
|
||||||
PAINTSTRUCT p;
|
|
||||||
|
|
||||||
HideCaret(hwnd);
|
HideCaret(hwnd);
|
||||||
hdc = BeginPaint(hwnd, &p);
|
hdc = BeginPaint(hwnd, &p);
|
||||||
if (pal) {
|
if (pal) {
|
||||||
SelectPalette(hdc, pal, true);
|
SelectPalette(hdc, pal, true);
|
||||||
RealizePalette(hdc);
|
RealizePalette(hdc);
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We have to be careful about term_paint(). It will
|
|
||||||
* set a bunch of character cells to INVALID and then
|
|
||||||
* call do_paint(), which will redraw those cells and
|
|
||||||
* _then mark them as done_. This may not be accurate:
|
|
||||||
* when painting in WM_PAINT context we are restricted
|
|
||||||
* to the rectangle which has just been exposed - so if
|
|
||||||
* that only covers _part_ of a character cell and the
|
|
||||||
* rest of it was already visible, that remainder will
|
|
||||||
* not be redrawn at all. Accordingly, we must not
|
|
||||||
* paint any character cell in a WM_PAINT context which
|
|
||||||
* already has a pending update due to terminal output.
|
|
||||||
* The simplest solution to this - and many, many
|
|
||||||
* thanks to Hung-Te Lin for working all this out - is
|
|
||||||
* not to do any actual painting at _all_ if there's a
|
|
||||||
* pending terminal update: just mark the relevant
|
|
||||||
* character cells as INVALID and wait for the
|
|
||||||
* scheduled full update to sort it out.
|
|
||||||
*
|
|
||||||
* I have a suspicion this isn't the _right_ solution.
|
|
||||||
* An alternative approach would be to have terminal.c
|
|
||||||
* separately track what _should_ be on the terminal
|
|
||||||
* screen and what _is_ on the terminal screen, and
|
|
||||||
* have two completely different types of redraw (one
|
|
||||||
* for full updates, which syncs the former with the
|
|
||||||
* terminal itself, and one for WM_PAINT which syncs
|
|
||||||
* the latter with the former); yet another possibility
|
|
||||||
* would be to have the Windows front end do what the
|
|
||||||
* GTK one already does, and maintain a bitmap of the
|
|
||||||
* current terminal appearance so that WM_PAINT becomes
|
|
||||||
* completely trivial. However, this should do for now.
|
|
||||||
*/
|
|
||||||
assert(!wintw_hdc);
|
|
||||||
wintw_hdc = hdc;
|
|
||||||
term_paint(term,
|
|
||||||
(p.rcPaint.left-offset_width)/font_width,
|
|
||||||
(p.rcPaint.top-offset_height)/font_height,
|
|
||||||
(p.rcPaint.right-offset_width-1)/font_width,
|
|
||||||
(p.rcPaint.bottom-offset_height-1)/font_height,
|
|
||||||
!term->window_update_pending);
|
|
||||||
wintw_hdc = NULL;
|
|
||||||
|
|
||||||
if (p.fErase ||
|
|
||||||
p.rcPaint.left < offset_width ||
|
|
||||||
p.rcPaint.top < offset_height ||
|
|
||||||
p.rcPaint.right >= offset_width + font_width*term->cols ||
|
|
||||||
p.rcPaint.bottom>= offset_height + font_height*term->rows)
|
|
||||||
{
|
|
||||||
HBRUSH fillcolour, oldbrush;
|
|
||||||
HPEN edge, oldpen;
|
|
||||||
fillcolour = CreateSolidBrush (
|
|
||||||
colours[ATTR_DEFBG>>ATTR_BGSHIFT]);
|
|
||||||
oldbrush = SelectObject(hdc, fillcolour);
|
|
||||||
edge = CreatePen(PS_SOLID, 0,
|
|
||||||
colours[ATTR_DEFBG>>ATTR_BGSHIFT]);
|
|
||||||
oldpen = SelectObject(hdc, edge);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Jordan Russell reports that this apparently
|
|
||||||
* ineffectual IntersectClipRect() call masks a
|
|
||||||
* Windows NT/2K bug causing strange display
|
|
||||||
* problems when the PuTTY window is taller than
|
|
||||||
* the primary monitor. It seems harmless enough...
|
|
||||||
*/
|
|
||||||
IntersectClipRect(hdc,
|
|
||||||
p.rcPaint.left, p.rcPaint.top,
|
|
||||||
p.rcPaint.right, p.rcPaint.bottom);
|
|
||||||
|
|
||||||
ExcludeClipRect(hdc,
|
|
||||||
offset_width, offset_height,
|
|
||||||
offset_width+font_width*term->cols,
|
|
||||||
offset_height+font_height*term->rows);
|
|
||||||
|
|
||||||
Rectangle(hdc, p.rcPaint.left, p.rcPaint.top,
|
|
||||||
p.rcPaint.right, p.rcPaint.bottom);
|
|
||||||
|
|
||||||
/* SelectClipRgn(hdc, NULL); */
|
|
||||||
|
|
||||||
SelectObject(hdc, oldbrush);
|
|
||||||
DeleteObject(fillcolour);
|
|
||||||
SelectObject(hdc, oldpen);
|
|
||||||
DeleteObject(edge);
|
|
||||||
}
|
|
||||||
SelectObject(hdc, GetStockObject(SYSTEM_FONT));
|
|
||||||
SelectObject(hdc, GetStockObject(WHITE_PEN));
|
|
||||||
EndPaint(hwnd, &p);
|
|
||||||
ShowCaret(hwnd);
|
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
case WM_NETEVENT:
|
/*
|
||||||
|
* We have to be careful about term_paint(). It will
|
||||||
|
* set a bunch of character cells to INVALID and then
|
||||||
|
* call do_paint(), which will redraw those cells and
|
||||||
|
* _then mark them as done_. This may not be accurate:
|
||||||
|
* when painting in WM_PAINT context we are restricted
|
||||||
|
* to the rectangle which has just been exposed - so if
|
||||||
|
* that only covers _part_ of a character cell and the
|
||||||
|
* rest of it was already visible, that remainder will
|
||||||
|
* not be redrawn at all. Accordingly, we must not
|
||||||
|
* paint any character cell in a WM_PAINT context which
|
||||||
|
* already has a pending update due to terminal output.
|
||||||
|
* The simplest solution to this - and many, many
|
||||||
|
* thanks to Hung-Te Lin for working all this out - is
|
||||||
|
* not to do any actual painting at _all_ if there's a
|
||||||
|
* pending terminal update: just mark the relevant
|
||||||
|
* character cells as INVALID and wait for the
|
||||||
|
* scheduled full update to sort it out.
|
||||||
|
*
|
||||||
|
* I have a suspicion this isn't the _right_ solution.
|
||||||
|
* An alternative approach would be to have terminal.c
|
||||||
|
* separately track what _should_ be on the terminal
|
||||||
|
* screen and what _is_ on the terminal screen, and
|
||||||
|
* have two completely different types of redraw (one
|
||||||
|
* for full updates, which syncs the former with the
|
||||||
|
* terminal itself, and one for WM_PAINT which syncs
|
||||||
|
* the latter with the former); yet another possibility
|
||||||
|
* would be to have the Windows front end do what the
|
||||||
|
* GTK one already does, and maintain a bitmap of the
|
||||||
|
* current terminal appearance so that WM_PAINT becomes
|
||||||
|
* completely trivial. However, this should do for now.
|
||||||
|
*/
|
||||||
|
assert(!wintw_hdc);
|
||||||
|
wintw_hdc = hdc;
|
||||||
|
term_paint(term,
|
||||||
|
(p.rcPaint.left-offset_width)/font_width,
|
||||||
|
(p.rcPaint.top-offset_height)/font_height,
|
||||||
|
(p.rcPaint.right-offset_width-1)/font_width,
|
||||||
|
(p.rcPaint.bottom-offset_height-1)/font_height,
|
||||||
|
!term->window_update_pending);
|
||||||
|
wintw_hdc = NULL;
|
||||||
|
|
||||||
|
if (p.fErase ||
|
||||||
|
p.rcPaint.left < offset_width ||
|
||||||
|
p.rcPaint.top < offset_height ||
|
||||||
|
p.rcPaint.right >= offset_width + font_width*term->cols ||
|
||||||
|
p.rcPaint.bottom>= offset_height + font_height*term->rows)
|
||||||
{
|
{
|
||||||
/*
|
HBRUSH fillcolour, oldbrush;
|
||||||
* To protect against re-entrancy when Windows's recv()
|
HPEN edge, oldpen;
|
||||||
* immediately triggers a new WSAAsyncSelect window
|
fillcolour = CreateSolidBrush (
|
||||||
* message, we don't call select_result directly from this
|
colours[ATTR_DEFBG>>ATTR_BGSHIFT]);
|
||||||
* handler but instead wait until we're back out at the
|
oldbrush = SelectObject(hdc, fillcolour);
|
||||||
* top level of the message loop.
|
edge = CreatePen(PS_SOLID, 0,
|
||||||
*/
|
colours[ATTR_DEFBG>>ATTR_BGSHIFT]);
|
||||||
struct wm_netevent_params *params =
|
oldpen = SelectObject(hdc, edge);
|
||||||
snew(struct wm_netevent_params);
|
|
||||||
params->wParam = wParam;
|
/*
|
||||||
params->lParam = lParam;
|
* Jordan Russell reports that this apparently
|
||||||
queue_toplevel_callback(wm_netevent_callback, params);
|
* ineffectual IntersectClipRect() call masks a
|
||||||
|
* Windows NT/2K bug causing strange display
|
||||||
|
* problems when the PuTTY window is taller than
|
||||||
|
* the primary monitor. It seems harmless enough...
|
||||||
|
*/
|
||||||
|
IntersectClipRect(hdc,
|
||||||
|
p.rcPaint.left, p.rcPaint.top,
|
||||||
|
p.rcPaint.right, p.rcPaint.bottom);
|
||||||
|
|
||||||
|
ExcludeClipRect(hdc,
|
||||||
|
offset_width, offset_height,
|
||||||
|
offset_width+font_width*term->cols,
|
||||||
|
offset_height+font_height*term->rows);
|
||||||
|
|
||||||
|
Rectangle(hdc, p.rcPaint.left, p.rcPaint.top,
|
||||||
|
p.rcPaint.right, p.rcPaint.bottom);
|
||||||
|
|
||||||
|
/* SelectClipRgn(hdc, NULL); */
|
||||||
|
|
||||||
|
SelectObject(hdc, oldbrush);
|
||||||
|
DeleteObject(fillcolour);
|
||||||
|
SelectObject(hdc, oldpen);
|
||||||
|
DeleteObject(edge);
|
||||||
}
|
}
|
||||||
|
SelectObject(hdc, GetStockObject(SYSTEM_FONT));
|
||||||
|
SelectObject(hdc, GetStockObject(WHITE_PEN));
|
||||||
|
EndPaint(hwnd, &p);
|
||||||
|
ShowCaret(hwnd);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
case WM_NETEVENT: {
|
||||||
|
/*
|
||||||
|
* To protect against re-entrancy when Windows's recv()
|
||||||
|
* immediately triggers a new WSAAsyncSelect window
|
||||||
|
* message, we don't call select_result directly from this
|
||||||
|
* handler but instead wait until we're back out at the
|
||||||
|
* top level of the message loop.
|
||||||
|
*/
|
||||||
|
struct wm_netevent_params *params =
|
||||||
|
snew(struct wm_netevent_params);
|
||||||
|
params->wParam = wParam;
|
||||||
|
params->lParam = lParam;
|
||||||
|
queue_toplevel_callback(wm_netevent_callback, params);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
case WM_SETFOCUS:
|
case WM_SETFOCUS:
|
||||||
term_set_focus(term, true);
|
term_set_focus(term, true);
|
||||||
CreateCaret(hwnd, caretbm, font_width, font_height);
|
CreateCaret(hwnd, caretbm, font_width, font_height);
|
||||||
@ -3137,21 +3130,20 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
|||||||
term_scroll(term, 0, -term->rows / 2);
|
term_scroll(term, 0, -term->rows / 2);
|
||||||
break;
|
break;
|
||||||
case SB_THUMBPOSITION:
|
case SB_THUMBPOSITION:
|
||||||
case SB_THUMBTRACK:
|
case SB_THUMBTRACK: {
|
||||||
/*
|
/*
|
||||||
* Use GetScrollInfo instead of HIWORD(wParam) to get
|
* Use GetScrollInfo instead of HIWORD(wParam) to get
|
||||||
* 32-bit scroll position.
|
* 32-bit scroll position.
|
||||||
*/
|
*/
|
||||||
{
|
SCROLLINFO si;
|
||||||
SCROLLINFO si;
|
|
||||||
|
|
||||||
si.cbSize = sizeof(si);
|
si.cbSize = sizeof(si);
|
||||||
si.fMask = SIF_TRACKPOS;
|
si.fMask = SIF_TRACKPOS;
|
||||||
if (GetScrollInfo(hwnd, SB_VERT, &si) == 0)
|
if (GetScrollInfo(hwnd, SB_VERT, &si) == 0)
|
||||||
si.nTrackPos = HIWORD(wParam);
|
si.nTrackPos = HIWORD(wParam);
|
||||||
term_scroll(term, 1, si.nTrackPos);
|
term_scroll(term, 1, si.nTrackPos);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WM_PALETTECHANGED:
|
case WM_PALETTECHANGED:
|
||||||
@ -3232,61 +3224,59 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
|||||||
set_input_locale((HKL)lParam);
|
set_input_locale((HKL)lParam);
|
||||||
sys_cursor_update();
|
sys_cursor_update();
|
||||||
break;
|
break;
|
||||||
case WM_IME_STARTCOMPOSITION:
|
case WM_IME_STARTCOMPOSITION: {
|
||||||
{
|
HIMC hImc = ImmGetContext(hwnd);
|
||||||
HIMC hImc = ImmGetContext(hwnd);
|
ImmSetCompositionFont(hImc, &lfont);
|
||||||
ImmSetCompositionFont(hImc, &lfont);
|
ImmReleaseContext(hwnd, hImc);
|
||||||
ImmReleaseContext(hwnd, hImc);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case WM_IME_COMPOSITION:
|
}
|
||||||
{
|
case WM_IME_COMPOSITION: {
|
||||||
HIMC hIMC;
|
HIMC hIMC;
|
||||||
int n;
|
int n;
|
||||||
char *buff;
|
char *buff;
|
||||||
|
|
||||||
if (osPlatformId == VER_PLATFORM_WIN32_WINDOWS ||
|
if (osPlatformId == VER_PLATFORM_WIN32_WINDOWS ||
|
||||||
osPlatformId == VER_PLATFORM_WIN32s)
|
osPlatformId == VER_PLATFORM_WIN32s)
|
||||||
break; /* no Unicode */
|
break; /* no Unicode */
|
||||||
|
|
||||||
if ((lParam & GCS_RESULTSTR) == 0) /* Composition unfinished. */
|
if ((lParam & GCS_RESULTSTR) == 0) /* Composition unfinished. */
|
||||||
break; /* fall back to DefWindowProc */
|
break; /* fall back to DefWindowProc */
|
||||||
|
|
||||||
hIMC = ImmGetContext(hwnd);
|
hIMC = ImmGetContext(hwnd);
|
||||||
n = ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, NULL, 0);
|
n = ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, NULL, 0);
|
||||||
|
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
int i;
|
int i;
|
||||||
buff = snewn(n, char);
|
buff = snewn(n, char);
|
||||||
ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, buff, n);
|
ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, buff, n);
|
||||||
/*
|
/*
|
||||||
* Jaeyoun Chung reports that Korean character
|
* Jaeyoun Chung reports that Korean character
|
||||||
* input doesn't work correctly if we do a single
|
* input doesn't work correctly if we do a single
|
||||||
* term_keyinputw covering the whole of buff. So
|
* term_keyinputw covering the whole of buff. So
|
||||||
* instead we send the characters one by one.
|
* instead we send the characters one by one.
|
||||||
*/
|
*/
|
||||||
/* don't divide SURROGATE PAIR */
|
/* don't divide SURROGATE PAIR */
|
||||||
if (ldisc) {
|
if (ldisc) {
|
||||||
for (i = 0; i < n; i += 2) {
|
for (i = 0; i < n; i += 2) {
|
||||||
WCHAR hs = *(unsigned short *)(buff+i);
|
WCHAR hs = *(unsigned short *)(buff+i);
|
||||||
if (IS_HIGH_SURROGATE(hs) && i+2 < n) {
|
if (IS_HIGH_SURROGATE(hs) && i+2 < n) {
|
||||||
WCHAR ls = *(unsigned short *)(buff+i+2);
|
WCHAR ls = *(unsigned short *)(buff+i+2);
|
||||||
if (IS_LOW_SURROGATE(ls)) {
|
if (IS_LOW_SURROGATE(ls)) {
|
||||||
term_keyinputw(
|
term_keyinputw(
|
||||||
term, (unsigned short *)(buff+i), 2);
|
term, (unsigned short *)(buff+i), 2);
|
||||||
i += 2;
|
i += 2;
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
}
|
|
||||||
term_keyinputw(
|
|
||||||
term, (unsigned short *)(buff+i), 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
free(buff);
|
}
|
||||||
|
term_keyinputw(
|
||||||
|
term, (unsigned short *)(buff+i), 1);
|
||||||
}
|
}
|
||||||
ImmReleaseContext(hwnd, hIMC);
|
}
|
||||||
return 1;
|
free(buff);
|
||||||
}
|
}
|
||||||
|
ImmReleaseContext(hwnd, hIMC);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
case WM_IME_CHAR:
|
case WM_IME_CHAR:
|
||||||
if (wParam & 0xFF00) {
|
if (wParam & 0xFF00) {
|
||||||
|
@ -1624,17 +1624,16 @@ void select_result(WPARAM wParam, LPARAM lParam)
|
|||||||
plug_receive(s->plug, 2, buf, ret);
|
plug_receive(s->plug, 2, buf, ret);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case FD_WRITE:
|
case FD_WRITE: {
|
||||||
{
|
int bufsize_before, bufsize_after;
|
||||||
int bufsize_before, bufsize_after;
|
s->writable = true;
|
||||||
s->writable = true;
|
bufsize_before = s->sending_oob + bufchain_size(&s->output_data);
|
||||||
bufsize_before = s->sending_oob + bufchain_size(&s->output_data);
|
try_send(s);
|
||||||
try_send(s);
|
bufsize_after = s->sending_oob + bufchain_size(&s->output_data);
|
||||||
bufsize_after = s->sending_oob + bufchain_size(&s->output_data);
|
if (bufsize_after < bufsize_before)
|
||||||
if (bufsize_after < bufsize_before)
|
plug_sent(s->plug, bufsize_after);
|
||||||
plug_sent(s->plug, bufsize_after);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case FD_CLOSE:
|
case FD_CLOSE:
|
||||||
/* Signal a close on the socket. First read any outstanding data. */
|
/* Signal a close on the socket. First read any outstanding data. */
|
||||||
do {
|
do {
|
||||||
@ -1652,42 +1651,42 @@ void select_result(WPARAM wParam, LPARAM lParam)
|
|||||||
}
|
}
|
||||||
} while (ret > 0);
|
} while (ret > 0);
|
||||||
return;
|
return;
|
||||||
case FD_ACCEPT:
|
case FD_ACCEPT: {
|
||||||
{
|
|
||||||
#ifdef NO_IPV6
|
#ifdef NO_IPV6
|
||||||
struct sockaddr_in isa;
|
struct sockaddr_in isa;
|
||||||
#else
|
#else
|
||||||
struct sockaddr_storage isa;
|
struct sockaddr_storage isa;
|
||||||
#endif
|
#endif
|
||||||
int addrlen = sizeof(isa);
|
int addrlen = sizeof(isa);
|
||||||
SOCKET t; /* socket of connection */
|
SOCKET t; /* socket of connection */
|
||||||
accept_ctx_t actx;
|
accept_ctx_t actx;
|
||||||
|
|
||||||
memset(&isa, 0, sizeof(isa));
|
memset(&isa, 0, sizeof(isa));
|
||||||
err = 0;
|
err = 0;
|
||||||
t = p_accept(s->s,(struct sockaddr *)&isa,&addrlen);
|
t = p_accept(s->s,(struct sockaddr *)&isa,&addrlen);
|
||||||
if (t == INVALID_SOCKET)
|
if (t == INVALID_SOCKET)
|
||||||
{
|
{
|
||||||
err = p_WSAGetLastError();
|
err = p_WSAGetLastError();
|
||||||
if (err == WSATRY_AGAIN)
|
if (err == WSATRY_AGAIN)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
actx.p = (void *)t;
|
actx.p = (void *)t;
|
||||||
|
|
||||||
#ifndef NO_IPV6
|
#ifndef NO_IPV6
|
||||||
if (isa.ss_family == AF_INET &&
|
if (isa.ss_family == AF_INET &&
|
||||||
s->localhost_only &&
|
s->localhost_only &&
|
||||||
!ipv4_is_local_addr(((struct sockaddr_in *)&isa)->sin_addr))
|
!ipv4_is_local_addr(((struct sockaddr_in *)&isa)->sin_addr))
|
||||||
#else
|
#else
|
||||||
if (s->localhost_only && !ipv4_is_local_addr(isa.sin_addr))
|
if (s->localhost_only && !ipv4_is_local_addr(isa.sin_addr))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
p_closesocket(t); /* dodgy WinSock let nonlocal through */
|
p_closesocket(t); /* dodgy WinSock let nonlocal through */
|
||||||
} else if (plug_accepting(s->plug, sk_net_accept, actx)) {
|
} else if (plug_accepting(s->plug, sk_net_accept, actx)) {
|
||||||
p_closesocket(t); /* denied or error */
|
p_closesocket(t); /* denied or error */
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,20 +100,19 @@ static void progress_update(void *param, int action, int phase, int iprogress)
|
|||||||
case PROGFN_PHASE_EXTENT:
|
case PROGFN_PHASE_EXTENT:
|
||||||
p->phases[phase-1].total = progress;
|
p->phases[phase-1].total = progress;
|
||||||
break;
|
break;
|
||||||
case PROGFN_READY:
|
case PROGFN_READY: {
|
||||||
{
|
unsigned total = 0;
|
||||||
unsigned total = 0;
|
int i;
|
||||||
int i;
|
for (i = 0; i < p->nphases; i++) {
|
||||||
for (i = 0; i < p->nphases; i++) {
|
p->phases[i].startpoint = total;
|
||||||
p->phases[i].startpoint = total;
|
total += p->phases[i].total;
|
||||||
total += p->phases[i].total;
|
|
||||||
}
|
|
||||||
p->total = total;
|
|
||||||
p->divisor = ((p->total + PROGRESSRANGE - 1) / PROGRESSRANGE);
|
|
||||||
p->range = p->total / p->divisor;
|
|
||||||
SendMessage(p->progbar, PBM_SETRANGE, 0, MAKELPARAM(0, p->range));
|
|
||||||
}
|
}
|
||||||
|
p->total = total;
|
||||||
|
p->divisor = ((p->total + PROGRESSRANGE - 1) / PROGRESSRANGE);
|
||||||
|
p->range = p->total / p->divisor;
|
||||||
|
SendMessage(p->progbar, PBM_SETRANGE, 0, MAKELPARAM(0, p->range));
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case PROGFN_PROGRESS:
|
case PROGFN_PROGRESS:
|
||||||
if (p->phases[phase-1].exponential) {
|
if (p->phases[phase-1].exponential) {
|
||||||
while (p->phases[phase-1].n < progress) {
|
while (p->phases[phase-1].n < progress) {
|
||||||
@ -236,24 +235,23 @@ static INT_PTR CALLBACK LicenceProc(HWND hwnd, UINT msg,
|
|||||||
WPARAM wParam, LPARAM lParam)
|
WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG: {
|
||||||
/*
|
/*
|
||||||
* Centre the window.
|
* Centre the window.
|
||||||
*/
|
*/
|
||||||
{ /* centre the window */
|
RECT rs, rd;
|
||||||
RECT rs, rd;
|
HWND hw;
|
||||||
HWND hw;
|
|
||||||
|
|
||||||
hw = GetDesktopWindow();
|
hw = GetDesktopWindow();
|
||||||
if (GetWindowRect(hw, &rs) && GetWindowRect(hwnd, &rd))
|
if (GetWindowRect(hw, &rs) && GetWindowRect(hwnd, &rd))
|
||||||
MoveWindow(hwnd,
|
MoveWindow(hwnd,
|
||||||
(rs.right + rs.left + rd.left - rd.right) / 2,
|
(rs.right + rs.left + rd.left - rd.right) / 2,
|
||||||
(rs.bottom + rs.top + rd.top - rd.bottom) / 2,
|
(rs.bottom + rs.top + rd.top - rd.bottom) / 2,
|
||||||
rd.right - rd.left, rd.bottom - rd.top, true);
|
rd.right - rd.left, rd.bottom - rd.top, true);
|
||||||
}
|
|
||||||
|
|
||||||
SetDlgItemText(hwnd, 1000, LICENCE_TEXT("\r\n\r\n"));
|
SetDlgItemText(hwnd, 1000, LICENCE_TEXT("\r\n\r\n"));
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
switch (LOWORD(wParam)) {
|
switch (LOWORD(wParam)) {
|
||||||
case IDOK:
|
case IDOK:
|
||||||
@ -1057,13 +1055,12 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg,
|
|||||||
case IDC_KEYSSH2RSA:
|
case IDC_KEYSSH2RSA:
|
||||||
case IDC_KEYSSH2DSA:
|
case IDC_KEYSSH2DSA:
|
||||||
case IDC_KEYSSH2ECDSA:
|
case IDC_KEYSSH2ECDSA:
|
||||||
case IDC_KEYSSH2ED25519:
|
case IDC_KEYSSH2ED25519: {
|
||||||
{
|
state = (struct MainDlgState *)
|
||||||
state = (struct MainDlgState *)
|
GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
||||||
GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
ui_set_key_type(hwnd, state, LOWORD(wParam));
|
||||||
ui_set_key_type(hwnd, state, LOWORD(wParam));
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case IDC_QUIT:
|
case IDC_QUIT:
|
||||||
PostMessage(hwnd, WM_CLOSE, 0, 0);
|
PostMessage(hwnd, WM_CLOSE, 0, 0);
|
||||||
break;
|
break;
|
||||||
@ -1478,61 +1475,60 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg,
|
|||||||
*/
|
*/
|
||||||
ui_set_state(hwnd, state, 2);
|
ui_set_state(hwnd, state, 2);
|
||||||
break;
|
break;
|
||||||
case WM_HELP:
|
case WM_HELP: {
|
||||||
{
|
int id = ((LPHELPINFO)lParam)->iCtrlId;
|
||||||
int id = ((LPHELPINFO)lParam)->iCtrlId;
|
const char *topic = NULL;
|
||||||
const char *topic = NULL;
|
switch (id) {
|
||||||
switch (id) {
|
case IDC_GENERATING:
|
||||||
case IDC_GENERATING:
|
case IDC_PROGRESS:
|
||||||
case IDC_PROGRESS:
|
case IDC_GENSTATIC:
|
||||||
case IDC_GENSTATIC:
|
case IDC_GENERATE:
|
||||||
case IDC_GENERATE:
|
topic = WINHELP_CTX_puttygen_generate; break;
|
||||||
topic = WINHELP_CTX_puttygen_generate; break;
|
case IDC_PKSTATIC:
|
||||||
case IDC_PKSTATIC:
|
case IDC_KEYDISPLAY:
|
||||||
case IDC_KEYDISPLAY:
|
topic = WINHELP_CTX_puttygen_pastekey; break;
|
||||||
topic = WINHELP_CTX_puttygen_pastekey; break;
|
case IDC_FPSTATIC:
|
||||||
case IDC_FPSTATIC:
|
case IDC_FINGERPRINT:
|
||||||
case IDC_FINGERPRINT:
|
topic = WINHELP_CTX_puttygen_fingerprint; break;
|
||||||
topic = WINHELP_CTX_puttygen_fingerprint; break;
|
case IDC_COMMENTSTATIC:
|
||||||
case IDC_COMMENTSTATIC:
|
case IDC_COMMENTEDIT:
|
||||||
case IDC_COMMENTEDIT:
|
topic = WINHELP_CTX_puttygen_comment; break;
|
||||||
topic = WINHELP_CTX_puttygen_comment; break;
|
case IDC_PASSPHRASE1STATIC:
|
||||||
case IDC_PASSPHRASE1STATIC:
|
case IDC_PASSPHRASE1EDIT:
|
||||||
case IDC_PASSPHRASE1EDIT:
|
case IDC_PASSPHRASE2STATIC:
|
||||||
case IDC_PASSPHRASE2STATIC:
|
case IDC_PASSPHRASE2EDIT:
|
||||||
case IDC_PASSPHRASE2EDIT:
|
topic = WINHELP_CTX_puttygen_passphrase; break;
|
||||||
topic = WINHELP_CTX_puttygen_passphrase; break;
|
case IDC_LOADSTATIC:
|
||||||
case IDC_LOADSTATIC:
|
case IDC_LOAD:
|
||||||
case IDC_LOAD:
|
topic = WINHELP_CTX_puttygen_load; break;
|
||||||
topic = WINHELP_CTX_puttygen_load; break;
|
case IDC_SAVESTATIC:
|
||||||
case IDC_SAVESTATIC:
|
case IDC_SAVE:
|
||||||
case IDC_SAVE:
|
topic = WINHELP_CTX_puttygen_savepriv; break;
|
||||||
topic = WINHELP_CTX_puttygen_savepriv; break;
|
case IDC_SAVEPUB:
|
||||||
case IDC_SAVEPUB:
|
topic = WINHELP_CTX_puttygen_savepub; break;
|
||||||
topic = WINHELP_CTX_puttygen_savepub; break;
|
case IDC_TYPESTATIC:
|
||||||
case IDC_TYPESTATIC:
|
case IDC_KEYSSH1:
|
||||||
case IDC_KEYSSH1:
|
case IDC_KEYSSH2RSA:
|
||||||
case IDC_KEYSSH2RSA:
|
case IDC_KEYSSH2DSA:
|
||||||
case IDC_KEYSSH2DSA:
|
case IDC_KEYSSH2ECDSA:
|
||||||
case IDC_KEYSSH2ECDSA:
|
case IDC_KEYSSH2ED25519:
|
||||||
case IDC_KEYSSH2ED25519:
|
topic = WINHELP_CTX_puttygen_keytype; break;
|
||||||
topic = WINHELP_CTX_puttygen_keytype; break;
|
case IDC_BITSSTATIC:
|
||||||
case IDC_BITSSTATIC:
|
case IDC_BITS:
|
||||||
case IDC_BITS:
|
topic = WINHELP_CTX_puttygen_bits; break;
|
||||||
topic = WINHELP_CTX_puttygen_bits; break;
|
case IDC_IMPORT:
|
||||||
case IDC_IMPORT:
|
case IDC_EXPORT_OPENSSH_AUTO:
|
||||||
case IDC_EXPORT_OPENSSH_AUTO:
|
case IDC_EXPORT_OPENSSH_NEW:
|
||||||
case IDC_EXPORT_OPENSSH_NEW:
|
case IDC_EXPORT_SSHCOM:
|
||||||
case IDC_EXPORT_SSHCOM:
|
topic = WINHELP_CTX_puttygen_conversions; break;
|
||||||
topic = WINHELP_CTX_puttygen_conversions; break;
|
}
|
||||||
}
|
if (topic) {
|
||||||
if (topic) {
|
launch_help(hwnd, topic);
|
||||||
launch_help(hwnd, topic);
|
} else {
|
||||||
} else {
|
MessageBeep(0);
|
||||||
MessageBeep(0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
state = (struct MainDlgState *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
state = (struct MainDlgState *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
||||||
sfree(state);
|
sfree(state);
|
||||||
|
@ -133,18 +133,17 @@ static INT_PTR CALLBACK AboutProc(HWND hwnd, UINT msg,
|
|||||||
WPARAM wParam, LPARAM lParam)
|
WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG: {
|
||||||
{
|
char *buildinfo_text = buildinfo("\r\n");
|
||||||
char *buildinfo_text = buildinfo("\r\n");
|
char *text = dupprintf
|
||||||
char *text = dupprintf
|
("Pageant\r\n\r\n%s\r\n\r\n%s\r\n\r\n%s",
|
||||||
("Pageant\r\n\r\n%s\r\n\r\n%s\r\n\r\n%s",
|
ver, buildinfo_text,
|
||||||
ver, buildinfo_text,
|
"\251 " SHORT_COPYRIGHT_DETAILS ". All rights reserved.");
|
||||||
"\251 " SHORT_COPYRIGHT_DETAILS ". All rights reserved.");
|
sfree(buildinfo_text);
|
||||||
sfree(buildinfo_text);
|
SetDlgItemText(hwnd, 1000, text);
|
||||||
SetDlgItemText(hwnd, 1000, text);
|
sfree(text);
|
||||||
sfree(text);
|
|
||||||
}
|
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
switch (LOWORD(wParam)) {
|
switch (LOWORD(wParam)) {
|
||||||
case IDOK:
|
case IDOK:
|
||||||
@ -186,22 +185,20 @@ static INT_PTR CALLBACK PassphraseProc(HWND hwnd, UINT msg,
|
|||||||
struct PassphraseProcStruct *p;
|
struct PassphraseProcStruct *p;
|
||||||
|
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG: {
|
||||||
passphrase_box = hwnd;
|
passphrase_box = hwnd;
|
||||||
/*
|
/*
|
||||||
* Centre the window.
|
* Centre the window.
|
||||||
*/
|
*/
|
||||||
{ /* centre the window */
|
RECT rs, rd;
|
||||||
RECT rs, rd;
|
HWND hw;
|
||||||
HWND hw;
|
|
||||||
|
|
||||||
hw = GetDesktopWindow();
|
hw = GetDesktopWindow();
|
||||||
if (GetWindowRect(hw, &rs) && GetWindowRect(hwnd, &rd))
|
if (GetWindowRect(hw, &rs) && GetWindowRect(hwnd, &rd))
|
||||||
MoveWindow(hwnd,
|
MoveWindow(hwnd,
|
||||||
(rs.right + rs.left + rd.left - rd.right) / 2,
|
(rs.right + rs.left + rd.left - rd.right) / 2,
|
||||||
(rs.bottom + rs.top + rd.top - rd.bottom) / 2,
|
(rs.bottom + rs.top + rd.top - rd.bottom) / 2,
|
||||||
rd.right - rd.left, rd.bottom - rd.top, true);
|
rd.right - rd.left, rd.bottom - rd.top, true);
|
||||||
}
|
|
||||||
|
|
||||||
SetForegroundWindow(hwnd);
|
SetForegroundWindow(hwnd);
|
||||||
SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0,
|
SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0,
|
||||||
@ -214,6 +211,7 @@ static INT_PTR CALLBACK PassphraseProc(HWND hwnd, UINT msg,
|
|||||||
*passphrase = dupstr("");
|
*passphrase = dupstr("");
|
||||||
SetDlgItemText(hwnd, 102, *passphrase);
|
SetDlgItemText(hwnd, 102, *passphrase);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
switch (LOWORD(wParam)) {
|
switch (LOWORD(wParam)) {
|
||||||
case IDOK:
|
case IDOK:
|
||||||
@ -485,41 +483,40 @@ static INT_PTR CALLBACK KeyListProc(HWND hwnd, UINT msg,
|
|||||||
ssh2_userkey *skey;
|
ssh2_userkey *skey;
|
||||||
|
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG: {
|
||||||
/*
|
/*
|
||||||
* Centre the window.
|
* Centre the window.
|
||||||
*/
|
*/
|
||||||
{ /* centre the window */
|
RECT rs, rd;
|
||||||
RECT rs, rd;
|
HWND hw;
|
||||||
HWND hw;
|
|
||||||
|
|
||||||
hw = GetDesktopWindow();
|
hw = GetDesktopWindow();
|
||||||
if (GetWindowRect(hw, &rs) && GetWindowRect(hwnd, &rd))
|
if (GetWindowRect(hw, &rs) && GetWindowRect(hwnd, &rd))
|
||||||
MoveWindow(hwnd,
|
MoveWindow(hwnd,
|
||||||
(rs.right + rs.left + rd.left - rd.right) / 2,
|
(rs.right + rs.left + rd.left - rd.right) / 2,
|
||||||
(rs.bottom + rs.top + rd.top - rd.bottom) / 2,
|
(rs.bottom + rs.top + rd.top - rd.bottom) / 2,
|
||||||
rd.right - rd.left, rd.bottom - rd.top, true);
|
rd.right - rd.left, rd.bottom - rd.top, true);
|
||||||
}
|
|
||||||
|
|
||||||
if (has_help())
|
if (has_help())
|
||||||
SetWindowLongPtr(hwnd, GWL_EXSTYLE,
|
SetWindowLongPtr(hwnd, GWL_EXSTYLE,
|
||||||
GetWindowLongPtr(hwnd, GWL_EXSTYLE) |
|
GetWindowLongPtr(hwnd, GWL_EXSTYLE) |
|
||||||
WS_EX_CONTEXTHELP);
|
WS_EX_CONTEXTHELP);
|
||||||
else {
|
else {
|
||||||
HWND item = GetDlgItem(hwnd, 103); /* the Help button */
|
HWND item = GetDlgItem(hwnd, 103); /* the Help button */
|
||||||
if (item)
|
if (item)
|
||||||
DestroyWindow(item);
|
DestroyWindow(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
keylist = hwnd;
|
keylist = hwnd;
|
||||||
{
|
{
|
||||||
static int tabs[] = { 35, 75, 250 };
|
static int tabs[] = { 35, 75, 250 };
|
||||||
SendDlgItemMessage(hwnd, 100, LB_SETTABSTOPS,
|
SendDlgItemMessage(hwnd, 100, LB_SETTABSTOPS,
|
||||||
sizeof(tabs) / sizeof(*tabs),
|
sizeof(tabs) / sizeof(*tabs),
|
||||||
(LPARAM) tabs);
|
(LPARAM) tabs);
|
||||||
}
|
}
|
||||||
keylist_update();
|
keylist_update();
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
switch (LOWORD(wParam)) {
|
switch (LOWORD(wParam)) {
|
||||||
case IDOK:
|
case IDOK:
|
||||||
@ -607,22 +604,21 @@ static INT_PTR CALLBACK KeyListProc(HWND hwnd, UINT msg,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
case WM_HELP:
|
case WM_HELP: {
|
||||||
{
|
int id = ((LPHELPINFO)lParam)->iCtrlId;
|
||||||
int id = ((LPHELPINFO)lParam)->iCtrlId;
|
const char *topic = NULL;
|
||||||
const char *topic = NULL;
|
switch (id) {
|
||||||
switch (id) {
|
case 100: topic = WINHELP_CTX_pageant_keylist; break;
|
||||||
case 100: topic = WINHELP_CTX_pageant_keylist; break;
|
case 101: topic = WINHELP_CTX_pageant_addkey; break;
|
||||||
case 101: topic = WINHELP_CTX_pageant_addkey; break;
|
case 102: topic = WINHELP_CTX_pageant_remkey; break;
|
||||||
case 102: topic = WINHELP_CTX_pageant_remkey; break;
|
}
|
||||||
}
|
if (topic) {
|
||||||
if (topic) {
|
launch_help(hwnd, topic);
|
||||||
launch_help(hwnd, topic);
|
} else {
|
||||||
} else {
|
MessageBeep(0);
|
||||||
MessageBeep(0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
keylist = NULL;
|
keylist = NULL;
|
||||||
DestroyWindow(hwnd);
|
DestroyWindow(hwnd);
|
||||||
@ -1007,20 +1003,19 @@ static LRESULT CALLBACK TrayWndProc(HWND hwnd, UINT message,
|
|||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
case WM_SYSCOMMAND:
|
case WM_SYSCOMMAND:
|
||||||
switch (wParam & ~0xF) { /* low 4 bits reserved to Windows */
|
switch (wParam & ~0xF) { /* low 4 bits reserved to Windows */
|
||||||
case IDM_PUTTY:
|
case IDM_PUTTY: {
|
||||||
{
|
TCHAR cmdline[10];
|
||||||
TCHAR cmdline[10];
|
cmdline[0] = '\0';
|
||||||
cmdline[0] = '\0';
|
if (restrict_putty_acl)
|
||||||
if (restrict_putty_acl)
|
strcat(cmdline, "&R");
|
||||||
strcat(cmdline, "&R");
|
|
||||||
|
|
||||||
if((INT_PTR)ShellExecute(hwnd, NULL, putty_path, cmdline,
|
if((INT_PTR)ShellExecute(hwnd, NULL, putty_path, cmdline,
|
||||||
_T(""), SW_SHOW) <= 32) {
|
_T(""), SW_SHOW) <= 32) {
|
||||||
MessageBox(NULL, "Unable to execute PuTTY!",
|
MessageBox(NULL, "Unable to execute PuTTY!",
|
||||||
"Error", MB_OK | MB_ICONERROR);
|
"Error", MB_OK | MB_ICONERROR);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case IDM_CLOSE:
|
case IDM_CLOSE:
|
||||||
if (passphrase_box)
|
if (passphrase_box)
|
||||||
SendMessage(passphrase_box, WM_CLOSE, 0, 0);
|
SendMessage(passphrase_box, WM_CLOSE, 0, 0);
|
||||||
@ -1068,31 +1063,30 @@ static LRESULT CALLBACK TrayWndProc(HWND hwnd, UINT message,
|
|||||||
case IDM_HELP:
|
case IDM_HELP:
|
||||||
launch_help(hwnd, WINHELP_CTX_pageant_general);
|
launch_help(hwnd, WINHELP_CTX_pageant_general);
|
||||||
break;
|
break;
|
||||||
default:
|
default: {
|
||||||
{
|
if(wParam >= IDM_SESSIONS_BASE && wParam <= IDM_SESSIONS_MAX) {
|
||||||
if(wParam >= IDM_SESSIONS_BASE && wParam <= IDM_SESSIONS_MAX) {
|
MENUITEMINFO mii;
|
||||||
MENUITEMINFO mii;
|
TCHAR buf[MAX_PATH + 1];
|
||||||
TCHAR buf[MAX_PATH + 1];
|
TCHAR param[MAX_PATH + 1];
|
||||||
TCHAR param[MAX_PATH + 1];
|
memset(&mii, 0, sizeof(mii));
|
||||||
memset(&mii, 0, sizeof(mii));
|
mii.cbSize = sizeof(mii);
|
||||||
mii.cbSize = sizeof(mii);
|
mii.fMask = MIIM_TYPE;
|
||||||
mii.fMask = MIIM_TYPE;
|
mii.cch = MAX_PATH;
|
||||||
mii.cch = MAX_PATH;
|
mii.dwTypeData = buf;
|
||||||
mii.dwTypeData = buf;
|
GetMenuItemInfo(session_menu, wParam, false, &mii);
|
||||||
GetMenuItemInfo(session_menu, wParam, false, &mii);
|
param[0] = '\0';
|
||||||
param[0] = '\0';
|
if (restrict_putty_acl)
|
||||||
if (restrict_putty_acl)
|
strcat(param, "&R");
|
||||||
strcat(param, "&R");
|
strcat(param, "@");
|
||||||
strcat(param, "@");
|
strcat(param, mii.dwTypeData);
|
||||||
strcat(param, mii.dwTypeData);
|
if((INT_PTR)ShellExecute(hwnd, NULL, putty_path, param,
|
||||||
if((INT_PTR)ShellExecute(hwnd, NULL, putty_path, param,
|
_T(""), SW_SHOW) <= 32) {
|
||||||
_T(""), SW_SHOW) <= 32) {
|
MessageBox(NULL, "Unable to execute PuTTY!", "Error",
|
||||||
MessageBox(NULL, "Unable to execute PuTTY!", "Error",
|
MB_OK | MB_ICONERROR);
|
||||||
MB_OK | MB_ICONERROR);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
@ -1108,27 +1102,26 @@ static LRESULT CALLBACK wm_copydata_WndProc(HWND hwnd, UINT message,
|
|||||||
WPARAM wParam, LPARAM lParam)
|
WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch (message) {
|
switch (message) {
|
||||||
case WM_COPYDATA:
|
case WM_COPYDATA: {
|
||||||
{
|
COPYDATASTRUCT *cds;
|
||||||
COPYDATASTRUCT *cds;
|
char *mapname, *err;
|
||||||
char *mapname, *err;
|
|
||||||
|
|
||||||
cds = (COPYDATASTRUCT *) lParam;
|
cds = (COPYDATASTRUCT *) lParam;
|
||||||
if (cds->dwData != AGENT_COPYDATA_ID)
|
if (cds->dwData != AGENT_COPYDATA_ID)
|
||||||
return 0; /* not our message, mate */
|
return 0; /* not our message, mate */
|
||||||
mapname = (char *) cds->lpData;
|
mapname = (char *) cds->lpData;
|
||||||
if (mapname[cds->cbData - 1] != '\0')
|
if (mapname[cds->cbData - 1] != '\0')
|
||||||
return 0; /* failure to be ASCIZ! */
|
return 0; /* failure to be ASCIZ! */
|
||||||
err = answer_filemapping_message(mapname);
|
err = answer_filemapping_message(mapname);
|
||||||
if (err) {
|
if (err) {
|
||||||
#ifdef DEBUG_IPC
|
#ifdef DEBUG_IPC
|
||||||
debug("IPC failed: %s\n", err);
|
debug("IPC failed: %s\n", err);
|
||||||
#endif
|
#endif
|
||||||
sfree(err);
|
sfree(err);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return DefWindowProc(hwnd, message, wParam, lParam);
|
return DefWindowProc(hwnd, message, wParam, lParam);
|
||||||
|
Loading…
Reference in New Issue
Block a user