| Commit message (Collapse) | Author | Age | Files | Lines |
| ... | |
| |
|
|
| |
This patch removes obsolated line_get_string on eb_save_file.
|
| |
|
|
|
| |
eb_get_line_string always return valid string, however
eb_get_line_slice has a chance to return slice with NULL ptr.
|
| |
|
|
|
| |
The bug caused UB on splited newline. (especially when is_lazy = 1
unluckly)
|
| | |
|
| |
|
|
|
| |
Implement helper draw_text_slice which just allocate C-string on the
stack and pass it to the DrawText.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
| |
Just kill warnings.
|
| |
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
| |
This is important for current line_get_stirng implementation, which
allocates real vector when it is called with lazy loaded `li`.
|
| | |
|
| |
|
|
|
|
|
| |
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
|
| | |
|