Skip to content

Commit

Permalink
[FEAT:MED] CHANGELOG v2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
nots1dd committed Aug 20, 2024
1 parent ed99ee4 commit b3c1bbb
Show file tree
Hide file tree
Showing 14 changed files with 204 additions and 65 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG/v2_3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# CHANGE TYPE: MEDIUM

-> Added audio file preview (VISUAL) with error handling and testing

-> Files with no extension and non-executable now show in as bash script file with syntax highlighting by default

-> Updated arguments for litefm
12 changes: 7 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,23 @@ set(CMAKE_C_STANDARD 99)
find_package(Curses REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBARCHIVE REQUIRED libarchive)
# Manually specify YAML include and library paths
pkg_check_modules(LIBYAML REQUIRED yaml-0.1)
pkg_check_modules(SDL2 REQUIRED sdl2)
pkg_check_modules(SDL2_MIXER REQUIRED SDL2_mixer)


# Include directories for ncurses, libarchive, libyaml, and project headers
# Include directories for ncurses, libarchive, libyaml, SDL2, SDL2_mixer, and project headers
include_directories(${CURSES_INCLUDE_DIR})
include_directories(${LIBARCHIVE_INCLUDE_DIRS})
include_directories(${LIBYAML_INCLUDE_DIRS})
include_directories(${SDL2_INCLUDE_DIRS})
include_directories(${SDL2_MIXER_INCLUDE_DIRS})
include_directories(${CMAKE_SOURCE_DIR})

# Add the executable
add_executable(litefm lfm.c src/cursesutils.c src/filepreview.c src/dircontrol.c src/archivecontrol.c src/clipboard.c src/logging.c src/signalhandling.c src/highlight.c src/hashtable.c src/helpers.c)
add_executable(litefm lfm.c src/cursesutils.c src/filepreview.c src/dircontrol.c src/archivecontrol.c src/clipboard.c src/logging.c src/signalhandling.c src/highlight.c src/hashtable.c src/arg_helpers.c src/musicpreview.c)

# Link required libraries
target_link_libraries(litefm ${CURSES_LIBRARIES} ${LIBARCHIVE_LIBRARIES} ${LIBYAML_LIBRARIES})
target_link_libraries(litefm ${CURSES_LIBRARIES} ${LIBARCHIVE_LIBRARIES} ${LIBYAML_LIBRARIES} ${SDL2_LIBRARIES} ${SDL2_MIXER_LIBRARIES})

# Add additional compiler flags
target_compile_options(litefm PRIVATE -Wall -Wextra -Wpedantic)
12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ ARCHIVE_INCS = $(shell pkg-config --cflags libarchive)
YAML_LIBS = $(shell pkg-config --libs yaml-0.1)
YAML_INCS = $(shell pkg-config --cflags yaml-0.1)

SDL2_LIBS = $(shell pkg-config --libs sdl2)
SDL2_INCS = $(shell pkg-config --cflags sdl2)
SDL2_MIXER_LIBS = $(shell pkg-config --libs sdl2_mixer)
SDL2_MIXER_INCS = $(shell pkg-config --cflags sdl2_mixer)

# Source files
SRCS = lfm.c \
src/cursesutils.c \
Expand All @@ -47,7 +52,8 @@ SRCS = lfm.c \
src/signalhandling.c \
src/highlight.c \
src/hashtable.c \
src/helpers.c
src/arg_helpers.c \
src/musicpreview.c

# Object files
OBJS = $(SRCS:.c=.o)
Expand All @@ -60,11 +66,11 @@ all: $(TARGET)

# Link the executable
$(TARGET): $(OBJS)
$(CC) -o $@ $(OBJS) $(CURSES_LIBS) $(ARCHIVE_LIBS) $(YAML_LIBS)
$(CC) -o $@ $(OBJS) $(CURSES_LIBS) $(ARCHIVE_LIBS) $(YAML_LIBS) $(SDL2_LIBS) $(SDL2_MIXER_LIBS)

# Compile source files into object files
%.o: %.c
$(CC) $(CFLAGS) $(CURSES_INCS) $(ARCHIVE_INCS) $(YAML_INCS) -c $< -o $@
$(CC) $(CFLAGS) $(CURSES_INCS) $(ARCHIVE_INCS) $(YAML_INCS) $(SDL2_INCS) $(SDL2_MIXER_INCS) -c $< -o $@

# Clean up generated files
clean:
Expand Down
11 changes: 3 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,12 @@ Written in C with NCurses, libyaml, rsync and more!
>
> Without a nerd font, LiteFM will show some unreadable chars!
>
> **2. Have it full screen whenever possible:**
> **2. Dynamic resizing:**
>
> Despite having dynamic window scaling, in a lot of
> the outputs the strings may look weird (or not visible at all!) upon resizing.
> Therefore, till I find a way to fix this issue, it is **HIGHLY**
> recommended to use LiteFM at:
> There is dynamic windowing setup in LiteFM. However,
>
> -> Full screen of originally created terminal [DE]
> Upon resizing, you will have to press any key for it to show!
>
> -> Full terminal size without resizing [WM]
>
> **3. Launch LiteFM with `superuser`**
>
> LiteFM allows for fast file/dir actions,
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions include/filepreview.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const char *determine_file_type(const char *filename);
int is_readable_extension(const char *filename);
const char *format_file_size(off_t size);
int is_image(const char *filename);
int is_audio(const char *filename);
void launch_env_var(WINDOW* win, const char *current_path, const char *filename, const char* type);
void print_permissions(WINDOW *info_win, struct stat *file_stat);
void display_archive_contents(WINDOW *info_win, const char *full_path, const char *file_ext);
Expand Down
16 changes: 16 additions & 0 deletions include/musicpreview.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef MUSIC_H
#define MUSIC_H

