File src/hstr_curses.c added (mode: 100644) (index 0000000..700f74c) |
|
1 |
|
/* |
|
2 |
|
============================================================================ |
|
3 |
|
Name : hstr_curses.c |
|
4 |
|
Author : martin.dvorak@midforger.com |
|
5 |
|
Copyright : Apache 2.0 |
|
6 |
|
Description : Curses utilities |
|
7 |
|
============================================================================ |
|
8 |
|
*/ |
|
9 |
|
|
|
10 |
|
#include "include/hstr_curses.h" |
|
11 |
|
|
|
12 |
|
static bool terminalHasColors=FALSE; |
|
13 |
|
|
|
14 |
|
void color_start() |
|
15 |
|
{ |
|
16 |
|
terminalHasColors=has_colors(); |
|
17 |
|
if(terminalHasColors) { |
|
18 |
|
start_color(); |
|
19 |
|
} |
|
20 |
|
} |
|
21 |
|
|
|
22 |
|
bool terminal_has_colors() { |
|
23 |
|
return terminalHasColors; |
|
24 |
|
} |
File src/hstr_history.c changed (mode: 100644) (index e7baf39..eb2907b) |
... |
... |
char *get_history_file_name() |
46 |
46 |
char *historyFile=getenv(ENV_VAR_HISTFILE); |
char *historyFile=getenv(ENV_VAR_HISTFILE); |
47 |
47 |
if(!historyFile || strlen(historyFile)==0) { |
if(!historyFile || strlen(historyFile)==0) { |
48 |
48 |
char *home = getenv(ENV_VAR_HOME); |
char *home = getenv(ENV_VAR_HOME); |
49 |
|
historyFile = malloc(strlen(home) + 1 + strlen(FILE_HISTORY) + 1); |
|
50 |
|
strcat(strcat(strcpy(historyFile, home), "/"), FILE_HISTORY); |
|
|
49 |
|
historyFile = malloc(strlen(home) + 1 + strlen(DEFAULT_HISTORY_FILE) + 1); |
|
50 |
|
strcat(strcat(strcpy(historyFile, home), "/"), DEFAULT_HISTORY_FILE); |
51 |
51 |
} |
} |
52 |
52 |
return historyFile; |
return historyFile; |
53 |
53 |
} |
} |
File src/include/hstr_curses.h added (mode: 100644) (index 0000000..aefff03) |
|
1 |
|
/* |
|
2 |
|
============================================================================ |
|
3 |
|
Name : hstr_curses.h |
|
4 |
|
Author : martin.dvorak@midforger.com |
|
5 |
|
Copyright : Apache 2.0 |
|
6 |
|
Description : Curses helpers |
|
7 |
|
============================================================================ |
|
8 |
|
*/ |
|
9 |
|
|
|
10 |
|
#ifndef _HSTR_CURSES_H |
|
11 |
|
#define _HSTR_CURSES_H |
|
12 |
|
|
|
13 |
|
#include <curses.h> |
|
14 |
|
|
|
15 |
|
#define color_attr_on(C) if(terminal_has_colors()) { attron(C); } |
|
16 |
|
#define color_attr_off(C) if(terminal_has_colors()) { attroff(C); } |
|
17 |
|
#define color_init_pair(X, Y, Z) if(terminal_has_colors()) { init_pair(X, Y, Z); } |
|
18 |
|
|
|
19 |
|
bool terminal_has_colors(); |
|
20 |
|
void color_start(); |
|
21 |
|
|
|
22 |
|
#endif |