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 ce166faee061d246e24b1375cc41e3e9d34e5aa7

Fix color manager being used uninitialized
Thanks to Valery Ushakov (a.k.a. nbuwe).

Fixes #374 on GitHub.
Author: xaizek
Author date (UTC): 2018-11-11 09:39
Committer name: xaizek
Committer date (UTC): 2018-11-11 09:41
Parent(s): f23325ba05809b2186d4250d521cf9a9d4cf3301
Signing key: 99DC5E4DB05F6BE2
Tree: 7f78aa575fb4d7f849b7549f8066b406bf3edf0c
File Lines added Lines deleted
THANKS 1 0
src/ui/ui.c 56 1
src/vifm.c 0 56
File THANKS changed (mode: 100644) (index 1607fc879..00e21b2ae)
... ... TobiSGD
171 171 Tomek K. (TomiCode) Tomek K. (TomiCode)
172 172 tYGjQCsvVI tYGjQCsvVI
173 173 Tyler Spivey Tyler Spivey
174 Valery Ushakov (nbuwe)
174 175 Vlad Glagolev (Stealth) Vlad Glagolev (Stealth)
175 176 Von Welch Von Welch
176 177 vzel vzel
File src/ui/ui.c changed (mode: 100644) (index 8dac13c30..117ca8b86)
... ... static pthread_mutex_t rwin_timestamps_mutex = PTHREAD_MUTEX_INITIALIZER;
95 95 view_t lwin = { .timestamps_mutex = &lwin_timestamps_mutex }; view_t lwin = { .timestamps_mutex = &lwin_timestamps_mutex };
96 96 view_t rwin = { .timestamps_mutex = &rwin_timestamps_mutex }; view_t rwin = { .timestamps_mutex = &rwin_timestamps_mutex };
97 97
98 static int pair_in_use(short int pair);
99 static void move_pair(short int from, short int to);
98 100 static void create_windows(void); static void create_windows(void);
99 101 static void update_geometry(void); static void update_geometry(void);
100 102 static int get_working_area_height(void); static int get_working_area_height(void);
 
... ... setup_ncurses_interface(void)
178 180 curs_set(0); curs_set(0);
179 181
180 182 getmaxyx(stdscr, screen_y, screen_x); getmaxyx(stdscr, screen_y, screen_x);
181 /* screen is too small to be useful*/
183 /* Screen is too small to be useful. */
182 184 if(screen_y < MIN_TERM_HEIGHT || screen_x < MIN_TERM_WIDTH) if(screen_y < MIN_TERM_HEIGHT || screen_x < MIN_TERM_WIDTH)
183 185 { {
184 186 vifm_finish("Terminal is too small to run vifm."); vifm_finish("Terminal is too small to run vifm.");
185 187 } }
186 188
187 189 if(!has_colors()) if(!has_colors())
190 {
188 191 vifm_finish("Vifm requires a console that can support color."); vifm_finish("Vifm requires a console that can support color.");
192 }
189 193
190 194 start_color(); start_color();
191 195 use_default_colors(); use_default_colors();
192 196
197 const colmgr_conf_t colmgr_conf = {
198 .max_color_pairs = COLOR_PAIRS,
199 .max_colors = COLORS,
200 .init_pair = &init_pair,
201 .pair_content = &pair_content,
202 .pair_in_use = &pair_in_use,
203 .move_pair = &move_pair,
204 };
205 colmgr_init(&colmgr_conf);
206
193 207 cs_load_defaults(); cs_load_defaults();
194 208
195 209 create_windows(); create_windows();
 
