aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
...
* 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.
* fix: line_split allocating newline but not initializing correctlydilluti0n2025-04-291-0/+4
| | | | | The bug caused UB on splited newline. (especially when is_lazy = 1 unluckly)
* fix: SEGSEGV on line_get_last; NULL check for li should be first.dilluti0n2025-04-291-1/+3
|
* refactor: main draw routine to use eb_get_line_slice instead string.dilluti0n2025-04-293-10/+25
| | | | | Implement helper draw_text_slice which just allocate C-string on the stack and pass it to the DrawText.
* feat: add slice-based accessors for line and editor bufferdilluti0n2025-04-295-10/+50
| | | | | | | | | | | | | | | | | This adds `line_get_slice` and `eb_get_line_slice`, enabling slice-style (pointer + length) access to line contents without requiring materialization into a null-terminated string. - `line_get_slice` returns either the original mmap'd buffer (if the - line is lazy) or the materialized vector contents (if edited). - `eb_get_line_slice` wraps `line_get_slice` to provide safe access at - the editor buffer level. Update `line.h` and `editor.h` headers to - declare the new functions. Minor documentation improvements to - clarify "init", "modify", and "get" function categories. This prepares the codebase for transitioning away from C-string dependency where possible, improving efficiency and avoiding unnecessary memory copies.
* fix: SIGBUS when eb_save_filedilluti0n2025-04-291-4/+20
| | | | | | | | | When eb_save_file is called, it opens the file with fopen(eb->file_name, "w"). Since opening with "w" mode truncates the file size to 0, accessing the memory region previously mmap-ed to that file results in a SIGBUS error. To prevent this, the content is now first written to a temporary file at /tmp/%s.tmpXXXXXX, and then renamed to eb->file_name.
* fix: format string is not a string literal in eb_save_filedilluti0n2025-04-291-1/+1
| | | | Just kill warnings.
* refactor: decouple line.h from main.cdilluti0n2025-04-293-11/+14
| | | | | | | | 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`.
* test: update test_line.c to test lazy-loaded linesdilluti0n2025-04-291-10/+71
|
* fix: `line_free` to handle lazy-loaded line appropriately.dilluti0n2025-04-292-6/+10
| | | | | | | fix `line_cat` to handle lazy-loaded `src` line too [minor] add const keyword for line_get_last since it is.
* refactor: introduce lazy loading to each line buffer.dilluti0n2025-04-293-21/+54
| | | | | | | | | | | | | | | | | Each `struct line` now holds a pointer (`origin`) to its corresponding line in the mmap'd file, along with its length (`origin_len`). The `vec` field is no longer allocated for each line during `eb_load_file`. Instead, actual memory allocation and copying into `vec` occurs only when an edit is made or when `line_get_string` is called (since a C string is required). This behavior is handled via the internal inline function `edit_happen`. Also implement `vec_cat_raw` to `line_cat` when lazy `src`. [minor] Remove unused debug messages in editor.c.
* implement: produce_vec_from_buf to use it lazy loading.dilluti0n2025-04-291-6/+13
|
* remove: line->last to reduce ambiguity.dilluti0n2025-04-293-41/+25
| | | | | | | | | | vec_len is O(1) and it would be fast enough to use it. introduce line_lazy_init for lazy load (allocate each line when actually edit it!) per line. [minor] remove obsolate line_delete_trailing.
* perf: reduce to a single allocation in line_init_from_bufdilluti0n2025-04-292-4/+27
| | | | | | | | Previously, line_init_from_buf called line_init followed by vec_resize, which could result in up to two separate allocations. This patch introduces vec_init_with_capacity, allowing the vector to be initialized with the required capacity in a single step, reducing allocation overhead.
* perf: improve vec_resize to not realloc again and againdilluti0n2025-04-291-1/+7
|
* feat: add right control C-sdilluti0n2025-04-291-2/+3
|
* remove uncontroled logdilluti0n2025-04-291-1/+0
|
* fix: add CRLF handling to eb_load_filedilluti0n2025-04-291-1/+6
|
* perf: make line from buf directly instead of append each charactersdilluti0n2025-04-293-6/+17
| | | | implement line_init_from_buf for this.
* perf: use line_append and push instead of eb_insertdilluti0n2025-04-291-14/+13
|
* perf: replace byte-by-byte scanning with memchr in eb_load_filedilluti0n2025-04-281-6/+16
| | | | | This reduces unnecessary per-byte branching by scanning for newlines more efficiently when loading files.
* implement: eb_load_file using mmapdilluti0n2025-04-281-1/+49
| | | | | [minor] add check for eb_save_file when fopen fails.
* fix: asser fail in eb_backspace, eb_newline due to invalid accessdilluti0n2025-04-282-18/+24
| | | | | | | | | | | | | | | | | | | | | In the current design, `eb->cur_row` can range up to `Vec_slinep_len(eb->line_vec)`, allowing insertion of a new line at the end of the buffer. However, directly accessing this index caused assertion failures, as the `eb_*` series of functions operate on an abstracted structure, not the raw vector. To resolve this, a new abstraction layer `eb_delete_line` was introduced to handle boundary checks properly. The `eb_*` functions now call `eb_delete_line` instead of accessing the vector directly. Similarly, `line_get_last` was modified to return 0 when called on a `NULL` (unallocated) line to avoid unnecessary assertions. From now on, the `eb_*` series should only directly call vector macros when absolutely necessary. [minor] Rename `eb_set_cur_next` and `eb_set_cur_back`
* refactor: organize editor.h to look pretty :)dilluti0n2025-04-281-6/+10
|
* add keyboard shortcut C-s to save filedilluti0n2025-04-281-13/+13
|
* implement: eb_save_filedilluti0n2025-04-281-10/+24
| | | | | [minor] move eb_free to front of file
* change: executable name rayedit to reddilluti0n2025-04-282-2/+3
| | | | for faster debuging :)
* add: basic i/o structure on main rendering loopdilluti0n2025-04-283-0/+33
| | | | | 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.
* refactor: no single line hidden expression on test_vector.cdilluti0n2025-04-281-10/+25
|
* organize TODO.orgdilluti0n2025-04-281-11/+16
|
* fix: eb_set_cur_next does not recovering cached cursor from line.dilluti0n2025-04-282-8/+6
| | | | | [minor] add argc and argv to main routine.
* Move TODO to TODO.orgdilluti0n2025-04-282-3/+26
|
* refactor: line_test.cdilluti0n2025-04-281-10/+23
|
* update TODOdilluti0n2025-04-281-26/+2
|
* implement: unittest for line.cdilluti0n2025-04-281-16/+134
|
* implement: uniittest vector_suite::delete_single and *::delete_rangedilluti0n2025-04-281-0/+68
|
* implement: uniittest vector_suite::splitdilluti0n2025-04-281-0/+64
|
* implement: uniittest vector_suite::catdilluti0n2025-04-281-1/+67
|
* implement: unit test vector_suite::insert_vectordilluti0n2025-04-281-0/+70
|
* implement: vec_cleardilluti0n2025-04-281-0/+4
| | | | It just bump size to 0.
* implement: unit test vector_suite::popdilluti0n2025-04-281-0/+33
|
* refactor: move tests to seperate filesdilluti0n2025-04-284-113/+155
| | | | | | test.c to *_line.c and *_vector.c also implement unit test vector_suite::resize too.
* fix: possable memory leak on eb_freedilluti0n2025-04-281-1/+1
| | | | since it calls MemFree instead of line_free.
* refactor: move ed_* modules from main.c to editor.cdilluti0n2025-04-284-177/+206
|
* 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
|
* add: DEBUG variable on makefiledilluti0n2025-04-282-1/+6
| | | | add assertion on line_insert
* refactor: introduce helper function ensure_line for eb_insertdilluti0n2025-04-272-12/+19
|
* fix: inserting on newline cause segmentatnion faultdilluti0n2025-04-272-1/+3
| | | | | | | | | | 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.