5959 actual_path string = os.abs_path ('' )
6060 actual_i int
6161 actual_scroll int
62- dir_list []string
62+ dir_list []FileInfo
6363 fav_folders []string
6464 frame_nb int
6565 last_event string
@@ -145,7 +145,7 @@ fn event(e &tui.Event, x voidptr) {
145145 app.last_event = "create file escape edit"
146146 }
147147 "Rename:" {
148- os.rename ("$app.actual_path \\ ${app.dir_list[app.actual_i]} " , "$app.actual_path \\ $app.edit_text " ) or {er ("rename $err " )}
148+ os.rename ("$app.actual_path \\ ${app.dir_list[app.actual_i].name } " , "$app.actual_path \\ $app.edit_text " ) or {er ("rename $err " )}
149149 app.update_dir_list ()
150150 app.reset_edit ()
151151 app.last_event = "rename"
@@ -164,15 +164,15 @@ fn event(e &tui.Event, x voidptr) {
164164 .enter {
165165 if app.question_answer{
166166 if app.question_mode == "Delete this file ?" {
167- os.rm (os.join_path_single (app.actual_path, app.dir_list[app.actual_i])) or {er ('rm $err ' )}
167+ os.rm (os.join_path_single (app.actual_path, app.dir_list[app.actual_i].name )) or {er ('rm $err ' )}
168168 app.update_dir_list ()
169169 if app.dir_list.len > 0 {
170170 app.actual_i = app.actual_i % app.dir_list.len
171171 }
172172 app.last_event = "deleted a file"
173173 }else {
174174 if app.question_mode == "Delete this folder ?" {
175- os.rmdir_all (os.join_path_single (app.actual_path, app.dir_list[app.actual_i])) or {er ('rmdir_all $err ' )}
175+ os.rmdir_all (os.join_path_single (app.actual_path, app.dir_list[app.actual_i].name )) or {er ('rmdir_all $err ' )}
176176 app.update_dir_list ()
177177 if app.dir_list.len > 0 {
178178 app.actual_i = app.actual_i % app.dir_list.len
@@ -244,6 +244,18 @@ fn event(e &tui.Event, x voidptr) {
244244 app.actual_i = app.actual_i % app.dir_list.len
245245 }
246246 }
247+ .left {
248+ app.actual_path = app.fav_folders[app.fav_index]
249+ app.reset_fav ()
250+ os.chdir (app.actual_path) or {
251+ er ('go in fav ${err} ' )
252+ app.chdir_error = '${err} '
253+ }
254+ app.update_dir_list ()
255+ if app.dir_list.len > 0 {
256+ app.actual_i = app.actual_i % app.dir_list.len
257+ }
258+ }
247259 else {}
248260 }
249261 } else if app.cmd_mode {
@@ -349,7 +361,7 @@ fn event(e &tui.Event, x voidptr) {
349361 }
350362 .c {
351363 if e.modifiers.has (.ctrl){
352- app.copy_path = os.abs_path (app.dir_list[app.actual_i])
364+ app.copy_path = os.abs_path (app.dir_list[app.actual_i].name )
353365 app.refresh = true
354366 app.cut_mode = false
355367 app.last_event = 'copy'
@@ -361,7 +373,7 @@ fn event(e &tui.Event, x voidptr) {
361373 }
362374 .x {
363375 if e.modifiers.has (.ctrl){
364- app.copy_path = os.abs_path (app.dir_list[app.actual_i])
376+ app.copy_path = os.abs_path (app.dir_list[app.actual_i].name )
365377 app.refresh = true
366378 app.cut_mode = true
367379 app.last_event = 'cut'
@@ -465,7 +477,7 @@ fn event(e &tui.Event, x voidptr) {
465477 }
466478 .delete {
467479 if app.dir_list != [] {
468- if ! os. is_dir ( app.dir_list[app.actual_i]) {
480+ if ! app.dir_list[app.actual_i]. is_dir ( ) {
469481 app.question_mode = "Delete this file ?"
470482 }else {
471483 if e.modifiers.has (.shift) {
@@ -523,11 +535,11 @@ fn (mut app App) render() {
523535 if app.chdir_error == '' {
524536 for i, file in app.dir_list#[0 + app.actual_scroll..app.tui.window_height+ app.actual_scroll- 4 ] {
525537 pos := i+ 3
526- if os .is_dir (file ) {
538+ if file .is_dir () {
527539 if i == app.actual_i- app.actual_scroll {
528540 app.tui.set_bg_color (r: app.folder_highlight[0 ], g: app.folder_highlight[1 ], b: app.folder_highlight[2 ])
529541 }
530- app.tui.draw_text (3 , pos, '${file} ' )
542+ app.tui.draw_text (3 , pos, '${file.name } ' )
531543 if i == app.actual_i- app.actual_scroll {
532544 app.tui.set_bg_color (r: app.bg_color[0 ], g: app.bg_color[1 ], b: app.bg_color[2 ])
533545 }
@@ -539,7 +551,7 @@ fn (mut app App) render() {
539551 if i == app.actual_i- app.actual_scroll {
540552 app.tui.set_bg_color (r: app.file_highlight[0 ], g: app.file_highlight[1 ], b: app.file_highlight[2 ])
541553 }
542- app.tui.draw_text (3 , pos, '${file} ' )
554+ app.tui.draw_text (3 , pos, '${file.name } ' )
543555 if i == app.actual_i- app.actual_scroll {
544556 app.tui.set_bg_color (r: app.bg_color[0 ], g: app.bg_color[1 ], b: app.bg_color[2 ])
545557 }
@@ -549,11 +561,10 @@ fn (mut app App) render() {
549561 app.tui.draw_text (2 , 3 , 'Empty directory' )
550562 } else {
551563 if app.search_results != [] && app.search_i != - 1 {
552- bottom_text := '${(if !app.search_results[app.search_i].is_dir() {space_nb(app.search_results[app.search_i].file_size().str()) + 'o'} else {' Directory'}):-15} | Modified the ${app.search_results[app.search_i].write_time().nice_time()} | Accessed the ${app.search_results[app.search_i].access_time().nice_time()} '
564+ bottom_text := '${(if !app.search_results[app.search_i].is_dir() {space_nb(app.search_results[app.search_i].file_size().str()) + 'o'} else {' Directory'}):-15} | Modified the ${app.search_results[app.search_i].write_time().nice_time()} | Accessed the ${app.search_results[app.search_i].access_time().nice_time()} | Creatied the ${app.search_results[app.search_i].creation_time().nice_time()} '
553565 app.tui.draw_text (0 , app.tui.window_height, if bottom_text.len > app.tui.window_width {bottom_text[0 ..app.tui.window_width]} else {bottom_text})
554566 }else {
555- date := time.Time{}.add_seconds (int (os.file_last_mod_unix (app.dir_list[app.actual_i])))
556- bottom_text := '${(if !os.is_dir(app.dir_list[app.actual_i]) {space_nb(os.file_size(app.dir_list[app.actual_i]).str()) + 'o'} else {' Directory'}):-15} | Modified the ${date.local().format_ss():-15} | ${os.abs_path(app.dir_list[app.actual_i])} '
567+ bottom_text := '${(if !app.dir_list[app.actual_i].is_dir() {space_nb(app.dir_list[app.actual_i].file_size().str()) + 'o'} else {' Directory'}):-15} | Modified the ${app.dir_list[app.actual_i].write_time().nice_time()} | Accessed the ${app.dir_list[app.actual_i].access_time().nice_time()} | Created the ${app.dir_list[app.actual_i].creation_time().nice_time()} '
557568 app.tui.draw_text (0 , app.tui.window_height, if bottom_text.len > app.tui.window_width {bottom_text[0 ..app.tui.window_width]} else {bottom_text})
558569 }
559570 }
0 commit comments