[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Nano-devel] [PATCH] possible new feature: a tab command to define what
From: |
Benno Schulenberg |
Subject: |
[Nano-devel] [PATCH] possible new feature: a tab command to define what the Tab key produces |
Date: |
Mon, 29 Oct 2018 20:48:44 +0100 |
The 'tab' command is syntax-specific and should be followed by a string
containing the character(s) that a single press of the <Tab> key should
produce -- most likely a single TAB or a small bunch spaces, but any
string is allowed. This overrides the 'tabstospaces' option/toggle.
This addresses https://savannah.gnu.org/bugs/?53661,
and addresses https://savannah.gnu.org/bugs/?54760,
and addresses part of https://savannah.gnu.org/bugs/?54775.
---
src/nano.h | 2 ++
src/rcfile.c | 3 +++
src/text.c | 5 +++++
3 files changed, 10 insertions(+)
diff --git a/src/nano.h b/src/nano.h
index 3007881d..b53d4e86 100644
--- a/src/nano.h
+++ b/src/nano.h
@@ -227,6 +227,8 @@ typedef struct syntaxtype {
/* The list of libmagic results that this syntax applies to. */
char *linter;
/* The command with which to lint this type of file. */
+ char *tab;
+ /* What the Tab key should produce; NULL for default behavior.
*/
#ifdef ENABLE_COMMENT
char *comment;
/* The line comment prefix (and postfix) for this type of file.
*/
diff --git a/src/rcfile.c b/src/rcfile.c
index d8a2d1fe..6c434a96 100644
--- a/src/rcfile.c
+++ b/src/rcfile.c
@@ -300,6 +300,7 @@ void parse_syntax(char *ptr)
live_syntax->headers = NULL;
live_syntax->magics = NULL;
live_syntax->linter = NULL;
+ live_syntax->tab = NULL;
#ifdef ENABLE_COMMENT
live_syntax->comment = mallocstrcpy(NULL, GENERAL_COMMENT_CHARACTER);
#endif
@@ -993,6 +994,8 @@ void parse_rcfile(FILE *rcstream, bool syntax_only)
parse_colors(ptr, NANO_REG_EXTENDED | REG_ICASE);
else if (strcasecmp(keyword, "linter") == 0)
pick_up_name("linter", ptr, &live_syntax->linter);
+ else if (strcasecmp(keyword, "tab") == 0)
+ pick_up_name("tab", ptr, &live_syntax->tab);
else if (syntax_only && (strcasecmp(keyword, "set") == 0 ||
strcasecmp(keyword, "unset") == 0 ||
strcasecmp(keyword, "bind") == 0 ||
diff --git a/src/text.c b/src/text.c
index 8302c7dd..e3359a0f 100644
--- a/src/text.c
+++ b/src/text.c
@@ -267,6 +267,11 @@ void do_cut_next_word(void)
* of spaces that a tab would normally take up. */
void do_tab(void)
{
+#ifdef ENABLE_COLOR
+ if (openfile->syntax && openfile->syntax->tab)
+ do_output(openfile->syntax->tab, strlen(openfile->syntax->tab),
TRUE);
+ else
+#endif
#ifndef NANO_TINY
if (ISSET(TABS_TO_SPACES)) {
char *spaces = charalloc(tabsize + 1);
--
2.19.1
- [Nano-devel] [PATCH] possible new feature: a tab command to define what the Tab key produces,
Benno Schulenberg <=