summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
...
* 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.
* change: remove zero initialization on allocationdilluti0n2025-04-271-14/+24
| | | | | | | instead, this will handle on *_resize for logically allocated segmants. [minor] refactor function vec_grow_to_size to proper name *_resize
* 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-272-4/+13
| | | | | | | | | | 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-273-20/+26
| | | | | | | | | | | 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.
* fix: vec_cat buffer overrun bugdilluti0n2025-04-271-3/+5
| | | | | | | After grow_to_size called, dest->size already growed. So calling memcpy to dest->data + dest->size causes overrun. There was an anothor problem... it does not update the dest->size either. Both are fixed well.
* implement: eb_set_cur_back and eb_set_cur_prevdilluti0n2025-04-273-2/+27
|
* fix: line_split update newline->last properlydilluti0n2025-04-271-2/+2
| | | | maybe caused by just coping and pasting line_init code