comment fixes
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3570 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
bd6e968506
commit
561db3a7c4
78
src/winio.c
78
src/winio.c
|
@ -30,10 +30,10 @@
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
static int *key_buffer = NULL;
|
static int *key_buffer = NULL;
|
||||||
/* The default keystroke buffer, containing all the keystrokes
|
/* The keystroke buffer, containing all the keystrokes we have
|
||||||
* we have at a given point. */
|
* at a given point. */
|
||||||
static size_t key_buffer_len = 0;
|
static size_t key_buffer_len = 0;
|
||||||
/* The length of the default keystroke buffer. */
|
/* The length of the keystroke buffer. */
|
||||||
static int statusblank = 0;
|
static int statusblank = 0;
|
||||||
/* The number of keystrokes left after we call statusbar(),
|
/* The number of keystrokes left after we call statusbar(),
|
||||||
* before we actually blank the statusbar. */
|
* before we actually blank the statusbar. */
|
||||||
|
@ -104,8 +104,8 @@ static bool disable_cursorpos = FALSE;
|
||||||
* be the Begin key. */
|
* be the Begin key. */
|
||||||
|
|
||||||
/* Read in a sequence of keystrokes from win and save them in the
|
/* Read in a sequence of keystrokes from win and save them in the
|
||||||
* default keystroke buffer. This should only be called when the
|
* keystroke buffer. This should only be called when the keystroke
|
||||||
* default keystroke buffer is empty. */
|
* buffer is empty. */
|
||||||
void get_key_buffer(WINDOW *win)
|
void get_key_buffer(WINDOW *win)
|
||||||
{
|
{
|
||||||
int input;
|
int input;
|
||||||
|
@ -184,14 +184,13 @@ void get_key_buffer(WINDOW *win)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the length of the default keystroke buffer. */
|
/* Return the length of the keystroke buffer. */
|
||||||
size_t get_key_buffer_len(void)
|
size_t get_key_buffer_len(void)
|
||||||
{
|
{
|
||||||
return key_buffer_len;
|
return key_buffer_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add the contents of the keystroke buffer input to the default
|
/* Add the keystrokes in input to the keystroke buffer. */
|
||||||
* keystroke buffer. */
|
|
||||||
void unget_input(int *input, size_t input_len)
|
void unget_input(int *input, size_t input_len)
|
||||||
{
|
{
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
|
@ -203,27 +202,26 @@ void unget_input(int *input, size_t input_len)
|
||||||
if (input_len == 0)
|
if (input_len == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* If adding input would put the default keystroke buffer beyond
|
/* If adding input would put the keystroke buffer beyond maximum
|
||||||
* maximum capacity, only add enough of input to put it at maximum
|
* capacity, only add enough of input to put it at maximum
|
||||||
* capacity. */
|
* capacity. */
|
||||||
if (key_buffer_len + input_len < key_buffer_len)
|
if (key_buffer_len + input_len < key_buffer_len)
|
||||||
input_len = (size_t)-1 - key_buffer_len;
|
input_len = (size_t)-1 - key_buffer_len;
|
||||||
|
|
||||||
/* Add the length of input to the length of the default keystroke
|
/* Add the length of input to the length of the keystroke buffer,
|
||||||
* buffer, and reallocate the default keystroke buffer so that it
|
* and reallocate the keystroke buffer so that it has enough room
|
||||||
* has enough room for input. */
|
* for input. */
|
||||||
key_buffer_len += input_len;
|
key_buffer_len += input_len;
|
||||||
key_buffer = (int *)nrealloc(key_buffer, key_buffer_len *
|
key_buffer = (int *)nrealloc(key_buffer, key_buffer_len *
|
||||||
sizeof(int));
|
sizeof(int));
|
||||||
|
|
||||||
/* If the default keystroke buffer wasn't empty before, move its
|
/* If the keystroke buffer wasn't empty before, move its beginning
|
||||||
* beginning forward far enough so that we can add input to its
|
* forward far enough so that we can add input to its beginning. */
|
||||||
* beginning. */
|
|
||||||
if (key_buffer_len > input_len)
|
if (key_buffer_len > input_len)
|
||||||
memmove(key_buffer + input_len, key_buffer,
|
memmove(key_buffer + input_len, key_buffer,
|
||||||
(key_buffer_len - input_len) * sizeof(int));
|
(key_buffer_len - input_len) * sizeof(int));
|
||||||
|
|
||||||
/* Copy input to the beginning of the default keystroke buffer. */
|
/* Copy input to the beginning of the keystroke buffer. */
|
||||||
memcpy(key_buffer, input, input_len * sizeof(int));
|
memcpy(key_buffer, input, input_len * sizeof(int));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,11 +242,11 @@ void unget_kbinput(int kbinput, bool meta_key, bool func_key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try to read input_len characters from the default keystroke buffer.
|
/* Try to read input_len characters from the keystroke buffer. If the
|
||||||
* If the default keystroke buffer is empty and win isn't NULL, try to
|
* keystroke buffer is empty and win isn't NULL, try to read in more
|
||||||
* read in more characters from win and add them to the default
|
* characters from win and add them to the keystroke buffer before doing
|
||||||
* keystroke buffer before doing anything else. If the default
|
* anything else. If the keystroke buffer is empty and win is NULL,
|
||||||
* keystroke buffer is empty and win is NULL, return NULL. */
|
* return NULL. */
|
||||||
int *get_input(WINDOW *win, size_t input_len)
|
int *get_input(WINDOW *win, size_t input_len)
|
||||||
{
|
{
|
||||||
int *input;
|
int *input;
|
||||||
|
@ -266,29 +264,28 @@ int *get_input(WINDOW *win, size_t input_len)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If input_len is greater than the length of the default keystroke
|
/* If input_len is greater than the length of the keystroke buffer,
|
||||||
* buffer, only read the number of characters in the default
|
* only read the number of characters in the keystroke buffer. */
|
||||||
* keystroke buffer. */
|
|
||||||
if (input_len > key_buffer_len)
|
if (input_len > key_buffer_len)
|
||||||
input_len = key_buffer_len;
|
input_len = key_buffer_len;
|
||||||
|
|
||||||
/* Subtract input_len from the length of the default keystroke
|
/* Subtract input_len from the length of the keystroke buffer, and
|
||||||
* buffer, and allocate the keystroke buffer input so that it
|
* allocate input so that it has enough room for input_len
|
||||||
* has enough room for input_len keystrokes. */
|
* keystrokes. */
|
||||||
key_buffer_len -= input_len;
|
key_buffer_len -= input_len;
|
||||||
input = (int *)nmalloc(input_len * sizeof(int));
|
input = (int *)nmalloc(input_len * sizeof(int));
|
||||||
|
|
||||||
/* Copy input_len characters from the beginning of the default
|
/* Copy input_len keystrokes from the beginning of the keystroke
|
||||||
* keystroke buffer into input. */
|
* buffer into input. */
|
||||||
memcpy(input, key_buffer, input_len * sizeof(int));
|
memcpy(input, key_buffer, input_len * sizeof(int));
|
||||||
|
|
||||||
/* If the default keystroke buffer is empty, mark it as such. */
|
/* If the keystroke buffer is empty, mark it as such. */
|
||||||
if (key_buffer_len == 0) {
|
if (key_buffer_len == 0) {
|
||||||
free(key_buffer);
|
free(key_buffer);
|
||||||
key_buffer = NULL;
|
key_buffer = NULL;
|
||||||
/* If the default keystroke buffer isn't empty, move its
|
/* If the keystroke buffer isn't empty, move its beginning forward
|
||||||
* beginning forward far enough so that the keystrokes in input are
|
* far enough so that the keystrokes in input are no longer at its
|
||||||
* no longer at its beginning. */
|
* beginning. */
|
||||||
} else {
|
} else {
|
||||||
memmove(key_buffer, key_buffer + input_len, key_buffer_len *
|
memmove(key_buffer, key_buffer + input_len, key_buffer_len *
|
||||||
sizeof(int));
|
sizeof(int));
|
||||||
|
@ -1221,7 +1218,7 @@ int get_byte_kbinput(int kbinput)
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
/* Three digits: add the digit we got to the 1's position of
|
/* Three digits: add the digit we got to the 1's position of
|
||||||
* the byte sequence holder, and save the corresponding word
|
* the byte sequence holder, and save the corresponding byte
|
||||||
* value as the result. */
|
* value as the result. */
|
||||||
if (('0' <= kbinput && kbinput <= '5') || (byte < 250 &&
|
if (('0' <= kbinput && kbinput <= '5') || (byte < 250 &&
|
||||||
'6' <= kbinput && kbinput <= '9')) {
|
'6' <= kbinput && kbinput <= '9')) {
|
||||||
|
@ -1229,7 +1226,7 @@ int get_byte_kbinput(int kbinput)
|
||||||
retval = byte;
|
retval = byte;
|
||||||
} else
|
} else
|
||||||
/* If the character we got isn't a decimal digit, or if
|
/* If the character we got isn't a decimal digit, or if
|
||||||
* it is and it would put the byte sequence out of word
|
* it is and it would put the byte sequence out of byte
|
||||||
* range, save it as the result. */
|
* range, save it as the result. */
|
||||||
retval = kbinput;
|
retval = kbinput;
|
||||||
break;
|
break;
|
||||||
|
@ -1412,9 +1409,8 @@ int get_control_kbinput(int kbinput)
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Put the output-formatted characters in output back into the default
|
/* Put the output-formatted characters in output back into the keystroke
|
||||||
* keystroke buffer, so that they can be parsed and displayed as output
|
* buffer, so that they can be parsed and displayed as output again. */
|
||||||
* again. */
|
|
||||||
void unparse_kbinput(char *output, size_t output_len)
|
void unparse_kbinput(char *output, size_t output_len)
|
||||||
{
|
{
|
||||||
int *input;
|
int *input;
|
||||||
|
@ -1476,8 +1472,8 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *kbinput_len)
|
||||||
* first keystroke. */
|
* first keystroke. */
|
||||||
if (uni != ERR)
|
if (uni != ERR)
|
||||||
unget_input(kbinput, 1);
|
unget_input(kbinput, 1);
|
||||||
/* Otherwise, read in keystrokes until we have a complete word
|
/* Otherwise, read in keystrokes until we have a complete Unicode
|
||||||
* sequence, and put back the corresponding word value. */
|
* sequence, and put back the corresponding Unicode value. */
|
||||||
else {
|
else {
|
||||||
char *uni_mb;
|
char *uni_mb;
|
||||||
int uni_mb_len, *seq, i;
|
int uni_mb_len, *seq, i;
|
||||||
|
|
Loading…
Reference in New Issue