commit bc6645f753d38f4a9525e1ba16ec2af6ef057da9
parent c1ca578853f202a7bdd00e6d091ad1b84717733a
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Thu, 19 Mar 2020 15:08:07 +0100
tweaks: move two functions to before the ones that call them
Diffstat:
M | src/global.c | | | 90 | ++++++++++++++++++++++++++++++++++++++++---------------------------------------- |
M | src/text.c | | | 26 | +++++++++++++------------- |
2 files changed, 58 insertions(+), 58 deletions(-)
diff --git a/src/global.c b/src/global.c
@@ -366,6 +366,51 @@ void add_to_funcs(void (*func)(void), int menus, const char *desc,
#endif
}
+/* Parse the given keystring and return the corresponding keycode,
+ * or return -1 when the string is invalid. */
+int keycode_from_string(const char *keystring)
+{
+ if (keystring[0] == '^') {
+ if (keystring[2] == '\0') {
+ if (keystring[1] == '/')
+ return 31;
+ if (keystring[1] <= '_')
+ return keystring[1] - 64;
+ if (keystring[1] == '`')
+ return 0;
+ else
+ return -1;
+ } else if (strcasecmp(keystring, "^Space") == 0)
+ return 0;
+ else
+ return -1;
+ } else if (keystring[0] == 'M') {
+ if (keystring[1] == '-' && keystring[3] == '\0')
+ return tolower((unsigned char)keystring[2]);
+ if (strcasecmp(keystring, "M-Space") == 0)
+ return (int)' ';
+ else
+ return -1;
+#ifdef ENABLE_NANORC
+ } else if (strncasecmp(keystring, "Sh-M-", 5) == 0 &&
+ 'a' <= (keystring[5] | 0x20) && (keystring[5] | 0x20) <= 'z' &&
+ keystring[6] == '\0') {
+ shifted_metas = TRUE;
+ return (keystring[5] & 0x5F);
+#endif
+ } else if (keystring[0] == 'F') {
+ int fn = atoi(&keystring[1]);
+ if (fn < 1 || fn > 24)
+ return -1;
+ return KEY_F0 + fn;
+ } else if (strcasecmp(keystring, "Ins") == 0)
+ return KEY_IC;
+ else if (strcasecmp(keystring, "Del") == 0)
+ return KEY_DC;
+ else
+ return -1;
+}
+
/* Add a key combo to the linked list of shortcuts. */
void add_to_sclist(int menus, const char *scstring, const int keycode,
void (*func)(void), int toggle)
@@ -513,51 +558,6 @@ functionptrtype interpret(int *keycode)
}
#endif /* ENABLE_BROWSER || ENABLE_HELP */
-/* Parse the given keystring and return the corresponding keycode,
- * or return -1 when the string is invalid. */
-int keycode_from_string(const char *keystring)
-{
- if (keystring[0] == '^') {
- if (keystring[2] == '\0') {
- if (keystring[1] == '/')
- return 31;
- if (keystring[1] <= '_')
- return keystring[1] - 64;
- if (keystring[1] == '`')
- return 0;
- else
- return -1;
- } else if (strcasecmp(keystring, "^Space") == 0)
- return 0;
- else
- return -1;
- } else if (keystring[0] == 'M') {
- if (keystring[1] == '-' && keystring[3] == '\0')
- return tolower((unsigned char)keystring[2]);
- if (strcasecmp(keystring, "M-Space") == 0)
- return (int)' ';
- else
- return -1;
-#ifdef ENABLE_NANORC
- } else if (strncasecmp(keystring, "Sh-M-", 5) == 0 &&
- 'a' <= (keystring[5] | 0x20) && (keystring[5] | 0x20) <= 'z' &&
- keystring[6] == '\0') {
- shifted_metas = TRUE;
- return (keystring[5] & 0x5F);
-#endif
- } else if (keystring[0] == 'F') {
- int fn = atoi(&keystring[1]);
- if (fn < 1 || fn > 24)
- return -1;
- return KEY_F0 + fn;
- } else if (strcasecmp(keystring, "Ins") == 0)
- return KEY_IC;
- else if (strcasecmp(keystring, "Del") == 0)
- return KEY_DC;
- else
- return -1;
-}
-
/* These two tags are used elsewhere too, so they are global. */
/* TRANSLATORS: Try to keep the next two strings at most 10 characters. */
const char *exit_tag = N_("Exit");
diff --git a/src/text.c b/src/text.c
@@ -1439,19 +1439,6 @@ size_t indent_length(const char *line)
#endif
#ifdef ENABLE_JUSTIFY
-/* Copy a character from one place to another. */
-void copy_character(char **from, char **to)
-{
- int charlen = char_length(*from);
-
- if (*from == *to) {
- *from += charlen;
- *to += charlen;
- } else
- while (--charlen >= 0)
- *((*to)++) = *((*from)++);
-}
-
/* Return the length of the quote part of the given line. The "quote part"
* of a line is the largest initial substring matching the quoting regex. */
size_t quote_length(const char *line)
@@ -1575,6 +1562,19 @@ void concat_paragraph(linestruct *line, size_t count)
}
}
+/* Copy a character from one place to another. */
+void copy_character(char **from, char **to)
+{
+ int charlen = char_length(*from);
+
+ if (*from == *to) {
+ *from += charlen;
+ *to += charlen;
+ } else
+ while (--charlen >= 0)
+ *((*to)++) = *((*from)++);
+}
+
/* In the given line, replace any series of blanks with a single space,
* but keep two spaces (if there are two) after any closing punctuation,
* and remove all blanks from the end of the line. Leave the first skip