46
46
#include "include/signalhandling.h"
47
47
#include "include/highlight.h"
48
48
#include "include/hashtable.h"
49
- #include "include/helpers.h"
49
+ #include "include/arg_helpers.h"
50
+ #include "include/musicpreview.h"
50
51
51
52
#define MAX_ITEMS 1024
52
53
#define MAX_HISTORY 256
@@ -762,6 +763,17 @@ int main(int argc, char* argv[]) {
762
763
endwin ();
763
764
show_version ();
764
765
return 0 ;
766
+ } else if (argc == 2 && (strcmp (argv [1 ], "-l" ) == 0 || strcmp (argv [1 ], "--log-dir" ) == 0 )) {
767
+ endwin ();
768
+ printf ("Log file at: ~/%s\n" , LOG_FILE_RELATIVE_PATH );
769
+ return 0 ;
770
+ } else if (argc == 2 && (strcmp (argv [1 ], "-lc" ) == 0 || strcmp (argv [1 ], "--log-clear" ) == 0 )) {
771
+ endwin ();
772
+ char termbuf [256 ];
773
+ snprintf (termbuf , 256 , "echo '' > ~/%s" , LOG_FILE_RELATIVE_PATH );
774
+ system (termbuf );
775
+ printf ("Cleared log for LiteFM.\n" ); // will implement this later
776
+ return 0 ;
765
777
} else {
766
778
get_current_working_directory (current_path , sizeof (current_path ));
767
779
}
@@ -788,6 +800,7 @@ int main(int argc, char* argv[]) {
788
800
int find_index = 0 ;
789
801
char last_query [NAME_MAX ] = "" ;
790
802
bool firstKeyPress = true;
803
+ bool firstPlay = true;
791
804
log_message (LOG_LEVEL_DEBUG , "================ LITEFM INSTANCE STARTED =================" );
792
805
log_message (LOG_LEVEL_DEBUG , "Entering as USER: %s" ,cur_user );
793
806
@@ -892,13 +905,19 @@ int main(int argc, char* argv[]) {
892
905
highlight = 0 ;
893
906
scroll_position = 0 ;
894
907
} else {
895
- if ((is_readable_extension (items [highlight ].name ) || !is_image (items [highlight ].name )) && !items [highlight ].is_dir ) {
908
+ if ((is_readable_extension (items [highlight ].name ) || !is_image (items [highlight ].name )) && !items [highlight ].is_dir && ! is_audio ( items [ highlight ]. name ) ) {
896
909
firstKeyPress = true;
897
910
launch_env_var (win , current_path , items [highlight ].name , "EDITOR" );
898
911
/* Since we have set firstKeyPress to true, it will not wgetch(), rather it will just refresh everything back to how it was */
899
912
} else if (is_image (items [highlight ].name ) && !items [highlight ].is_dir ) {
900
913
firstKeyPress = true;
901
914
launch_env_var (win , current_path , items [highlight ].name , "VISUAL" );
915
+ } else if (is_audio (items [highlight ].name ) && !items [highlight ].is_dir ) {
916
+ char file_path [MAX_PATH_LENGTH ];
917
+ snprintf (file_path , MAX_PATH_LENGTH , "%s/%s" , current_path , items [highlight ].name );
918
+ show_term_message (" [PREVIEW] Previewing audio file. Press q to quit." , 0 );
919
+ preview_audio (file_path );
920
+ show_term_message ("" , -1 );
902
921
} else {
903
922
show_term_message ("Cannot enter this directory/file." , 1 );
904
923
}
@@ -1456,9 +1475,6 @@ int main(int argc, char* argv[]) {
1456
1475
}
1457
1476
break ;
1458
1477
}
1459
- /*else if (nextch == 'p' && !items[highlight].is_dir) {*/
1460
- /* break;*/
1461
- /*}*/
1462
1478
refreshMainWin (win , info_win , items , item_count , highlight , current_path , show_hidden , scroll_position , height , info_height , info_width , info_starty , info_startx );
1463
1479
1464
1480
} while (nextch != 10 );
0 commit comments