mg

port of mg editor (openbsd to linux)
Log | Files | Refs | README

commit 7f72c5d4b44ec8694751a52d1601679b1f787e22
parent 2b800f1ebbb7acb8c1a80238d7167e3feb3b8556
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Fri, 28 Nov 2014 19:39:21 +0100

feature: add indent-region

Diffstat:
CHANGES | 5+++--
def.h | 1+
region.c | 19+++++++++++++++++++
3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/CHANGES b/CHANGES @@ -26,4 +26,5 @@ Compatibility: Features: --------- -- Allow "y" and "n" aswell for save-buffers-kill-emacs instead of "yes" and "no".- \ No newline at end of file +- Allow "y" and "n" aswell for save-buffers-kill-emacs instead of "yes" and "no". +- Add "indent-region": prefixes region with tab.+ \ No newline at end of file diff --git a/def.h b/def.h @@ -592,6 +592,7 @@ int copyregion(int, int); int lowerregion(int, int); int upperregion(int, int); int prefixregion(int, int); +int indentregion(int, int); int setprefix(int, int); int region_get_data(struct region *, char *, int); void region_put_data(const char *, int); diff --git a/region.c b/region.c @@ -353,6 +353,25 @@ setprefix(int f, int n) return (retval); } +/* indent region with tab */ +int +indentregion(int f, int n) +{ + int tmp[2]; + + /* remember previous prefix_string part */ + memcpy(tmp, prefix_string, sizeof(tmp)); + + prefix_string[0] = '\t'; + prefix_string[1] = '\0'; + + prefixregion(f, n); + + /* restore */ + memcpy(prefix_string, tmp, sizeof(tmp)); + return (TRUE); +} + int region_get_data(struct region *reg, char *buf, int len) {