... ... setup_ncurses_interface(void)
215 229 return 1; return 1;
216 230 } }
217 231
232 /* Checks whether pair is being used at the moment. Returns non-zero if so and
233 * zero otherwise. */
234 static int
235 pair_in_use(short int pair)
236 {
237 int i;
238
239 for(i = 0; i < MAXNUM_COLOR; ++i)
240 {
241 if(cfg.cs.pair[i] == pair || lwin.cs.pair[i] == pair ||
242 rwin.cs.pair[i] == pair)
243 {
244 return 1;
245 }
246 }
247
248 return 0;
249 }
250
251 /* Substitutes old pair number with the new one. */
252 static void
253 move_pair(short int from, short int to)
254 {
255 int i;
256 for(i = 0; i < MAXNUM_COLOR; ++i)
257 {
258 if(cfg.cs.pair[i] == from)
259 {
260 cfg.cs.pair[i] = to;
261 }
262 if(lwin.cs.pair[i] == from)
263 {
264 lwin.cs.pair[i] = to;
265 }
266 if(rwin.cs.pair[i] == from)
267 {
268 rwin.cs.pair[i] = to;
269 }
270 }
271 }
272
218 273 /* Initializes all WINDOW variables by calling newwin() to create ncurses /* Initializes all WINDOW variables by calling newwin() to create ncurses
219 274 * windows and configures hardware cursor. */ * windows and configures hardware cursor. */
220 275 static void static void
File src/vifm.c changed (mode: 100644) (index 8ae321ee7..dce4796ae)
57 57 #include "modes/normal.h" #include "modes/normal.h"
58 58 #include "modes/view.h" #include "modes/view.h"
59 59 #include "ui/cancellation.h" #include "ui/cancellation.h"
60 #include "ui/color_manager.h"
61 60 #include "ui/color_scheme.h" #include "ui/color_scheme.h"
62 61 #include "ui/quickview.h" #include "ui/quickview.h"
63 62 #include "ui/statusbar.h" #include "ui/statusbar.h"
 
97 96 #include "undo.h" #include "undo.h"
98 97
99 98 static int vifm_main(int argc, char *argv[]); static int vifm_main(int argc, char *argv[]);
100 static int pair_in_use(short int pair);
101 static void move_pair(short int from, short int to);
102 99 static int undo_perform_func(OPS op, void *data, const char src[], static int undo_perform_func(OPS op, void *data, const char src[],
103 100 const char dst[]); const char dst[]);
104 101 static void parse_received_arguments(char *args[]); static void parse_received_arguments(char *args[]);
 
... ... vifm_main(int argc, char *argv[])
281 278 return -1; return -1;
282 279 } }
283 280
284 {
285 const colmgr_conf_t colmgr_conf = {
286 .max_color_pairs = COLOR_PAIRS,
287 .max_colors = COLORS,
288 .init_pair = &init_pair,
289 .pair_content = &pair_content,
290 .pair_in_use = &pair_in_use,
291 .move_pair = &move_pair,
292 };
293 colmgr_init(&colmgr_conf);
294 }
295
296 281 init_modes(); init_modes();
297 282 un_init(&undo_perform_func, NULL, &ui_cancellation_requested, un_init(&undo_perform_func, NULL, &ui_cancellation_requested,
298 283 &cfg.undo_levels); &cfg.undo_levels);
 
... ... vifm_main(int argc, char *argv[])
362 347 return 0; return 0;
363 348 } }
364 349
365 /* Checks whether pair is being used at the moment. Returns non-zero if so and
366 * zero otherwise. */
367 static int
368 pair_in_use(short int pair)
369 {
370 int i;
371
372 for(i = 0; i < MAXNUM_COLOR; ++i)
373 {
374 if(cfg.cs.pair[i] == pair || lwin.cs.pair[i] == pair ||
375 rwin.cs.pair[i] == pair)
376 {
377 return 1;
378 }
379 }
380
381 return 0;
382 }
383
384 /* Substitutes old pair number with the new one. */
385 static void
386 move_pair(short int from, short int to)
387 {
388 int i;
389 for(i = 0; i < MAXNUM_COLOR; ++i)
390 {
391 if(cfg.cs.pair[i] == from)
392 {
393 cfg.cs.pair[i] = to;
394 }
395 if(lwin.cs.pair[i] == from)
396 {
397 lwin.cs.pair[i] = to;
398 }
399 if(rwin.cs.pair[i] == from)
400 {
401 rwin.cs.pair[i] = to;
402 }
403 }
404 }
405
406 350 /* perform_operation() interface adaptor for the undo unit. */ /* perform_operation() interface adaptor for the undo unit. */
407 351 static int static int
408 352 undo_perform_func(OPS op, void *data, const char src[], const char dst[]) undo_perform_func(OPS op, void *data, const char src[], const char dst[])
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