toggle file icons
This commit is contained in:
parent
4fdeb8c56b
commit
60d9928459
3 changed files with 22 additions and 7 deletions
9
ccc.c
9
ccc.c
|
@ -44,6 +44,7 @@ bool to_open_file = false;
|
||||||
bool dirs_size = DIRS_SIZE;
|
bool dirs_size = DIRS_SIZE;
|
||||||
bool show_hidden = SHOW_HIDDEN;
|
bool show_hidden = SHOW_HIDDEN;
|
||||||
bool file_details = SHOW_DETAILS;
|
bool file_details = SHOW_DETAILS;
|
||||||
|
bool show_icons = SHOW_ICONS;
|
||||||
char *argv_cp;
|
char *argv_cp;
|
||||||
char *trash_dir;
|
char *trash_dir;
|
||||||
char *cwd;
|
char *cwd;
|
||||||
|
@ -291,6 +292,11 @@ int main(int argc, char** argv)
|
||||||
change_dir(cwd, 0, 0);
|
change_dir(cwd, 0, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'w':
|
||||||
|
show_icons = !show_icons;
|
||||||
|
change_dir(cwd, 0, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
case 'X':
|
case 'X':
|
||||||
toggle_executable();
|
toggle_executable();
|
||||||
break;
|
break;
|
||||||
|
@ -376,6 +382,7 @@ int main(int argc, char** argv)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
free(argv_cp);
|
||||||
arraylist_free(files);
|
arraylist_free(files);
|
||||||
arraylist_free(marked);
|
arraylist_free(marked);
|
||||||
endwin();
|
endwin();
|
||||||
|
@ -752,7 +759,7 @@ void highlight_current_line()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* print the actual filename and stats */
|
/* print the actual filename and stats */
|
||||||
char *line = get_line(files, i, file_details);
|
char *line = get_line(files, i, file_details, show_icons);
|
||||||
int color = files->items[i].color;
|
int color = files->items[i].color;
|
||||||
/* check is file marked for action */
|
/* check is file marked for action */
|
||||||
bool is_marked = arraylist_search(marked, files->items[i].path, false) != -1;
|
bool is_marked = arraylist_search(marked, files->items[i].path, false) != -1;
|
||||||
|
|
16
file.c
16
file.c
|
@ -127,7 +127,7 @@ void arraylist_add(ArrayList *list, char *name, char *path, char *stats, char *t
|
||||||
/*
|
/*
|
||||||
* Construct a formatted line for display
|
* Construct a formatted line for display
|
||||||
*/
|
*/
|
||||||
char *get_line(ArrayList *list, long index, bool detail)
|
char *get_line(ArrayList *list, long index, bool detail, bool icons)
|
||||||
{
|
{
|
||||||
file file = list->items[index];
|
file file = list->items[index];
|
||||||
char *name = estrdup(file.name);
|
char *name = estrdup(file.name);
|
||||||
|
@ -144,11 +144,19 @@ char *get_line(ArrayList *list, long index, bool detail)
|
||||||
}
|
}
|
||||||
|
|
||||||
char *line = memalloc(length * sizeof(char));
|
char *line = memalloc(length * sizeof(char));
|
||||||
|
line[0] = '\0';
|
||||||
if (detail) {
|
if (detail) {
|
||||||
snprintf(line, length, "%s %ls %s", stats, icon, name);
|
strcat(line, stats);
|
||||||
} else {
|
strcat(line, " ");
|
||||||
snprintf(line, length, "%ls %s", icon, name);
|
|
||||||
}
|
}
|
||||||
|
if (icons) {
|
||||||
|
char *tmp = memalloc(8 * sizeof(char));
|
||||||
|
snprintf(tmp, 8, "%ls", icon);
|
||||||
|
strcat(line, tmp);
|
||||||
|
strcat(line, " ");
|
||||||
|
free(tmp);
|
||||||
|
}
|
||||||
|
strcat(line, name);
|
||||||
|
|
||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
2
file.h
2
file.h
|
@ -23,6 +23,6 @@ void arraylist_free(ArrayList *list);
|
||||||
long arraylist_search(ArrayList *list, char *filepath, bool bname);
|
long arraylist_search(ArrayList *list, char *filepath, bool bname);
|
||||||
void arraylist_remove(ArrayList *list, long index);
|
void arraylist_remove(ArrayList *list, long index);
|
||||||
void arraylist_add(ArrayList *list, char *filename, char *path, char *stats, char *type, wchar_t *icon, int color, bool marked, bool force);
|
void arraylist_add(ArrayList *list, char *filename, char *path, char *stats, char *type, wchar_t *icon, int color, bool marked, bool force);
|
||||||
char *get_line(ArrayList *list, long index, bool detail);
|
char *get_line(ArrayList *list, long index, bool detail, bool icons);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue