mistral gagnant

This commit is contained in:
Giorgio ar work
2026-02-04 16:16:36 +01:00
parent 87746f09ce
commit cce1ffa903
39 changed files with 12917 additions and 11802 deletions
+12 -12
View File
@@ -1,12 +1,12 @@
#ifndef APPEND_BUFFER_H_
#define APPEND_BUFFER_H_
#include "data.h"
#include <stdlib.h>
#include <string.h>
void abAppend(struct abuf *ab, const char *s, int len);
void abFree(struct abuf *ab);
#endif // APPEND_BUFFER_H_
#ifndef APPEND_BUFFER_H_
#define APPEND_BUFFER_H_
#include "data.h"
#include <stdlib.h>
#include <string.h>
void abAppend(struct abuf *ab, const char *s, int len);
void abFree(struct abuf *ab);
#endif // APPEND_BUFFER_H_
+72 -58
View File
@@ -1,58 +1,72 @@
/**
* @file buffer.h
* @brief Buffer management for handling multiple open files
*/
#ifndef BUFFER_H_
#define BUFFER_H_
#include "data.h"
/**
* @brief Creates a new buffer for a file
* @param filename Path to the file
* @return Buffer ID on success, -1 on failure
*/
int bufferCreate(const char *filename);
/**
* @brief Switches to a specific buffer by ID
* @param buffer_id The buffer ID to switch to
* @return 0 on success, -1 on failure
*/
int bufferSwitch(int buffer_id);
struct buffer_t *bufferFindById(int buffer_id);
/**
* @brief Closes a buffer by ID
* @param buffer_id The buffer ID to close
* @return 0 on success, -1 on failure
*/
int bufferClose(int buffer_id);
/**
* @brief Gets the current active buffer
* @return Pointer to current buffer_t, NULL if none
*/
struct buffer_t *bufferGetCurrent(void);
/**
* @brief Lists all open buffers
* @return Number of open buffers
*/
int bufferListAll(void);
/**
* @brief Saves current buffer to disk
* @return 0 on success, -1 on failure
*/
int bufferSave(void);
/**
* @brief Saves all buffers to disk
* @return 0 on success, -1 on failure
*/
int bufferSaveAll(void);
#endif
/**
* @file buffer.h
* @brief Buffer management for handling multiple open files
*/
#ifndef BUFFER_H_
#define BUFFER_H_
#include "data.h"
/**
* @brief Creates a new buffer for a file
* @param filename Path to the file
* @return Buffer ID on success, -1 on failure
*/
int bufferCreate(const char *filename);
/**
* @brief Switches to a specific buffer by ID
* @param buffer_id The buffer ID to switch to
* @return 0 on success, -1 on failure
*/
int bufferSwitch(int buffer_id);
struct buffer_t *bufferFindById(int buffer_id);
/**
* @brief Closes a buffer by ID
* @param buffer_id The buffer ID to close
* @return 0 on success, -1 on failure
*/
int bufferClose(int buffer_id);
/**
* @brief Gets the current active buffer
* @return Pointer to current buffer_t, NULL if none
*/
struct buffer_t *bufferGetCurrent(void);
/**
* @brief Lists all open buffers
* @return Number of open buffers
*/
int bufferListAll(void);
/**
* @brief Saves current buffer to disk
* @return 0 on success, -1 on failure
*/
int bufferSave(void);
/**
* @brief Saves all buffers to disk
* @return 0 on success, -1 on failure
*/
int bufferSaveAll(void);
/**
* @brief Creates a new terminal buffer
* @return Buffer ID on success, -1 on failure
*/
int bufferCreateTerminal(void);
/**
* @brief Executes a command in the terminal buffer
* @param buffer_id The terminal buffer ID
* @param command The command to execute
* @return 0 on success, -1 on failure
*/
int bufferExecuteTerminalCommand(int buffer_id, const char *command);
#endif
+60 -56
View File
@@ -1,56 +1,60 @@
#ifndef BUILTINS_H_
#define BUILTINS_H_
#include "lisp.h"
// Mouvement
Lisp moveCursor(Lisp args, LispError *e, LispContext ctx);
Lisp moveCursorBeginLine(Lisp args, LispError *e, LispContext ctx);
Lisp moveCursorEndLine(Lisp args, LispError *e, LispContext ctx);
Lisp editorMoveCursorPageUp(Lisp args, LispError* e, LispContext ctx);
Lisp editorMoveCursorPageDown(Lisp args, LispError *e, LispContext ctx);
// Text editing
Lisp l_editorInsertNewLine(Lisp args, LispError* e, LispContext ctx);
Lisp l_editorInserTab(Lisp args, LispError *e, LispContext ctx);
Lisp deletePreviousChar(Lisp args, LispError *e, LispContext ctx);
Lisp editorPrintC(Lisp args, LispError *e, LispContext ctx);
Lisp editorDelRow_L(Lisp args, LispError *e, LispContext ctx);
Lisp editorReadChar_L(Lisp args, LispError *e, LispContext ctx);
// Editor
Lisp editorQuit(Lisp args, LispError *e, LispContext ctx);
Lisp l_editorSave(Lisp args, LispError *e, LispContext ctx);
Lisp editorSetPrefix(Lisp args, LispError *e, LispContext ctx);
Lisp editorPrefix(Lisp args, LispError *e, LispContext ctx);
Lisp mapKey(Lisp args, LispError *e, LispContext ctx);
void registerBuiltin(char * key_sequence, LispCFunc f);
Lisp editorOpenFile(Lisp args, LispError *e, LispContext ctx);
Lisp addPackage(Lisp args, LispError *e, LispContext ctx);
// Buffer
Lisp editorSwitchNextBuffer(Lisp args, LispError *e, LispContext ctx);
Lisp bufferFind_L(Lisp args, LispError *e, LispContext ctx);
// Pane
Lisp l_editorSplitScreenVertical(Lisp args, LispError *e, LispContext ctx);
Lisp editorSwitchNextPane(Lisp args, LispError *e, LispContext ctx);
Lisp editorUnifiedPanes(Lisp args, LispError *e, LispContext ctx);
// Other
void free_structs(void);
#endif
#ifndef BUILTINS_H_
#define BUILTINS_H_
#include "lisp.h"
// Mouvement
Lisp moveCursor(Lisp args, LispError *e, LispContext ctx);
Lisp moveCursorBeginLine(Lisp args, LispError *e, LispContext ctx);
Lisp moveCursorEndLine(Lisp args, LispError *e, LispContext ctx);
Lisp editorMoveCursorPageUp(Lisp args, LispError* e, LispContext ctx);
Lisp editorMoveCursorPageDown(Lisp args, LispError *e, LispContext ctx);
// Text editing
Lisp l_editorInsertNewLine(Lisp args, LispError* e, LispContext ctx);
Lisp l_editorInserTab(Lisp args, LispError *e, LispContext ctx);
Lisp deletePreviousChar(Lisp args, LispError *e, LispContext ctx);
Lisp editorPrintC(Lisp args, LispError *e, LispContext ctx);
Lisp editorDelRow_L(Lisp args, LispError *e, LispContext ctx);
Lisp editorReadChar_L(Lisp args, LispError *e, LispContext ctx);
// Editor
Lisp editorQuit(Lisp args, LispError *e, LispContext ctx);
Lisp l_editorSave(Lisp args, LispError *e, LispContext ctx);
Lisp editorSetPrefix(Lisp args, LispError *e, LispContext ctx);
Lisp editorPrefix(Lisp args, LispError *e, LispContext ctx);
Lisp mapKey(Lisp args, LispError *e, LispContext ctx);
void registerBuiltin(char * key_sequence, LispCFunc f);
Lisp editorOpenFile(Lisp args, LispError *e, LispContext ctx);
Lisp addPackage(Lisp args, LispError *e, LispContext ctx);
// Buffer
Lisp editorSwitchNextBuffer(Lisp args, LispError *e, LispContext ctx);
Lisp bufferFind_L(Lisp args, LispError *e, LispContext ctx);
// Pane
Lisp l_editorSplitScreenVertical(Lisp args, LispError *e, LispContext ctx);
Lisp editorSwitchNextPane(Lisp args, LispError *e, LispContext ctx);
Lisp editorUnifiedPanes(Lisp args, LispError *e, LispContext ctx);
// Other
void free_structs(void);
// Terminal
Lisp editorCreateTerminal(Lisp args, LispError *e, LispContext ctx);
#endif
+123 -123
View File
@@ -1,123 +1,123 @@
#ifndef COLOR_H_
#define COLOR_H_
// ============================================================================
// TEXT STYLES / ATTRIBUTES
// ============================================================================
#define ANSI_RESET "\x1b[0m" // Reset all attributes
#define ANSI_BOLD "\x1b[1m" // Bold text
#define ANSI_DIM "\x1b[2m" // Dim/faint text
#define ANSI_ITALIC "\x1b[3m" // Italic text
#define ANSI_UNDERLINE "\x1b[4m" // Underline text
#define ANSI_BLINK "\x1b[5m" // Blinking text
#define ANSI_REVERSE "\x1b[7m" // Reverse video (invert colors)
#define ANSI_HIDDEN "\x1b[8m" // Hidden/invisible text
#define ANSI_STRIKETHROUGH "\x1b[9m" // Strikethrough text
// ============================================================================
// FOREGROUND COLORS (30-37 standard, 90-97 bright)
// ============================================================================
#define ANSI_BLACK "\x1b[30m"
#define ANSI_RED "\x1b[31m"
#define ANSI_GREEN "\x1b[32m"
#define ANSI_YELLOW "\x1b[33m"
#define ANSI_BLUE "\x1b[34m"
#define ANSI_MAGENTA "\x1b[35m"
#define ANSI_CYAN "\x1b[36m"
#define ANSI_WHITE "\x1b[37m"
// Bright/Light foreground colors (90-97)
#define ANSI_BRIGHT_BLACK "\x1b[90m"
#define ANSI_BRIGHT_RED "\x1b[91m"
#define ANSI_BRIGHT_GREEN "\x1b[92m"
#define ANSI_BRIGHT_YELLOW "\x1b[93m"
#define ANSI_BRIGHT_BLUE "\x1b[94m"
#define ANSI_BRIGHT_MAGENTA "\x1b[95m"
#define ANSI_BRIGHT_CYAN "\x1b[96m"
#define ANSI_BRIGHT_WHITE "\x1b[97m"
// ============================================================================
// BACKGROUND COLORS (40-47 standard, 100-107 bright)
// ============================================================================
#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"
// Bright/Light background colors (100-107)
#define ANSI_BG_BRIGHT_BLACK "\x1b[100m"
#define ANSI_BG_BRIGHT_RED "\x1b[101m"
#define ANSI_BG_BRIGHT_GREEN "\x1b[102m"
#define ANSI_BG_BRIGHT_YELLOW "\x1b[103m"
#define ANSI_BG_BRIGHT_BLUE "\x1b[104m"
#define ANSI_BG_BRIGHT_MAGENTA "\x1b[105m"
#define ANSI_BG_BRIGHT_CYAN "\x1b[106m"
#define ANSI_BG_BRIGHT_WHITE "\x1b[107m"
// ============================================================================
// 256-COLOR MODE (for more colors)
// ============================================================================
// Foreground: \x1b[38;5;Nm where N is 0-255
// Background: \x1b[48;5;Nm where N is 0-255
// Example macros:
#define ANSI_FG_256(N) "\x1b[38;5;" #N "m"
#define ANSI_BG_256(N) "\x1b[48;5;" #N "m"
// ============================================================================
// TRUE COLOR / 24-BIT COLOR (RGB)
// ============================================================================
// Foreground: \x1b[38;2;R;G;Bm
// Background: \x1b[48;2;R;G;Bm
// Example macros:
#define ANSI_FG_RGB(R,G,B) "\x1b[38;2;" #R ";" #G ";" #B "m"
#define ANSI_BG_RGB(R,G,B) "\x1b[48;2;" #R ";" #G ";" #B "m"
// ============================================================================
// CURSOR MOVEMENT
// ============================================================================
#define ANSI_CURSOR_UP(N) "\x1b[" #N "A" // Move up N lines
#define ANSI_CURSOR_DOWN(N) "\x1b[" #N "B" // Move down N lines
#define ANSI_CURSOR_RIGHT(N) "\x1b[" #N "C" // Move right N columns
#define ANSI_CURSOR_LEFT(N) "\x1b[" #N "D" // Move left N columns
#define ANSI_CURSOR_HOME "\x1b[H" // Move to home (0,0)
#define ANSI_CURSOR_HIDE "\x1b[?25l" // Hide cursor
#define ANSI_CURSOR_SHOW "\x1b[?25h" // Show cursor
// ============================================================================
// SCREEN CONTROL
// ============================================================================
#define ANSI_CLEAR_SCREEN "\x1b[2J" // Clear entire screen
#define ANSI_CLEAR_LINE "\x1b[K" // Clear from cursor to end of line
#define ANSI_CLEAR_UP "\x1b[1J" // Clear from cursor to start
#define ANSI_CLEAR_DOWN "\x1b[0J" // Clear from cursor to end
// ============================================================================
// EXAMPLE USAGE
// ============================================================================
/*
#include <stdio.h>
int main(void) {
// Simple color example
printf("%sHello in Red%s\n", ANSI_RED, ANSI_RESET);
// Bold and colored
printf("%s%sBold Green%s\n", ANSI_BOLD, ANSI_GREEN, ANSI_RESET);
// Background color
printf("%s%sYellow on Blue%s\n", ANSI_YELLOW, ANSI_BG_BLUE, ANSI_RESET);
// Combine multiple styles
printf("%s%s%sUnderlined Bold Cyan%s\n",
ANSI_UNDERLINE, ANSI_BOLD, ANSI_CYAN, ANSI_RESET);
return 0;
}
*/
#endif
#ifndef COLOR_H_
#define COLOR_H_
// ============================================================================
// TEXT STYLES / ATTRIBUTES
// ============================================================================
#define ANSI_RESET "\x1b[0m" // Reset all attributes
#define ANSI_BOLD "\x1b[1m" // Bold text
#define ANSI_DIM "\x1b[2m" // Dim/faint text
#define ANSI_ITALIC "\x1b[3m" // Italic text
#define ANSI_UNDERLINE "\x1b[4m" // Underline text
#define ANSI_BLINK "\x1b[5m" // Blinking text
#define ANSI_REVERSE "\x1b[7m" // Reverse video (invert colors)
#define ANSI_HIDDEN "\x1b[8m" // Hidden/invisible text
#define ANSI_STRIKETHROUGH "\x1b[9m" // Strikethrough text
// ============================================================================
// FOREGROUND COLORS (30-37 standard, 90-97 bright)
// ============================================================================
#define ANSI_BLACK "\x1b[30m"
#define ANSI_RED "\x1b[31m"
#define ANSI_GREEN "\x1b[32m"
#define ANSI_YELLOW "\x1b[33m"
#define ANSI_BLUE "\x1b[34m"
#define ANSI_MAGENTA "\x1b[35m"
#define ANSI_CYAN "\x1b[36m"
#define ANSI_WHITE "\x1b[37m"
// Bright/Light foreground colors (90-97)
#define ANSI_BRIGHT_BLACK "\x1b[90m"
#define ANSI_BRIGHT_RED "\x1b[91m"
#define ANSI_BRIGHT_GREEN "\x1b[92m"
#define ANSI_BRIGHT_YELLOW "\x1b[93m"
#define ANSI_BRIGHT_BLUE "\x1b[94m"
#define ANSI_BRIGHT_MAGENTA "\x1b[95m"
#define ANSI_BRIGHT_CYAN "\x1b[96m"
#define ANSI_BRIGHT_WHITE "\x1b[97m"
// ============================================================================
// BACKGROUND COLORS (40-47 standard, 100-107 bright)
// ============================================================================
#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"
// Bright/Light background colors (100-107)
#define ANSI_BG_BRIGHT_BLACK "\x1b[100m"
#define ANSI_BG_BRIGHT_RED "\x1b[101m"
#define ANSI_BG_BRIGHT_GREEN "\x1b[102m"
#define ANSI_BG_BRIGHT_YELLOW "\x1b[103m"
#define ANSI_BG_BRIGHT_BLUE "\x1b[104m"
#define ANSI_BG_BRIGHT_MAGENTA "\x1b[105m"
#define ANSI_BG_BRIGHT_CYAN "\x1b[106m"
#define ANSI_BG_BRIGHT_WHITE "\x1b[107m"
// ============================================================================
// 256-COLOR MODE (for more colors)
// ============================================================================
// Foreground: \x1b[38;5;Nm where N is 0-255
// Background: \x1b[48;5;Nm where N is 0-255
// Example macros:
#define ANSI_FG_256(N) "\x1b[38;5;" #N "m"
#define ANSI_BG_256(N) "\x1b[48;5;" #N "m"
// ============================================================================
// TRUE COLOR / 24-BIT COLOR (RGB)
// ============================================================================
// Foreground: \x1b[38;2;R;G;Bm
// Background: \x1b[48;2;R;G;Bm
// Example macros:
#define ANSI_FG_RGB(R,G,B) "\x1b[38;2;" #R ";" #G ";" #B "m"
#define ANSI_BG_RGB(R,G,B) "\x1b[48;2;" #R ";" #G ";" #B "m"
// ============================================================================
// CURSOR MOVEMENT
// ============================================================================
#define ANSI_CURSOR_UP(N) "\x1b[" #N "A" // Move up N lines
#define ANSI_CURSOR_DOWN(N) "\x1b[" #N "B" // Move down N lines
#define ANSI_CURSOR_RIGHT(N) "\x1b[" #N "C" // Move right N columns
#define ANSI_CURSOR_LEFT(N) "\x1b[" #N "D" // Move left N columns
#define ANSI_CURSOR_HOME "\x1b[H" // Move to home (0,0)
#define ANSI_CURSOR_HIDE "\x1b[?25l" // Hide cursor
#define ANSI_CURSOR_SHOW "\x1b[?25h" // Show cursor
// ============================================================================
// SCREEN CONTROL
// ============================================================================
#define ANSI_CLEAR_SCREEN "\x1b[2J" // Clear entire screen
#define ANSI_CLEAR_LINE "\x1b[K" // Clear from cursor to end of line
#define ANSI_CLEAR_UP "\x1b[1J" // Clear from cursor to start
#define ANSI_CLEAR_DOWN "\x1b[0J" // Clear from cursor to end
// ============================================================================
// EXAMPLE USAGE
// ============================================================================
/*
#include <stdio.h>
int main(void) {
// Simple color example
printf("%sHello in Red%s\n", ANSI_RED, ANSI_RESET);
// Bold and colored
printf("%s%sBold Green%s\n", ANSI_BOLD, ANSI_GREEN, ANSI_RESET);
// Background color
printf("%s%sYellow on Blue%s\n", ANSI_YELLOW, ANSI_BG_BLUE, ANSI_RESET);
// Combine multiple styles
printf("%s%s%sUnderlined Bold Cyan%s\n",
ANSI_UNDERLINE, ANSI_BOLD, ANSI_CYAN, ANSI_RESET);
return 0;
}
*/
#endif
+172 -161
View File
@@ -1,161 +1,172 @@
#ifndef DATA_H_
#define DATA_H_
#include <stdio.h>
#include <termios.h>
#include <time.h>
#include "lisp.h"
/**
* \struct erow
* \brief Store one editor row
* \param
* */
typedef struct frow {
int size; /**< Size of the line */
int rsize; /**< Size of the render line */
char *chars; /**< Characters of the line */
char *render; /**< The actual line we will print */
} frow;
/**
* @brief Split modes for screen layout
*/
typedef enum {
SPLIT_NONE = 0, // Single buffer fullscreen
SPLIT_VERTICAL, // Left-right split
SPLIT_HORIZONTAL // Top-bottom split
} SplitMode;
/**
* @brief Represents an editor viewport/pane
*/
typedef struct {
int buffer_id; // Which buffer this pane displays
int start_row; // Starting row on screen
int start_col; // Starting column on screen
int height; // Height of this pane
int width; // Width of this pane
int cursor_x; // Local cursor x in this pane
int cursor_y; // Local cursor y in this pane
int rx, ry;
int row_offset; // Scroll offset for rows
int col_offset; // Scroll offset for columns
int is_active; // Is this pane currently active
} EditorPane;
/**
* @brief Screen layout manager
*/
typedef struct {
SplitMode mode;
EditorPane *panes;
int num_panes;
int active_pane; // Index of active pane
} ScreenLayout;
typedef struct theme {
char *BACKGROUND_COLOR;
char *COLOR_KEYWORD;
char *COLOR_TYPE;
char *COLOR_STRING;
char *COLOR_COMMENT;
char *COLOR_NUMBER;
char *COLOR_DEFAULT;
} theme_t;
enum bufferStatus_e {
IDLE,
READ_ONLY,
READ_AND_WRITE,
};
struct const_t {
int TAB_LENGTH;
int QUIT_TIMES;
char *THEME;
};
struct prefix_t {
char prefix_name[64];
int prefix_id;
};
struct keyBind_t {
char *key_sequence;
int prefix_id;
Lisp command;
};
enum buffer_type { FILE_BUFF, TERMINAL_BUFF };
struct buffer_t {
enum buffer_type type;
int buffer_id;
int width, height;
int x, y; /**< Position in the buffer (cursor) */
frow *row;
int numrows;
char *filename;
enum bufferStatus_e state;
int dirty; /**< Has this buffer been modified since last save */
int row_offset; /**< Scroll offset for rows in this buffer */
int col_offset; /**< Scroll offset for columns in this buffer */
};
/**
* \struct editorConfig
* \brief Containing our editor state.
*/
struct editorConfig {
int screenrows; /**< Terminal height*/
int screencols; /**< Terminal width*/
ScreenLayout layout;
int dirty;
int prefix_state;
char status_msg[80];
time_t status_msg_time;
struct termios orig_termios; /**< Terminal communication interface */
struct const_t constantes;
int quit_times_buffer;
char *init_file_path;
FILE *fd_init_file;
Lisp env;
LispContext ctx; /** Lisp context */
Lisp ctx_data; /** Lisp data context */
LispError ctx_error; /** Lisp ctx error */
struct keyBind_t *key_binds;
int number_of_keybinds;
struct prefix_t *prefix;
int number_of_prefix;
struct buffer_t buffers[64];
int number_of_buffer;
theme_t theme;
};
/**
* \struct abuf
* \brief Contains text to add before writing to screen.
* */
struct abuf {
char *b; /**< Text that will be printed */
int len; /**< Length of the text */
};
extern struct editorConfig E;
#endif
#ifndef DATA_H_
#define DATA_H_
#include <stdio.h>
#include <time.h>
#ifdef _WIN32
#include "termiWin.h"
#else
#include <termios.h>
#endif
#include "lisp.h"
/**
* \struct erow
* \brief Store one editor row
* \param
* */
typedef struct frow {
int size; /**< Size of the line */
int rsize; /**< Size of the render line */
char *chars; /**< Characters of the line */
char *render; /**< The actual line we will print */
} frow;
/**
* @brief Split modes for screen layout
*/
typedef enum {
SPLIT_NONE = 0, // Single buffer fullscreen
SPLIT_VERTICAL, // Left-right split
SPLIT_HORIZONTAL // Top-bottom split
} SplitMode;
/**
* @brief Represents an editor viewport/pane
*/
typedef struct {
int buffer_id; // Which buffer this pane displays
int start_row; // Starting row on screen
int start_col; // Starting column on screen
int height; // Height of this pane
int width; // Width of this pane
int cursor_x; // Local cursor x in this pane
int cursor_y; // Local cursor y in this pane
int rx, ry;
int row_offset; // Scroll offset for rows
int col_offset; // Scroll offset for columns
int is_active; // Is this pane currently active
} EditorPane;
/**
* @brief Screen layout manager
*/
typedef struct {
SplitMode mode;
EditorPane *panes;
int num_panes;
int active_pane; // Index of active pane
} ScreenLayout;
typedef struct theme {
char *BACKGROUND_COLOR;
char *COLOR_KEYWORD;
char *COLOR_TYPE;
char *COLOR_STRING;
char *COLOR_COMMENT;
char *COLOR_NUMBER;
char *COLOR_DEFAULT;
} theme_t;
enum bufferStatus_e {
IDLE,
READ_ONLY,
READ_AND_WRITE,
};
struct const_t {
int TAB_LENGTH;
int QUIT_TIMES;
char *THEME;
};
struct prefix_t {
char prefix_name[64];
int prefix_id;
};
struct keyBind_t {
char *key_sequence;
int prefix_id;
Lisp command;
};
enum buffer_type { FILE_BUFF, TERMINAL_BUFF };
struct buffer_t {
enum buffer_type type;
int buffer_id;
int width, height;
int x, y; /**< Position in the buffer (cursor) */
frow *row;
int numrows;
char *filename;
enum bufferStatus_e state;
int dirty; /**< Has this buffer been modified since last save */
int row_offset; /**< Scroll offset for rows in this buffer */
int col_offset; /**< Scroll offset for columns in this buffer */
// Terminal-specific data
char *terminal_command; /**< Current command being executed */
int terminal_pid; /**< Process ID of running terminal command */
char *terminal_output; /**< Captured terminal output */
int terminal_output_size; /**< Size of terminal output */
};
/**
* \struct editorConfig
* \brief Containing our editor state.
*/
struct editorConfig {
int screenrows; /**< Terminal height*/
int screencols; /**< Terminal width*/
ScreenLayout layout;
int dirty;
int prefix_state;
char status_msg[80];
time_t status_msg_time;
struct termios orig_termios; /**< Terminal communication interface */
struct const_t constantes;
int quit_times_buffer;
char *init_file_path;
FILE *fd_init_file;
Lisp env;
LispContext ctx; /** Lisp context */
Lisp ctx_data; /** Lisp data context */
LispError ctx_error; /** Lisp ctx error */
struct keyBind_t *key_binds;
int number_of_keybinds;
struct prefix_t *prefix;
int number_of_prefix;
struct buffer_t buffers[64];
int number_of_buffer;
theme_t theme;
};
/**
* \struct abuf
* \brief Contains text to add before writing to screen.
* */
struct abuf {
char *b; /**< Text that will be printed */
int len; /**< Length of the text */
};
extern struct editorConfig E;
#endif
+29 -29
View File
@@ -1,29 +1,29 @@
#ifndef DEFINE_H_
#define DEFINE_H_
#define CTRL_KEY(k) ((k) & 0x1f)
#define ESCAPE '\x1b'
#define CURSOR_TOP_LEFT "\x1b[H"
#define HIDE_CURSOR "\x1b[?25l"
#define SHOW_CURSOR "\x1b[?25h"
#define ERASE_END_LINE "\x1b[K"
enum editorKey {
BACKSPACE = 127,
ARROW_LEFT = 1000,
ARROW_RIGHT,
ARROW_UP,
ARROW_DOWN,
DEL_KEY,
BEG_LINE,
END_LINE,
PAGE_UP,
PAGE_DOWN,
};
#define ABUF_INIT {NULL, 0}
#define BELUGA_VERSION "1.1"
#endif // DEFINE_H_
#ifndef DEFINE_H_
#define DEFINE_H_
#define CTRL_KEY(k) ((k) & 0x1f)
#define ESCAPE '\x1b'
#define CURSOR_TOP_LEFT "\x1b[H"
#define HIDE_CURSOR "\x1b[?25l"
#define SHOW_CURSOR "\x1b[?25h"
#define ERASE_END_LINE "\x1b[K"
enum editorKey {
BACKSPACE = 127,
ARROW_LEFT = 1000,
ARROW_RIGHT,
ARROW_UP,
ARROW_DOWN,
DEL_KEY,
BEG_LINE,
END_LINE,
PAGE_UP,
PAGE_DOWN,
};
#define ABUF_INIT {NULL, 0}
#define BELUGA_VERSION "1.1"
#endif // DEFINE_H_
+13 -13
View File
@@ -1,13 +1,13 @@
#ifndef EDITOR_OP_H_
#define EDITOR_OP_H_
#include "data.h"
void bufferInsertChar(int c);
void bufferInsertNewLine();
void bufferDelChar();
void editorSetStatusMessage(const char *fmt, ...);
#endif // EDITOR_OP_H_
#ifndef EDITOR_OP_H_
#define EDITOR_OP_H_
#include "data.h"
void bufferInsertChar(int c);
void bufferInsertNewLine();
void bufferDelChar();
void editorSetStatusMessage(const char *fmt, ...);
#endif // EDITOR_OP_H_
+22 -22
View File
@@ -1,22 +1,22 @@
#ifndef FILE_IO_H_
#define FILE_IO_H_
#include "data.h"
#include "row_op.h"
#include "terminal.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
char *bufferRowsToString(struct buffer_t *buf,int *buffer_len);
void editorCloseFile(void);
void editorOpen(struct buffer_t *buffer);
void editorSave();
void bufferFind(struct buffer_t *buf);
#endif // FILE_IO_H_
#ifndef FILE_IO_H_
#define FILE_IO_H_
#include "data.h"
#include "row_op.h"
#include "terminal.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
char *bufferRowsToString(struct buffer_t *buf,int *buffer_len);
void editorCloseFile(void);
void editorOpen(struct buffer_t *buffer);
void editorSave();
void bufferFind(struct buffer_t *buf);
#endif // FILE_IO_H_
+18 -18
View File
@@ -1,18 +1,18 @@
#ifndef INIT_H_
#define INIT_H_
#include "builtins.h"
#include "data.h"
#include "terminal.h"
#include <stdio.h>
/**
* \fn void initEditor()
* \brief Job's function is to initialize all the fields of editorConfig.
* */
void initBuiltins();
void initEditor();
#endif // INIT_H_
#ifndef INIT_H_
#define INIT_H_
#include "builtins.h"
#include "data.h"
#include "terminal.h"
#include <stdio.h>
/**
* \fn void initEditor()
* \brief Job's function is to initialize all the fields of editorConfig.
* */
void initBuiltins();
void initEditor();
#endif // INIT_H_
+38 -38
View File
@@ -1,38 +1,38 @@
#ifndef INPUT_H_
#define INPUT_H_
#include "data.h"
#include "define.h"
#include "output.h"
#include "terminal.h"
#include "builtins.h"
#include <unistd.h>
// KEYS keycode
//
// ARROW_UP \x1b[A
// ARROW_DOWN \x1b[B
// ARROW_RIGHT \x1b[C
// ARROW_LEFT \x1b[D
// PAGE_UP \x1b[5~
// PAGE_DOWN \x1b[6~
// HOME \x1b[1~ || <esc>[7~ || <esc>[H || <esc>OH
// END \x1b[4~ || <esc>[8~ || <esc>[F || <esc>OF
// DELETE \x1b[3~
char *editorPrompt(char *prompt, char * PlaceHolder, char bPathMode);
char *key_to_string(int key);
int editorMoveCursor(int key);
int executeKeyBind(char *key_sequence);
/**
* \fn void editorProcessKeypress()
* \brief Get the last key input and do the proper action.
*/
void editorProcessKeypress();
#endif // INPUT_H_
#ifndef INPUT_H_
#define INPUT_H_
#include "data.h"
#include "define.h"
#include "output.h"
#include "terminal.h"
#include "builtins.h"
#include <unistd.h>
// KEYS keycode
//
// ARROW_UP \x1b[A
// ARROW_DOWN \x1b[B
// ARROW_RIGHT \x1b[C
// ARROW_LEFT \x1b[D
// PAGE_UP \x1b[5~
// PAGE_DOWN \x1b[6~
// HOME \x1b[1~ || <esc>[7~ || <esc>[H || <esc>OH
// END \x1b[4~ || <esc>[8~ || <esc>[F || <esc>OF
// DELETE \x1b[3~
char *editorPrompt(char *prompt, char * PlaceHolder, char bPathMode);
char *key_to_string(int key);
int editorMoveCursor(int key);
int executeKeyBind(char *key_sequence);
/**
* \fn void editorProcessKeypress()
* \brief Get the last key input and do the proper action.
*/
void editorProcessKeypress();
#endif // INPUT_H_
+3220 -3218
View File
File diff suppressed because it is too large Load Diff
+2177 -2177
View File
File diff suppressed because it is too large Load Diff
+22 -22
View File
@@ -1,22 +1,22 @@
#ifndef OUTPUT_H_
#define OUTPUT_H_
#include "data.h"
#include <unistd.h>
/**
* \fn void editorDrawRows(struct editorConfig *E, struct abuf *ab)
* \brief Draws left rows of the editor.
*/
void editorDrawRows(struct abuf *ab);
void editorRefreshScreen();
void editorScroll();
void editorDrawStatusBar(struct abuf *ab);
void editorDrawMessageBar(struct abuf *ab);
#endif // OUTPUT_H_
#ifndef OUTPUT_H_
#define OUTPUT_H_
#include "data.h"
#include <unistd.h>
/**
* \fn void editorDrawRows(struct editorConfig *E, struct abuf *ab)
* \brief Draws left rows of the editor.
*/
void editorDrawRows(struct abuf *ab);
void editorRefreshScreen();
void editorScroll();
void editorDrawStatusBar(struct abuf *ab);
void editorDrawMessageBar(struct abuf *ab);
#endif // OUTPUT_H_
+29 -29
View File
@@ -1,29 +1,29 @@
#ifndef ROW_OP_H_
#define ROW_OP_H_
#include "data.h"
#include "define.h"
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
int bufferRowCxToRx(frow *row, int cursor_x);
int bufferRowRxToCx(frow *row, int rx);
void bufferUpdatfrow(frow *row);
void bufferInsertRow(struct buffer_t *buffer, int at, char *s, size_t len);
void bufferFrefrow(frow *row);
void bufferDelRow(struct buffer_t *buffer, int at);
void bufferRowInsertChar(struct buffer_t *buffer, frow *row, int at, int c);
void bufferRowAppendString(struct buffer_t *buffer, frow *row, char *s, size_t len);
void bufferRowDelchar(struct buffer_t *buffer, frow *row, int at);
#endif // ROW_OP_H_
#ifndef ROW_OP_H_
#define ROW_OP_H_
#include "data.h"
#include "define.h"
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
int bufferRowCxToRx(frow *row, int cursor_x);
int bufferRowRxToCx(frow *row, int rx);
void bufferUpdatfrow(frow *row);
void bufferInsertRow(struct buffer_t *buffer, int at, char *s, size_t len);
void bufferFrefrow(frow *row);
void bufferDelRow(struct buffer_t *buffer, int at);
void bufferRowInsertChar(struct buffer_t *buffer, frow *row, int at, int c);
void bufferRowAppendString(struct buffer_t *buffer, frow *row, char *s, size_t len);
void bufferRowDelchar(struct buffer_t *buffer, frow *row, int at);
#endif // ROW_OP_H_
+62 -62
View File
@@ -1,62 +1,62 @@
/**
* @file split_screen.h
* @brief Split screen management for displaying multiple buffers
*/
#ifndef SPLIT_SCREEN_H_
#define SPLIT_SCREEN_H_
#include "data.h"
/**
* @brief Initializes split screen system
*/
void splitScreenInit(void);
/**
* @brief Splits screen vertically (left-right)
* @param buffer_id_left Buffer ID for left pane
* @param buffer_id_right Buffer ID for right pane
* @return 0 on success, -1 on failure
*/
int splitScreenVertical(int buffer_id_left, int buffer_id_right);
/**
* @brief Splits screen horizontally (top-bottom)
* @param buffer_id_top Buffer ID for top pane
* @param buffer_id_bottom Buffer ID for bottom pane
* @return 0 on success, -1 on failure
*/
int splitScreenHorizontal(int buffer_id_top, int buffer_id_bottom);
/**
* @brief Returns to single buffer fullscreen
*/
void splitScreenUnify(void);
/**
* @brief Switches active pane (focus moves between splits)
* @return 0 on success, -1 on failure
*/
int splitScreenSwitchPane(void);
/**
* @brief Updates the active pane's buffer
* @param buffer_id New buffer ID for active pane
* @return 0 on success, -1 on failure
*/
int splitScreenSetPaneBuffer(int buffer_id);
/**
* @brief Gets current screen layout
* @return Pointer to current ScreenLayout
*/
ScreenLayout *splitScreenGetLayout(void);
/**
* @brief Gets active pane
* @return Pointer to active EditorPane
*/
EditorPane *splitScreenGetActivePane(void);
#endif
/**
* @file split_screen.h
* @brief Split screen management for displaying multiple buffers
*/
#ifndef SPLIT_SCREEN_H_
#define SPLIT_SCREEN_H_
#include "data.h"
/**
* @brief Initializes split screen system
*/
void splitScreenInit(void);
/**
* @brief Splits screen vertically (left-right)
* @param buffer_id_left Buffer ID for left pane
* @param buffer_id_right Buffer ID for right pane
* @return 0 on success, -1 on failure
*/
int splitScreenVertical(int buffer_id_left, int buffer_id_right);
/**
* @brief Splits screen horizontally (top-bottom)
* @param buffer_id_top Buffer ID for top pane
* @param buffer_id_bottom Buffer ID for bottom pane
* @return 0 on success, -1 on failure
*/
int splitScreenHorizontal(int buffer_id_top, int buffer_id_bottom);
/**
* @brief Returns to single buffer fullscreen
*/
void splitScreenUnify(void);
/**
* @brief Switches active pane (focus moves between splits)
* @return 0 on success, -1 on failure
*/
int splitScreenSwitchPane(void);
/**
* @brief Updates the active pane's buffer
* @param buffer_id New buffer ID for active pane
* @return 0 on success, -1 on failure
*/
int splitScreenSetPaneBuffer(int buffer_id);
/**
* @brief Gets current screen layout
* @return Pointer to current ScreenLayout
*/
ScreenLayout *splitScreenGetLayout(void);
/**
* @brief Gets active pane
* @return Pointer to active EditorPane
*/
EditorPane *splitScreenGetActivePane(void);
#endif
+24 -23
View File
@@ -1,23 +1,24 @@
#ifndef SYNTAX_HIGHLIGHTER_H_
#define SYNTAX_HIGHLIGHTER_H_
#include "color.h"
// Color codes that only affect foreground, preserving your background color
#define COLOR_RESET "\x1b[39m" // Reset all (4 bytes)
// Token types
typedef enum {
TOKEN_KEYWORD,
TOKEN_TYPE,
TOKEN_STRING,
TOKEN_COMMENT,
TOKEN_NUMBER,
TOKEN_OPERATOR,
TOKEN_DEFAULT
} TokenType;
char *highlight_line(const char * line, int *length);
#endif
#ifndef SYNTAX_HIGHLIGHTER_H_
#define SYNTAX_HIGHLIGHTER_H_
#include "color.h"
// Color codes that only affect foreground, preserving your background color
#define COLOR_RESET "\x1b[39m" // Reset all (4 bytes)
// Token types
typedef enum {
TOKEN_KEYWORD,
TOKEN_DATATYPE,
TOKEN_STRING,
TOKEN_COMMENT,
TOKEN_NUMBER,
TOKEN_OPERATOR,
TOKEN_DEFAULT
} SyntaxTokenType;
const char *get_color(SyntaxTokenType type);
char *highlight_line(const char * line, int *length);
#endif
+217
View File
@@ -0,0 +1,217 @@
/* termiWin.h
*
* Copyright (C) 2017 Christian Visintin - christian.visintin1997@gmail.com
*
* This file is part of "termiWin: a termios porting for Windows"
*
* termiWin is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* termiWin is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with termiWin. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#ifndef TERMIWIN_H_
#define TERMIWIN_H_
#define TERMIWIN_VERSION "1.2.0"
#define TERMIWIN_MAJOR_VERSION 1
#define TERMIWIN_MINOR_VERSION 2
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winsock2.h>
#ifdef _MSC_VER
#pragma comment(lib, "Ws2_32.lib")
#endif
/*Redefining functions from winsock to termiWin. This is very important since winsock2 defines functions such as close as closesocket we have to redefine it*/
#ifdef __MINGW32__
#define TERMIWIN_DONOTREDEFINE
#endif
#ifndef TERMIWIN_DONOTREDEFINE
#define read read_serial
#define write serial_write
#define open open_serial
#define close close_serial
#define select select_serial
#endif
#if !defined(SSIZE_MAX)
// ssize_t
#if SIZE_MAX == UINT_MAX
typedef int ssize_t; /* common 32 bit case */
#define SSIZE_MAX INT_MAX
#elif SIZE_MAX == ULONG_MAX
typedef long ssize_t; /* linux 64 bits */
#define SSIZE_MAX LONG_MAX
#elif SIZE_MAX == ULLONG_MAX
typedef long long ssize_t; /* windows 64 bits */
#define SSIZE_MAX LLONG_MAX
#endif
#endif
//Serial options - Linux -> Windows
/*setAttr flags - ~ in front of flags -> deny them*/
//iFlag
#define INPCK 0x00004000 /*If this bit is set, input parity checking is enabled. If it is not set, no checking at all is done for parity errors on input; the characters are simply passed through to the application.*/
#define IGNPAR 0x00001000 /*If this bit is set, any byte with a framing or parity error is ignored. This is only useful if INPCK is also set.*/
#define PARMRK 0x00040000 /*If this bit is set, input bytes with parity or framing errors are marked when passed to the program. This bit is meaningful only when INPCK is set and IGNPAR is not set.*/
#define ISTRIP 0x00008000 /*If this bit is set, valid input bytes are stripped to seven bits; otherwise, all eight bits are available for programs to read. */
#define IGNBRK 0x00000400 /*If this bit is set, break conditions are ignored. */
#define BRKINT 0x00000100 /*If this bit is set and IGNBRK is not set, a break condition clears the terminal input and output queues and raises a SIGINT signal for the foreground process group associated with the terminal. */
#define IGNCR 0x00000800 /*If this bit is set, carriage return characters ('\r') are discarded on input. Discarding carriage return may be useful on terminals that send both carriage return and linefeed when you type the RET key. */
#define ICRNL 0x00000200 /*If this bit is set and IGNCR is not set, carriage return characters ('\r') received as input are passed to the application as newline characters ('\n').*/
#define INLCR 0x00002000 /*If this bit is set, newline characters ('\n') received as input are passed to the application as carriage return characters ('\r').*/
#define IXOFF 0x00010000 /*If this bit is set, start/stop control on input is enabled. In other words, the computer sends STOP and START characters as necessary to prevent input from coming in faster than programs are reading it. The idea is that the actual terminal hardware that is generating the input data responds to a STOP character by suspending transmission, and to a START character by resuming transmission.*/
#define IXON 0x00020000 /*If this bit is set, start/stop control on output is enabled. In other words, if the computer receives a STOP character, it suspends output until a START character is received. In this case, the STOP and START characters are never passed to the application program. If this bit is not set, then START and STOP can be read as ordinary characters.*/
//lFlag
#define ICANON 0x00001000 /*This bit, if set, enables canonical input processing mode. Otherwise, input is processed in noncanonical mode. */
#define ECHO 0x00000100 /*If this bit is set, echoing of input characters back to the terminal is enabled.*/
#define ECHOE 0x00000200 /*If this bit is set, echoing indicates erasure of input with the ERASE character by erasing the last character in the current line from the screen. Otherwise, the character erased is re-echoed to show what has happened (suitable for a printing terminal). */
#define ECHOK 0x00000400 /*This bit enables special display of the KILL character by moving to a new line after echoing the KILL character normally. The behavior of ECHOKE (below) is nicer to look at.*/
#define ECHONL 0x00000800 /*If this bit is set and the ICANON bit is also set, then the newline ('\n') character is echoed even if the ECHO bit is not set. */
#define ISIG 0x00004000 /*This bit controls whether the INTR, QUIT, and SUSP characters are recognized. The functions associated with these characters are performed if and only if this bit is set. Being in canonical or noncanonical input mode has no effect on the interpretation of these characters. */
#define IEXTEN 0x00002000 /*On BSD systems and GNU/Linux and GNU/Hurd systems, it enables the LNEXT and DISCARD characters.*/
#define NOFLSH 0x00008000 /*Normally, the INTR, QUIT, and SUSP characters cause input and output queues for the terminal to be cleared. If this bit is set, the queues are not cleared. */
#define TOSTOP 0x00010000 /*If this bit is set and the system supports job control, then SIGTTOU signals are generated by background processes that attempt to write to the terminal.*/
//cFlag
#define CSTOPB 0x00001000 /*If this bit is set, two stop bits are used. Otherwise, only one stop bit is used. */
#define PARENB 0x00004000 /*If this bit is set, generation and detection of a parity bit are enabled*/
#define PARODD 0x00008000 /*This bit is only useful if PARENB is set. If PARODD is set, odd parity is used, otherwise even parity is used. */
#define CSIZE 0x00000c00 /*This is a mask for the number of bits per character. */
#define CS5 0x00000000 /*This specifies five bits per byte. */
#define CS6 0x00000400 /*This specifies six bits per byte. */
#define CS7 0x00000800 /*This specifies seven bits per byte. */
#define CS8 0x00000c00 /*This specifies eight bits per byte. */
#define CLOCAL 0x00000000 /*Ignore modem control lines -> ignore data carrier detected - not implementable in windows*/
#define CREAD 0x00000000 /*Enable receiver - if is not set no character will be received*/
//oFlag
#define OPOST 0x00000100 /*If this bit is set, output data is processed in some unspecified way so that it is displayed appropriately on the terminal device. This typically includes mapping newline characters ('\n') onto carriage return and linefeed pairs. */
//cc
#define VEOF 0
#define VEOL 1
#define VERASE 2
#define VINTR 3
#define VKILL 4
#define VMIN 5 /*If set to 0, serial communication is NOT-BLOCKING, otherwise is BLOCKING*/
#define VQUIT 6
#define VSTART 7
#define VSTOP 8
#define VSUSP 9
#define VTIME 10
//END OF setAttr flags
/*Controls*/
#define TIOMBIC DTR_CONTROL_DISABLE
#define TIOMBIS DTR_CONTROL_ENABLE
#define CRTSCTS RTS_CONTROL_ENABLE
/*Others*/
#define NCCS 11
//Baud speed
#define B110 CBR_110
#define B300 CBR_300
#define B600 CBR_600
#define B1200 CBR_2400
#define B2400 CBR_2400
#define B4800 CBR_4800
#define B9600 CBR_9600
#define B19200 CBR_19200
#define B38400 CBR_38400
#define B57600 CBR_57600
#define B115200 CBR_115200
/*Attributes optional_actions*/
#define TCSANOW 0
#define TCSADRAIN 1
#define TCSAFLUSH 2
/*TCFLUSH options*/
#define TCIFLUSH 0
#define TCOFLUSH 1
#define TCIOFLUSH 2
/*TCFLOW optons*/
#define TCOOFF 0
#define TCOON 1
#define TCIOFF 2
#define TCION 3
//typdef
typedef unsigned tcflag_t; /*This is an unsigned integer type used to represent the various bit masks for terminal flags.*/
typedef unsigned cc_t; /*This is an unsigned integer type used to represent characters associated with various terminal control functions.*/
typedef unsigned speed_t; /*used for terminal baud rates*/
typedef struct termios
{
tcflag_t c_iflag; /*input modes*/
tcflag_t c_oflag; /*output modes*/
tcflag_t c_cflag; /*control modes*/
tcflag_t c_lflag; /*local modes*/
cc_t c_cc[NCCS]; /*special character*/
} termios;
//Serial configuration functions
int tcgetattr(int fd, struct termios *termios_p);
int tcsetattr(int fd, int optional_actions, const struct termios *termios_p);
int tcsendbreak(int fd, int duration);
int tcdrain(int fd);
int tcflush(int fd, int queue_selector);
int tcflow(int fd, int action);
void cfmakeraw(struct termios *termios_p);
speed_t cfgetispeed(const struct termios *termios_p);
speed_t cfgetospeed(const struct termios *termios_p);
int cfsetispeed(struct termios *termios_p, speed_t speed);
int cfsetospeed(struct termios *termios_p, speed_t speed);
int cfsetspeed(struct termios * termios_p, speed_t speed);
//Write/Read/Open/Close/Select Functions
ssize_t read_serial(int fd, void* buffer, size_t count);
ssize_t write_serial(int fd, const void* buffer, size_t count);
int open_serial(const char* portname, int opt);
int close_serial(int fd);
int select_serial(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
//get Handle out of the COM structure
HANDLE getHandle();
#endif
#ifndef _WIN32
#pragma message("-Warning: termiWin requires a Windows system!")
#endif
#endif
+33 -34
View File
@@ -1,34 +1,33 @@
#ifndef TERMINAL_H_
#define TERMINAL_H_
/* includes */
#include "data.h"
#include "define.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <termios.h>
#include <unistd.h>
/**
* \fn void die(const char *s)
* \brief Exit program and return s error message.
* \param *s Error string
* */
void die(const char *s);
void disableRawMode();
void enableRawMode();
int editorReadKey();
int getCursorPosition(int *rows, int *cols);
int getWindowSize(int *rows, int *cols);
#endif
#ifndef TERMINAL_H_
#define TERMINAL_H_
/* includes */
#include "data.h"
#include "define.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
// #include <sys/ioctl.h>
#include <unistd.h>
/**
* \fn void die(const char *s)
* \brief Exit program and return s error message.
* \param *s Error string
* */
void die(const char *s);
void disableRawMode();
void enableRawMode();
int editorReadKey();
int getCursorPosition(int *rows, int *cols);
int getWindowSize(int *rows, int *cols);
#endif
+32
View File
@@ -0,0 +1,32 @@
/* termios.h
*
* Copyright (C) 2017 Christian Visintin - christian.visintin1997@gmail.com
*
* This file is part of "termiWin: a termios porting for Windows"
*
* termiWin is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* termiWin is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with termiWin. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#ifdef _WIN32
#ifndef TERMIOS_H
#define TERMIOS_H
#include "termiWin.h"
#endif // TERMIOS_H
#endif // _WIN32