use '-' to go back previous dir
This commit is contained in:
parent
5aa36bbb0d
commit
d429cbe594
1 changed files with 19 additions and 1 deletions
20
ccc.c
20
ccc.c
|
@ -35,6 +35,7 @@ unsigned int focus = 0;
|
||||||
long current_selection = 0;
|
long current_selection = 0;
|
||||||
bool dirs_size = DIRS_SIZE;
|
bool dirs_size = DIRS_SIZE;
|
||||||
char *cwd;
|
char *cwd;
|
||||||
|
char *p_cwd; /* previous cwd */
|
||||||
int half_width;
|
int half_width;
|
||||||
WINDOW *directory_border;
|
WINDOW *directory_border;
|
||||||
WINDOW *directory_content;
|
WINDOW *directory_content;
|
||||||
|
@ -82,6 +83,7 @@ int main(int argc, char** argv)
|
||||||
init_pair(8, COLOR_WHITE, -1); /* REG */
|
init_pair(8, COLOR_WHITE, -1); /* REG */
|
||||||
|
|
||||||
cwd = memalloc(PATH_MAX * sizeof(char));
|
cwd = memalloc(PATH_MAX * sizeof(char));
|
||||||
|
p_cwd = memalloc(PATH_MAX * sizeof(char));
|
||||||
getcwd(cwd, PATH_MAX);
|
getcwd(cwd, PATH_MAX);
|
||||||
start_ccc();
|
start_ccc();
|
||||||
|
|
||||||
|
@ -113,6 +115,7 @@ int main(int argc, char** argv)
|
||||||
case LEFT:
|
case LEFT:
|
||||||
case 'h':;
|
case 'h':;
|
||||||
/* get parent directory */
|
/* get parent directory */
|
||||||
|
strcpy(p_cwd, cwd);
|
||||||
char *last_slash = strrchr(cwd, '/');
|
char *last_slash = strrchr(cwd, '/');
|
||||||
if (last_slash != NULL) {
|
if (last_slash != NULL) {
|
||||||
*last_slash = '\0';
|
*last_slash = '\0';
|
||||||
|
@ -124,6 +127,7 @@ int main(int argc, char** argv)
|
||||||
case ENTER:
|
case ENTER:
|
||||||
case RIGHT:
|
case RIGHT:
|
||||||
case 'l':;
|
case 'l':;
|
||||||
|
strcpy(p_cwd, cwd);
|
||||||
file *file = get_file(current_selection);
|
file *file = get_file(current_selection);
|
||||||
if (file != NULL) {
|
if (file != NULL) {
|
||||||
/* check if it is directory or a regular file */
|
/* check if it is directory or a regular file */
|
||||||
|
@ -234,6 +238,11 @@ int main(int argc, char** argv)
|
||||||
highlight_current_line();
|
highlight_current_line();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
/* go to previous dir */
|
||||||
|
case '-':
|
||||||
|
change_dir(p_cwd, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
/* mark one file */
|
/* mark one file */
|
||||||
case SPACE:
|
case SPACE:
|
||||||
add_file_stat(get_filepath(current_selection), 1);
|
add_file_stat(get_filepath(current_selection), 1);
|
||||||
|
@ -319,7 +328,16 @@ void start_ccc()
|
||||||
*/
|
*/
|
||||||
void change_dir(const char *buf, int selection)
|
void change_dir(const char *buf, int selection)
|
||||||
{
|
{
|
||||||
strcpy(cwd, buf);
|
char *buf_dup;
|
||||||
|
if (buf == p_cwd) {
|
||||||
|
buf_dup = strdup(p_cwd);
|
||||||
|
if (buf_dup == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
buf_dup = (char *) buf;
|
||||||
|
}
|
||||||
|
strcpy(cwd, buf_dup);
|
||||||
clear_files();
|
clear_files();
|
||||||
populate_files(cwd, 0);
|
populate_files(cwd, 0);
|
||||||
current_selection = selection;
|
current_selection = selection;
|
||||||
|
|
Loading…
Reference in a new issue