From b8f33769c090f9493e51023e7673c9f9c5df32d2 Mon Sep 17 00:00:00 2001
From: Sergey Naumov <snaumov@quantenna.com>
Date: Wed, 4 Oct 2017 11:56:43 +0300
Subject: [PATCH] editor: add %c (cursor offset from BOF) support for macros
---
src/editor/edit.c | 9 +++++++++
src/editor/edit.h | 1 +
src/filemanager/usermenu.c | 9 +++++++++
3 files changed, 19 insertions(+)
diff --git a/src/editor/edit.c b/src/editor/edit.c
index eaab3c4..258307e 100644
a
|
b
|
edit_move_forward3 (const WEdit * edit, off_t current, long cols, off_t upto) |
2829 | 2829 | } |
2830 | 2830 | |
2831 | 2831 | /* --------------------------------------------------------------------------------------------- */ |
| 2832 | /** returns the current offset of the cursor from the beginning of a file */ |
| 2833 | |
| 2834 | off_t |
| 2835 | edit_get_curs_offt (const WEdit * edit) |
| 2836 | { |
| 2837 | return edit->buffer.curs1; |
| 2838 | } |
| 2839 | |
| 2840 | /* --------------------------------------------------------------------------------------------- */ |
2832 | 2841 | /** returns the current column position of the cursor */ |
2833 | 2842 | |
2834 | 2843 | long |
diff --git a/src/editor/edit.h b/src/editor/edit.h
index e02589f..b8b2e19 100644
a
|
b
|
gboolean edit_file (const vfs_path_t * file_vpath, long line); |
70 | 70 | gboolean edit_files (const GList * files); |
71 | 71 | |
72 | 72 | const char *edit_get_file_name (const WEdit * edit); |
| 73 | off_t edit_get_curs_offt (const WEdit * edit); |
73 | 74 | long edit_get_curs_col (const WEdit * edit); |
74 | 75 | const char *edit_get_syntax_type (const WEdit * edit); |
75 | 76 | |
diff --git a/src/filemanager/usermenu.c b/src/filemanager/usermenu.c
index e2b7c9d..7a75a7a 100644
a
|
b
|
expand_format (const WEdit * edit_widget, char c, gboolean do_quote) |
800 | 800 | result = qstr; |
801 | 801 | goto ret; |
802 | 802 | } |
| 803 | case 'c': |
| 804 | #ifdef USE_INTERNAL_EDIT |
| 805 | if (edit_widget != NULL) |
| 806 | { |
| 807 | result = g_strdup_printf ("%u", (unsigned int)edit_get_curs_offt (edit_widget)); |
| 808 | goto ret; |
| 809 | } |
| 810 | #endif |
| 811 | break; |
803 | 812 | case 'i': /* indent equal number cursor position in line */ |
804 | 813 | #ifdef USE_INTERNAL_EDIT |
805 | 814 | if (edit_widget != NULL) |