updated folder structure once more

This commit is contained in:
2025-09-23 22:03:24 +02:00
parent e3e10a67c8
commit 853c9003f4
73 changed files with 6 additions and 2901 deletions

View File

@@ -1,5 +1,5 @@
CC = gcc
CFLAGS = -Wextra -g -Iinclude
CFLAGS = -Wextra -g -Iinclude -Iinclude/core -Iinclude/input -Iinclude/history -Iinclude/search -Iinclude/ui -Iinclude/data -Iinclude/git -Iinclude/system -Iinclude/utils
LIBS = -lm -lncurses
# Directories
@@ -7,9 +7,9 @@ SRC_DIR = src
INC_DIR = include
BUILD_DIR = build
# Get all .c files from src directory
SOURCES = $(wildcard $(SRC_DIR)/*.c)
# Generate object file names in build directory
# Get all .c files recursively from src directory and subdirectories
SOURCES = $(shell find $(SRC_DIR) -name "*.c")
# Generate object file names in build directory, preserving subdirectory structure
OBJECTS = $(SOURCES:$(SRC_DIR)/%.c=$(BUILD_DIR)/%.o)
TARGET = shell
@@ -21,7 +21,9 @@ $(BUILD_DIR):
$(TARGET): $(OBJECTS)
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
# Create build subdirectories and compile
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c $< -o $@
clean:

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,102 +0,0 @@
/**
* builtins.h
* Declarations for all built-in shell commands
*/
#ifndef BUILTINS_H
#define BUILTINS_H
#include "common.h"
#include "system_monitor.h"
#include <time.h>
// Syntax highlighting definitions using ANSI colors
#define COLOR_DEFAULT ANSI_COLOR_RESET
#define COLOR_KEYWORD ANSI_COLOR_CYAN
#define COLOR_STRING ANSI_COLOR_GREEN
#define COLOR_COMMENT "\x1b[90m" // Dark gray
#define COLOR_NUMBER ANSI_COLOR_MAGENTA
#define COLOR_PREPROCESSOR ANSI_COLOR_YELLOW
#define COLOR_IDENTIFIER "\x1b[97m" // Bright white
// Add declarations for color functions
void set_color(int color);
void reset_color();
// History command implementation
#define HISTORY_SIZE 10
// New struct to hold history entries with timestamps
typedef struct {
char *command;
time_t timestamp;
} HistoryEntry;
// History variables - made extern to be accessible from line_reader.c
extern HistoryEntry command_history[HISTORY_SIZE];
extern int history_count;
extern int history_index;
// Built-in command declarations
int lsh_cd(char **args);
int lsh_help(char **args);
int lsh_exit(char **args);
int lsh_dir(char **args);
int lsh_clear(char **args);
int lsh_mkdir(char **args);
int lsh_rmdir(char **args);
int lsh_del(char **args);
int lsh_touch(char **args);
int lsh_pwd(char **args);
int lsh_cat(char **args);
int lsh_history(char **args);
int lsh_copy(char **args);
int lsh_paste(char **args);
int lsh_move(char **args);
int lsh_ps(char **args);
int lsh_news(char **args);
// Alias command declarations - added for alias support
int lsh_alias(char **args);
int lsh_unalias(char **args);
int lsh_aliases(char **args); // New command to list all aliases
// Bookmark command declarations - added for bookmark support
int lsh_bookmark(char **args);
int lsh_bookmarks(char **args);
int lsh_goto(char **args);
int lsh_unbookmark(char **args);
int lsh_focus_timer(char **args);
int lsh_weather(char **args);
// Text search command
int lsh_grep(char **args);
int lsh_actual_grep(char **args);
int lsh_ripgrep(char **args);
int lsh_fzf_native(char **args);
int lsh_clip(char **args);
int lsh_echo(char **args);
int lsh_self_destruct();
int lsh_theme(char **args);
int lsh_loc(char **args);
int lsh_git_status(char **args);
int lsh_gg(char **args);
int lsh_stats(char **args);
// Add command to history
void lsh_add_to_history(const char *command);
// Get number of builtin commands
int lsh_num_builtins(void);
// Expose the builtin command strings and function pointers
extern char *builtin_str[];
extern int (*builtin_func[])(char **);
/**
* Extract a string value from a JSON object
*
* @param json The JSON string to parse
* @param key The key to find
* @return Allocated string containing the value (caller must free)
*/
char *extract_json_string(const char *json, const char *key);
#endif // BUILTINS_H

View File

@@ -1,116 +0,0 @@
/**
* common.h
* Common includes, defines and macros used throughout the shell
*/
#ifndef COMMON_H
#define COMMON_H
// Standard library includes
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h> // For isprint
#include <fcntl.h> // For file control
#include <unistd.h> // For POSIX API (replaces direct.h)
#include <sys/types.h>
#include <sys/wait.h> // For waitpid
#include <sys/stat.h> // For stat (replaces fileapi.h)
#include <termios.h> // For terminal control
#include <sys/ioctl.h> // For console dimensions
#include <signal.h> // For signal handling
#include <time.h> // For time functions
#include <limits.h> // For PATH_MAX
// Define PATH_MAX if not defined
#ifndef PATH_MAX
#define PATH_MAX 4096
#endif
// Common defines
#define LSH_RL_BUFSIZE 1024
#define LSH_TOK_BUFSIZE 64
#define LSH_TOK_DELIM " \t\r\n\a"
// Terminal control and color codes (ANSI sequences)
#define ANSI_COLOR_RESET "\x1b[0m"
#define ANSI_COLOR_BLACK "\x1b[30m"
#define ANSI_COLOR_RED "\x1b[31m"
#define ANSI_COLOR_GREEN "\x1b[32m"
#define ANSI_COLOR_YELLOW "\x1b[33m"
#define ANSI_COLOR_BLUE "\x1b[34m"
#define ANSI_COLOR_MAGENTA "\x1b[35m"
#define ANSI_COLOR_CYAN "\x1b[36m"
#define ANSI_COLOR_WHITE "\x1b[37m"
// Background colors
#define ANSI_BG_BLACK "\x1b[40m"
#define ANSI_BG_RED "\x1b[41m"
#define ANSI_BG_GREEN "\x1b[42m"
#define ANSI_BG_YELLOW "\x1b[43m"
#define ANSI_BG_BLUE "\x1b[44m"
#define ANSI_BG_MAGENTA "\x1b[45m"
#define ANSI_BG_CYAN "\x1b[46m"
#define ANSI_BG_WHITE "\x1b[47m"
// Cursor movement and screen control
#define ANSI_CLEAR_SCREEN "\x1b[2J"
#define ANSI_CURSOR_HOME "\x1b[H"
#define ANSI_SAVE_CURSOR "\x1b[s"
#define ANSI_RESTORE_CURSOR "\x1b[u"
// Key code definitions used by the line reader
#define KEY_BACKSPACE 127 // Different on Linux
#define KEY_TAB 9
#define KEY_ENTER 10 // Linux: 10 (LF) or 13 (CR)
#define KEY_ESCAPE 27
// Special keys (Linux terminal uses escape sequences)
// These will need handling in the line reader
#define KEY_UP 1000
#define KEY_DOWN 1001
#define KEY_LEFT 1002
#define KEY_RIGHT 1003
#define KEY_SHIFT_ENTER 1010
#define KEY_SHIFT_TAB 1011
// Typedefs for compatibility
typedef unsigned int UINT;
typedef unsigned short WORD;
typedef int BOOL;
typedef int HANDLE;
typedef int DWORD;
// Define Windows constants
#define FALSE 0
#define TRUE 1
// Struct to replace COORD
typedef struct {
short X;
short Y;
} COORD;
// Struct to replace SMALL_RECT
typedef struct {
short Left;
short Top;
short Right;
short Bottom;
} SMALL_RECT;
// Struct to replace CONSOLE_SCREEN_BUFFER_INFO
typedef struct {
COORD dwSize;
COORD dwCursorPosition;
WORD wAttributes;
SMALL_RECT srWindow;
} CONSOLE_SCREEN_BUFFER_INFO;
// Struct to replace CONSOLE_CURSOR_INFO
typedef struct {
DWORD dwSize;
BOOL bVisible;
} CONSOLE_CURSOR_INFO;
#endif // COMMON_H

View File

@@ -1,141 +0,0 @@
/**
* shell.h
* Core shell functionality
*/
#ifndef SHELL_H
#define SHELL_H
#include "common.h"
#include "structured_data.h"
/**
* Display a welcome banner with BBQ sauce invention time
*/
void display_welcome_banner(void);
/**
* Execute a command
*
* @param args Null-terminated array of command arguments
* @return 1 to continue the shell, 0 to exit
*/
int lsh_execute(char **args);
/**
* Execute a pipeline of commands
*
* @param commands Null-terminated array of command arrays
* @return 1 to continue the shell, 0 to exit
*/
int lsh_execute_piped(char ***commands);
/**
* Create a TableData structure from an ls command
*
* @param args Command arguments
* @return TableData pointer (must be freed by caller) or NULL on error
*/
TableData* create_ls_table(char **args);
/**
* Parse input line into an array of commands (for pipelines)
*
* @param line Input command line
* @return Null-terminated array of command arrays
*/
char*** lsh_split_commands(char *line);
/**
* Launch an external program
*
* @param args Null-terminated array of command arguments
* @return Always returns 1 (continue the shell)
*/
int lsh_launch(char **args);
/**
* Main shell loop
*/
void lsh_loop(void);
/**
* Free memory for a command array from lsh_split_commands
*/
void free_commands(char ***commands);
/**
* Initialize the status bar at the bottom of the screen
*
* @param fd File descriptor for terminal (STDOUT_FILENO)
* @return 1 if successful, 0 on failure
*/
int init_status_bar(int fd);
/**
* Temporarily hide the status bar before command execution
*
* @param fd File descriptor for terminal (STDOUT_FILENO)
*/
void hide_status_bar(int fd);
/**
* Ensures there's space for the status bar by scrolling if needed
*
* @param fd File descriptor for terminal (STDOUT_FILENO)
*/
void ensure_status_bar_space(int fd);
/**
* Check for terminal window resize and update status bar position
*
* @param fd File descriptor for terminal (STDOUT_FILENO)
*/
void check_console_resize(int fd);
/**
* Update the status bar with Git information
*
* @param fd File descriptor for terminal (STDOUT_FILENO)
* @param git_info The Git information to display in the status bar
*/
void update_status_bar(int fd, const char *git_info);
/**
* Get the name of the parent and current directories from a path
*
* @param cwd The current working directory path
* @param parent_dir_name Buffer to store the parent directory name
* @param current_dir_name Buffer to store the current directory name
* @param buf_size Size of the buffers
*/
void get_path_display(const char *cwd, char *parent_dir_name,
char *current_dir_name, size_t buf_size);
/**
* Initialize the terminal for raw mode
*
* @param orig_termios Original terminal settings to restore later
* @return File descriptor for terminal
*/
int init_terminal(struct termios *orig_termios);
/**
* Restore terminal to original settings
*
* @param fd File descriptor for terminal
* @param orig_termios Original terminal settings
*/
void restore_terminal(int fd, struct termios *orig_termios);
/**
* Get console dimensions
*
* @param fd File descriptor for terminal
* @param width Pointer to store width
* @param height Pointer to store height
* @return 1 on success, 0 on failure
*/
int get_console_dimensions(int fd, int *width, int *height);
#endif // SHELL_H

BIN
shell

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -1,26 +0,0 @@
/**
* main.c
* Entry point for the LSH shell program
*/
#include "common.h"
#include "shell.h"
#include <locale.h>
/**
* Main entry point
*/
int main(int argc, char **argv) {
// Set locale to support UTF-8
setlocale(LC_ALL, "en_US.UTF-8");
// Setup terminal for proper UTF-8 handling
// This is Linux equivalent of SetConsoleOutputCP(65001)
printf("\033%%G"); // Tell terminal to use UTF-8
// Start the shell loop
lsh_loop();
return EXIT_SUCCESS;
}

File diff suppressed because it is too large Load Diff