Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
cs24-19fa
git_rec_nano
Commits
5eccaa76
Commit
5eccaa76
authored
7 years ago
by
Benno Schulenberg
Browse files
Options
Download
Email Patches
Plain Diff
tweaks: refactor the implanting of a key expansion
parent
d9ac785a
master
feature/match-parens
refactor/readbility
No related merge requests found
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
src/global.c
+0
-18
src/global.c
src/nano.c
+3
-3
src/nano.c
src/prompt.c
+3
-3
src/prompt.c
src/proto.h
+3
-2
src/proto.h
src/rcfile.c
+2
-2
src/rcfile.c
src/winio.c
+9
-0
src/winio.c
with
20 additions
and
28 deletions
+20
-28
src/global.c
View file @
5eccaa76
...
...
@@ -318,11 +318,6 @@ void flip_newbuffer(void)
void
discard_buffer
(
void
)
{
}
#ifdef ENABLE_NANORC
void
implant
(
void
)
{
}
#endif
/* Add a function to the function list. */
void
add_to_funcs
(
void
(
*
func
)(
void
),
int
menus
,
const
char
*
desc
,
const
char
*
help
,
...
...
@@ -1386,19 +1381,6 @@ void set_spell_shortcuts(void)
}
#endif
/* ENABLE_COLOR && ENABLE_SPELLER */
/* Execute the function of the given shortcut. */
void
execute
(
const
sc
*
shortcut
)
{
#ifdef ENABLE_NANORC
if
(
shortcut
->
func
==
implant
)
/* Insert the corresponding string into the keyboard buffer. */
for
(
int
i
=
strlen
(
shortcut
->
expansion
);
i
>
0
;
i
--
)
put_back
(
shortcut
->
expansion
[
i
-
1
]);
else
#endif
shortcut
->
func
();
}
const
subnfunc
*
sctofunc
(
const
sc
*
s
)
{
subnfunc
*
f
=
allfuncs
;
...
...
This diff is collapsed.
Click to expand it.
src/nano.c
View file @
5eccaa76
...
...
@@ -1728,8 +1728,8 @@ int do_input(bool allow_funcs)
pletion_line
=
NULL
;
#endif
#ifdef ENABLE_NANORC
if
(
shortcut
->
func
==
implant
)
{
execute
(
shortcut
);
if
(
shortcut
->
func
==
(
void
*
)
implant
)
{
implant
(
shortcut
->
expansion
);
return
42
;
}
#endif
...
...
@@ -1756,7 +1756,7 @@ int do_input(bool allow_funcs)
}
#endif
/* Execute the function of the shortcut. */
execute
(
shortcut
);
shortcut
->
func
(
);
#ifndef NANO_TINY
/* When the marked region changes without Shift being held,
...
...
This diff is collapsed.
Click to expand it.
src/prompt.c
View file @
5eccaa76
...
...
@@ -153,8 +153,8 @@ int do_statusbar_input(bool *finished)
shortcut
->
func
==
do_backspace
))
;
#ifdef ENABLE_NANORC
else
if
(
shortcut
->
func
==
implant
)
execute
(
shortcut
);
else
if
(
shortcut
->
func
==
(
void
*
)
implant
)
implant
(
shortcut
->
expansion
);
#endif
else
if
(
shortcut
->
func
==
do_verbatim_input
)
do_statusbar_verbatim_input
();
...
...
@@ -172,7 +172,7 @@ int do_statusbar_input(bool *finished)
* to TRUE to indicate that we're done after running or trying to
* run its associated function. */
if
(
!
ISSET
(
VIEW_MODE
)
||
sctofunc
(
shortcut
)
->
viewok
)
execute
(
shortcut
);
shortcut
->
func
(
);
*
finished
=
TRUE
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/proto.h
View file @
5eccaa76
...
...
@@ -318,7 +318,6 @@ char *input_tab(char *buf, bool allow_files, size_t *place,
/* Some functions in global.c. */
size_t
length_of_list
(
int
menu
);
void
implant
(
void
);
const
sc
*
first_sc_for
(
int
menu
,
void
(
*
func
)(
void
));
int
the_code_for
(
void
(
*
func
)(
void
),
int
defaultval
);
functionptrtype
func_from_key
(
int
*
kbinput
);
...
...
@@ -330,7 +329,6 @@ void shortcut_init(void);
void
set_lint_or_format_shortcuts
(
void
);
void
set_spell_shortcuts
(
void
);
#endif
void
execute
(
const
sc
*
shortcut
);
const
subnfunc
*
sctofunc
(
const
sc
*
s
);
const
char
*
flagtostr
(
int
flag
);
sc
*
strtosc
(
const
char
*
input
);
...
...
@@ -624,6 +622,9 @@ void run_macro(void);
size_t
get_key_buffer_len
(
void
);
void
put_back
(
int
keycode
);
void
unget_kbinput
(
int
kbinput
,
bool
metakey
);
#ifdef ENABLE_NANORC
void
implant
(
const
char
*
string
);
#endif
int
get_kbinput
(
WINDOW
*
win
,
bool
showcursor
);
int
parse_kbinput
(
WINDOW
*
win
);
int
arrow_from_abcd
(
int
kbinput
);
...
...
This diff is collapsed.
Click to expand it.
src/rcfile.c
View file @
5eccaa76
...
...
@@ -338,7 +338,7 @@ bool is_universal(void (*func)(void))
func
==
do_prev_word_void
||
func
==
do_next_word_void
||
#endif
#ifdef ENABLE_NANORC
func
==
implant
||
func
==
(
void
*
)
implant
||
#endif
func
==
do_delete
||
func
==
do_backspace
||
func
==
do_cut_text_void
||
func
==
do_uncut_text
||
...
...
@@ -421,7 +421,7 @@ void parse_binding(char *ptr, bool dobind)
* otherwise it is the name of a function. */
if
(
*
funcptr
==
'"'
)
{
newsc
=
nmalloc
(
sizeof
(
sc
));
newsc
->
func
=
implant
;
newsc
->
func
=
(
void
*
)
implant
;
newsc
->
expansion
=
mallocstrcpy
(
NULL
,
funcptr
+
1
);
#ifndef NANO_TINY
newsc
->
toggle
=
0
;
...
...
This diff is collapsed.
Click to expand it.
src/winio.c
View file @
5eccaa76
...
...
@@ -286,6 +286,15 @@ void unget_kbinput(int kbinput, bool metakey)
put_back
(
ESC_CODE
);
}
#ifdef ENABLE_NANORC
/* Insert the given string into the keyboard buffer. */
void
implant
(
const
char
*
string
)
{
for
(
int
i
=
strlen
(
string
);
i
>
0
;
i
--
)
put_back
(
string
[
i
-
1
]);
}
#endif
/* Try to read input_len codes from the keystroke buffer. If the
* keystroke buffer is empty and win isn't NULL, try to read in more
* codes from win and add them to the keystroke buffer before doing
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help