summaryrefslogtreecommitdiff
path: root/main.c
Commit message (Collapse)AuthorAgeFilesLines
* refactor: abstract input/rendering modules from main routinedilluti0n2025-05-281-146/+11
| | | | | | This fetch moves raylib-specific logics to redr_raylib.c and input_raylib.c from main routine. Each apis are defined in redr.h and input.h respectively.
* refactor: replace #ifdef DEBUG printf to log_printfdilluti0n2025-05-141-8/+13
| | | | - fix log_printf to not automatically insert newline
* refactor: unify log level and stream setup via log_initdilluti0n2025-05-141-2/+2
| | | | | | | | - Replaced log_set_level() with log_init() to allow stream configuration. - log_fprintf() now uses an internal stream, defaulting to stdout. [minor] update log tags in TODO.org correctly
* refactor: integrate raylib logs to RED log levelsdilluti0n2025-05-131-6/+33
| | | | | - refactor enums in LOG_* to RED_LOG_* since its conflicting raylib namespaces
* feat: introduce log.c; log handling moduledilluti0n2025-05-101-1/+1
|
* fix: Memory Leak in eb_delete_linedilluti0n2025-05-101-1/+0
| | | | | | The function eb_delete_line did not properly free the contents of the entry when deleting an element from eb->line_vec. This patch fixes that issue.
* fix: possable buffer overflow when sl.len >= BUFSIZE on draw routinedilluti0n2025-05-011-2/+4
|
* fix: NULL check sl.ptr on main routine.dilluti0n2025-04-291-2/+2
| | | | | eb_get_line_string always return valid string, however eb_get_line_slice has a chance to return slice with NULL ptr.
* refactor: main draw routine to use eb_get_line_slice instead string.dilluti0n2025-04-291-6/+21
| | | | | Implement helper draw_text_slice which just allocate C-string on the stack and pass it to the DrawText.
* refactor: decouple line.h from main.cdilluti0n2025-04-291-4/+2
| | | | | | | | By making eb_get_line a static function within editor.c and introducing API wrappers that internally delegate to eb_get_line and line_get_string, thereby avoiding direct exposure of the line structure. Considering a future transition from C-style null-terminated strings to explicit length-based string management.
* perf: update draw loop to access actrually visable line only.dilluti0n2025-04-291-4/+9
| | | | | This is important for current line_get_stirng implementation, which allocates real vector when it is called with lazy loaded `li`.
* feat: add right control C-sdilluti0n2025-04-291-2/+3
|
* remove uncontroled logdilluti0n2025-04-291-1/+0
|
* add keyboard shortcut C-s to save filedilluti0n2025-04-281-13/+13
|
* add: basic i/o structure on main rendering loopdilluti0n2025-04-281-0/+13
| | | | | eb_bind binds file path to the ed_buf, eb_load_file loads to the buffer if exists and eb_save_file save the buffer to that path.
* fix: eb_set_cur_next does not recovering cached cursor from line.dilluti0n2025-04-281-3/+2
| | | | | [minor] add argc and argv to main routine.
* refactor: move ed_* modules from main.c to editor.cdilluti0n2025-04-281-175/+4
|
* change: eb_get_line to return NULL if index is 'appending' line.dilluti0n2025-04-281-23/+30
| | | | | | | | | implement eb_get_last and is_cur_col_last to get consistant abstraction for unallocated line or appending line. fix set_cur_forward to more straightforward way. [minor] refactor ensure_line to use single variable li.
* fix: draw routine cannot draw last line's cursordilluti0n2025-04-281-1/+1
|
* refactor: introduce helper function ensure_line for eb_insertdilluti0n2025-04-271-12/+16
|
* fix: inserting on newline cause segmentatnion faultdilluti0n2025-04-271-1/+2
| | | | | | | | | | This was rely on NULL-initialization of physically allocated vector. When I remove that feature, it immediatly segfalt since logically v->data[index] is not allocated so its not initialized by NULL yet. [minor] add assert on vec_get to avoid this kind of stupid mistake.
* implement: eb_set_cur_nextdilluti0n2025-04-271-1/+7
| | | | | [minor] add log cursor on draw loop.
* implement: eb_set_cur_forwarddilluti0n2025-04-271-6/+33
| | | | | fix: eb_set_cur_back to handle unallocated line correctly when called on head of the line.
* fix: eb_insert to grow line pointer array properlydilluti0n2025-04-271-4/+12
| | | | | | | | | | It was "inserting" the new line to the current eb->cur_row index. Which should just set or push (when inserting to the end of the buffer) to the eb->vec[eb->cur_row]. [minor] add assertion on vec_set. add debug lines on draw loop.
* fix: eb_newline to properly lazy allocate newlinedilluti0n2025-04-271-2/+5
| | | | | | | It was actually allocating line buf when insert empty line... [minor] refactor eb_init to indicates each field initialization well.
* fix: eb_backspace possable memory leakdilluti0n2025-04-271-18/+15
| | | | | | | | | | | Before deleting curr, it does not freeing it! [minor] optimize vec_delete; if sizeof v is 0, do not call memmove. refactor line_init to clearly indicates both value are initialized to 0. optimize line_cat; if src is empty (['\0']), do not call Vec_char_delete or something.
* implement: eb_set_cur_back and eb_set_cur_prevdilluti0n2025-04-271-2/+22
|
* modify: eb_newline to actually increase the vec when newlinedilluti0n2025-04-271-7/+6
| | | | | | | | | | | | | This is important because eb_backspace remove lines by the index of vector. Although there is pro for lazy allocation for actual line buffer, no-allocating line vector itself increase ambiguty too much. Also this commit removes the feature that eb_get_line returns NULL when its index is not correct, because this is ambiguouse with actual line pointer is NULL on line vector and causes unfindable bug. [minor] add assert on line_split
* add: draw cursor on rendering loopdilluti0n2025-04-271-1/+23
| | | | | [minor] implement eb_get_cur_col and *_row
* implement: eb_backspacedilluti0n2025-04-271-3/+23
| | | | | | | | | quite a nested function. to implement lazy allocation for line buffer. is there a proper way to do it??? [minor] fix warning msg on eb_insert which was incomplecation type on printf add <stdio.h> on config.h DEBUG section
* implement: eb_backspace; line_cat still TODOdilluti0n2025-04-271-6/+5
| | | | line_cat should be implemented; markd it TODO
* to-fix: add TODO for ed_backspace since it is not well implementeddilluti0n2025-04-271-2/+3
| | | | It was deleting entire upper line when backspaced on first column.
* refactor: move debugs to config.h and handle build gracefullydilluti0n2025-04-271-6/+2
| | | | | | | makefile now handle each object and sources seperately to handle header change gracefully. and from now on, #DEBUG should declared inside of config.h
* implement: eb_newlinedilluti0n2025-04-271-12/+26
| | | | | | | | | | | | | I move around most of because it did not update eb->cur_col correctly. implement line_split which use vec_split for it [minor] implement eb_get_line and eb_line_num refactor main routine to use them add DEBUG symbol to makefile and remove lines.o for OBJS move declaration struct line to line.c from line.h for enhanced OOP
* implement: line_deletedilluti0n2025-04-271-3/+4
| | | | | | | fix eb_backspace to actually backspace char, not delete it [minor] fix line_insert to handle li->last correctly
* change: vec_grow_size able to reduce the size toodilluti0n2025-04-241-1/+2
| | | | | Mark eb_newline as TODO because it is not able to insert newline on middle or end of the line.
* fix: eb_insert to move the cursor after insertiondilluti0n2025-04-241-1/+1
|
* change: vector.h now alloc/free its own handledilluti0n2025-04-241-3/+1
|
* implement: eb_backspacedilluti0n2025-04-241-9/+22
|
* fix: vector memory allocation and insert logic; cleanup eb handlingdilluti0n2025-04-211-16/+30
| | | | | | | | - Fixed incorrect `MemAlloc(sizeof(type *))` usage to properly allocate `sizeof(type)` for vector structs. - Corrected `memmove` call in vector insert to account for type size and copy full range. - Added `line_set_cursor()` to set line's cursor position before inserting new lines. - Replaced `line_arr` with `line_vec` in editor buffer for clearer naming. - Improved `DrawText` fallback behavior for NULL lines.
* refactor: line handling and implement basic editor buffer abstractiondilluti0n2025-04-211-20/+32
| | | | | | | | | | | | - Rename vector type VEC -> Vec_char for clarity - Update line.c to use renamed Vec_char API - Add `line_insert` function for character insertion at arbitrary positions - Define Vec_slinep as vector of line pointers in main.c - Introduce `struct ed_buf` as an abstraction for a text buffer - Implement `eb_insert`, `eb_free` and stub `eb_newline`, `eb_backspace` - Update main loop to use `ed_buf` instead of standalone line/lines - Fix vector insertion logic to support gaps and non-contiguous positions - Change optimization level in makefile to -O0 for easier debugging
* implement: eb_initdilluti0n2025-04-181-0/+37
| | | | ed_buf (editor buf) define the context of the editor.
* tabify, gitignore, add -Wextra to CFLAGSdilluti0n2025-04-181-12/+12
|
* refactor: Split lines management into its own moduledilluti0n2025-04-181-37/+3
| | | | Refactor the codebase to isolate line-collection logic from the main.c driver
* Add multi-line support using vector of line pointersdilluti0n2025-04-181-18/+62
| | | | | | | | | | | | * main.c: - Introduce VEC_LINE (vector of struct line *) using DEFINE_VECTOR macro - Create `struct lines` to hold current line buffer and all past lines - Implement `lines_init`, `lines_append_last`, `lines_get_last_line`, `lines_free` - Modify main loop: - On KEY_ENTER, current line is stored and a new line is allocated - On BACKSPACE, deletion is done in current line - All stored lines and the current line are drawn line-by-line with vertical spacing - Replace previous single-line logic (`lineh`) with full multi-line editor buffer
* tabifydilluti0n2025-04-181-11/+7
|
* refactor: Extract line handling logic into separate line moduledilluti0n2025-04-181-42/+5
| | | | | | | | - Moved line-related functions (init, append, clear, delete, free) out of main.c - Created new files: line.c and line.h to encapsulate `struct line` and its operations - Updated main.c to use the new line module - Simplified main.c by removing inline struct and function definitions - Adjusted makefile to compile line.o
* Implement line apidilluti0n2025-04-181-22/+55
| | | | Should be improved
* Implement vector moduledilluti0n2025-04-181-0/+3
|
* Implement simple real time interactive text renderingdilluti0n2025-04-181-0/+76
Dependancy: raylib-5.5_linux_amd64[1] [1] https://github.com/raysan5/raylib/releases/tag/5.5