| Commit message (Collapse) | Author | Age | Files | Lines |
| ... | |
| | |
|
| |
|
|
|
|
|
| |
fix `line_cat` to handle lazy-loaded `src` line too
[minor]
add const keyword for line_get_last since it is.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| | |
|
| |
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
| |
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.
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
|
|
| |
implement line_init_from_buf for this.
|
| | |
|
| |
|
|
|
| |
This reduces unnecessary per-byte branching by scanning for newlines
more efficiently when loading files.
|
| |
|
|
|
| |
[minor]
add check for eb_save_file when fopen fails.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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`
|
| | |
|
| | |
|
| |
|
|
|
| |
[minor]
move eb_free to front of file
|
| |
|
|
| |
for faster debuging :)
|
| |
|
|
|
| |
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.
|
| | |
|
| | |
|
| |
|
|
|
| |
[minor]
add argc and argv to main routine.
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
|
|
| |
It just bump size to 0.
|
| | |
|
| |
|
|
|
|
| |
test.c to *_line.c and *_vector.c
also implement unit test vector_suite::resize too.
|
| |
|
|
| |
since it calls MemFree instead of line_free.
|
| | |
|
| |
|
|
|
|
|
|
|
| |
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.
|
| | |
|
| |
|
|
| |
add assertion on line_insert
|
| | |
|
| |
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
| |
instead, this will handle on *_resize for logically allocated segmants.
[minor]
refactor function vec_grow_to_size to proper name *_resize
|
| |
|
|
|
| |
[minor]
add log cursor on draw loop.
|
| |
|
|
|
| |
fix: eb_set_cur_back to handle unallocated line correctly when called
on head of the line.
|
| |
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
| |
It was actually allocating line buf when insert empty line...
[minor]
refactor eb_init to indicates each field initialization well.
|
| |
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
| |
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.
|
| | |
|
| |
|
|
| |
maybe caused by just coping and pasting line_init code
|