xaizek / vifm (License: GPLv2+) (since 2018-12-07)
Vifm is a file manager with curses interface, which provides Vi[m]-like environment for managing objects within file systems, extended with some useful ideas from mutt.
Commit 67e100023bdd4319439904883c2817f65e77471f

Fix view mode highlighting for multi-byte chars
Thanks to filterfalse.
Author: xaizek
Author date (UTC): 2013-10-28 21:30
Committer name: xaizek
Committer date (UTC): 2013-10-28 21:55
Parent(s): dad1d015a9dce3be1bca14b6ca4cf2610ff98ab7
Signing key:
Tree: 151e92451c0c7dd1da8b1b41e783c690c1b5bd98
File Lines added Lines deleted
ChangeLog 3 0
src/escape.c 13 4
File ChangeLog changed (mode: 100644) (index 5b8658b34..f4a40f348)
22 22
23 23 Fixed backward search in view mode for the first line. Fixed backward search in view mode for the first line.
24 24
25 Fixed view mode highlighting for multi-byte characters. Thanks to
26 filterfalse.
27
25 28 0.7.6-beta to 0.7.6-beta2 0.7.6-beta to 0.7.6-beta2
26 29
27 30 Made building for Windows64 platform possible. Made building for Windows64 platform possible.
File src/escape.c changed (mode: 100644) (index 5d820c7b0..0d28a59cb)
... ... esc_highlight_pattern(const char line[], const regex_t *re)
105 105 const size_t len = strlen(line); const size_t len = strlen(line);
106 106
107 107 int *const offsets = malloc(sizeof(int)*(len + 1)); int *const offsets = malloc(sizeof(int)*(len + 1));
108 int noffsets = 0;
109 108
110 109 char *const no_esc = malloc(len + 1); char *const no_esc = malloc(len + 1);
111 110 char *no_esc_sym = no_esc; char *no_esc_sym = no_esc;
111 int no_esc_sym_pos = 0;
112 112
113 113 /* Fill no_esc and offsets. */ /* Fill no_esc and offsets. */
114 114 const char *src_sym = line; const char *src_sym = line;
 
... ... esc_highlight_pattern(const char line[], const regex_t *re)
117 117 const size_t char_width_esc = get_char_width_esc(src_sym); const size_t char_width_esc = get_char_width_esc(src_sym);
118 118 if(*src_sym != '\033') if(*src_sym != '\033')
119 119 { {
120 offsets[noffsets++] = src_sym - line;
120 int i;
121 const int offset = src_sym - line;
122 /* Each offset value is filled over whole character width. */
123 for(i = 0; i < char_width_esc; i++)
124 {
125 offsets[no_esc_sym_pos + i] = offset;
126 }
127 no_esc_sym_pos += char_width_esc;
128
121 129 memcpy(no_esc_sym, src_sym, char_width_esc); memcpy(no_esc_sym, src_sym, char_width_esc);
122 130 no_esc_sym += char_width_esc; no_esc_sym += char_width_esc;
123 131 } }
124 132 src_sym += char_width_esc; src_sym += char_width_esc;
125 133 } }
126 offsets[noffsets++] = src_sym - line;
134 offsets[no_esc_sym_pos] = src_sym - line;
127 135 *no_esc_sym = '\0'; *no_esc_sym = '\0';
136 assert(no_esc_sym_pos == no_esc_sym - no_esc);
128 137
129 138 processed = add_pattern_highlights(line, len, no_esc, offsets, re); processed = add_pattern_highlights(line, len, no_esc, offsets, re);
130 139
 
... ... add_pattern_highlights(const char line[], size_t len, const char no_esc[],
204 213 } }
205 214
206 215 /* Corrects offset inside the line so that it points to the char after previous /* Corrects offset inside the line so that it points to the char after previous
207 * character instead of the beginning of the current one.. */
216 * character instead of the beginning of the current one. */
208 217 static size_t static size_t
209 218 correct_offset(const char line[], const int offsets[], size_t offset) correct_offset(const char line[], const int offsets[], size_t offset)
210 219 { {
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/vifm

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/vifm

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master