#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_mixer.h>
#include <ncurses.h>

void preview_audio(const char *file_path);

#endif
3 changes: 2 additions & 1 deletion keywords/sh-keywords.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ symbols:
- '<'
- '>'
- '$'
- '`'
- '~'
- '\\'
- '='
Expand Down Expand Up @@ -99,3 +98,5 @@ multicomments2:
strings:
- "\""
- "'"
- "`"
- "\"\""
26 changes: 21 additions & 5 deletions lfm.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
#include "include/signalhandling.h"
#include "include/highlight.h"
#include "include/hashtable.h"
#include "include/helpers.h"
#include "include/arg_helpers.h"
#include "include/musicpreview.h"

#define MAX_ITEMS 1024
#define MAX_HISTORY 256
Expand Down Expand Up @@ -762,6 +763,17 @@ int main(int argc, char* argv[]) {
endwin();
show_version();
return 0;
} else if (argc == 2 && (strcmp(argv[1], "-l") == 0 || strcmp(argv[1], "--log-dir") == 0)) {
endwin();
printf("Log file at: ~/%s\n", LOG_FILE_RELATIVE_PATH);
return 0;
} else if (argc == 2 && (strcmp(argv[1], "-lc") == 0 || strcmp(argv[1], "--log-clear") == 0)) {
endwin();
char termbuf[256];
snprintf(termbuf, 256, "echo '' > ~/%s", LOG_FILE_RELATIVE_PATH);
system(termbuf);
printf("Cleared log for LiteFM.\n"); // will implement this later
return 0;
} else {
get_current_working_directory(current_path, sizeof(current_path));
}
Expand All @@ -788,6 +800,7 @@ int main(int argc, char* argv[]) {
int find_index = 0;
char last_query[NAME_MAX] = "";
bool firstKeyPress = true;
bool firstPlay = true;
log_message(LOG_LEVEL_DEBUG, "================ LITEFM INSTANCE STARTED =================");
log_message(LOG_LEVEL_DEBUG, "Entering as USER: %s",cur_user);

Expand Down Expand Up @@ -892,13 +905,19 @@ int main(int argc, char* argv[]) {
highlight = 0;
scroll_position = 0;
} else {
if ((is_readable_extension(items[highlight].name) || !is_image(items[highlight].name)) && !items[highlight].is_dir) {
if ((is_readable_extension(items[highlight].name) || !is_image(items[highlight].name)) && !items[highlight].is_dir && !is_audio(items[highlight].name)) {
firstKeyPress = true;
launch_env_var(win, current_path, items[highlight].name, "EDITOR");
/* Since we have set firstKeyPress to true, it will not wgetch(), rather it will just refresh everything back to how it was */
} else if (is_image(items[highlight].name) && !items[highlight].is_dir) {
firstKeyPress = true;
launch_env_var(win, current_path, items[highlight].name, "VISUAL");
} else if (is_audio(items[highlight].name) && !items[highlight].is_dir) {
char file_path[MAX_PATH_LENGTH];
snprintf(file_path, MAX_PATH_LENGTH, "%s/%s", current_path, items[highlight].name);
show_term_message(" [PREVIEW] Previewing audio file. Press q to quit.", 0);
preview_audio(file_path);
show_term_message("", -1);
} else {
show_term_message("Cannot enter this directory/file.", 1);
}
Expand Down Expand Up @@ -1456,9 +1475,6 @@ int main(int argc, char* argv[]) {
}
break;
}
/*else if (nextch == 'p' && !items[highlight].is_dir) {*/
/* break;*/
/*}*/
refreshMainWin(win, info_win, items, item_count, highlight, current_path, show_hidden, scroll_position, height, info_height, info_width, info_starty, info_startx);

} while (nextch != 10);
Expand Down
2 changes: 1 addition & 1 deletion src/helpers.c → src/arg_helpers.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

#include "../include/helpers.h"
#include "../include/arg_helpers.h"

void show_help() {
// Print the header in blue color
Expand Down
9 changes: 7 additions & 2 deletions src/cursesutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,14 +497,19 @@ void displayHelp(WINDOW* main_win) {
" Traverse the filesystem ",
" Toggle hidden dirs",
"",
" Mode 3: Command - Direct command input. [Ex: Go to, /, so on]",
" Mode 3: Preview - For file preview (AUDIO only!)",
" ->Cannot perform any operations while in preview",
" Have to exit the preview before accessing LiteFM",
"",
" Mode 4: Command - Direct command input. [Ex: Go to, /, so on]",
"",
"",
" Author: nots1dd",
" Version: 1.0",
" Version: 2.2",
" License: GNU GPL v3",
" Thank you for using LiteFM!",
" For more information, visit the Github page:",
"",
" ->https://github.com/nots1dd/litefm",
"",
" Press 'q' to exit this help",
Expand Down
Loading

0 comments on commit b3c1bbb

Please sign in to comment.