aboutsummaryrefslogtreecommitdiff
path: root/line.h
Commit message (Collapse)AuthorAgeFilesLines
* refactor: deprecate line->cursor; simplify vertical cursor movementdilluti0n2025-05-021-2/+0
| | | | | | | | | This patch removes the per-line cursor cache (`line->cursor`), reducing implementation complexity. Vertical cursor movement (up/down) now uniformly places the cursor at the beginning of the line, instead of trying to restore the previous horizontal position. UX considerations such as column preservation will be revisited after core stabilization.
* feat: add slice-based accessors for line and editor bufferdilluti0n2025-04-291-8/+15
| | | | | | | | | | | | | | | | | 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: `line_free` to handle lazy-loaded line appropriately.dilluti0n2025-04-291-1/+1
| | | | | | | fix `line_cat` to handle lazy-loaded `src` line too [minor] add const keyword for line_get_last since it is.
* remove: line->last to reduce ambiguity.dilluti0n2025-04-291-1/+1
| | | | | | | | | | 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: make line from buf directly instead of append each charactersdilluti0n2025-04-291-0/+1
| | | | implement line_init_from_buf for this.
* implement: eb_set_cur_back and eb_set_cur_prevdilluti0n2025-04-271-0/+1
|
* implement: eb_backspace; line_cat still TODOdilluti0n2025-04-271-0/+1
| | | | line_cat should be implemented; markd it TODO
* refactor: move debugs to config.h and handle build gracefullydilluti0n2025-04-271-1/+1
| | | | | | | 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-7/+4
| | | | | | | | | | | | | 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: eb_backspacedilluti0n2025-04-241-0/+1
|
* fix: vector memory allocation and insert logic; cleanup eb handlingdilluti0n2025-04-211-0/+1
| | | | | | | | - 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-3/+4
| | | | | | | | | | | | - 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
* Introduce vector template and migrate line moduledilluti0n2025-04-181-1/+3
| | | | | | | | | | | | * vector.h: Add DEFINE_VECTOR macro for a header-only generic vector template - Implements common operations: init, push, pop, set, get, len, grow * line.[ch]: - Replace fixed char-only vec with VEC (DEFINE_VECTOR(char)) instance - Refactor memory allocation and method calls to use VEC_* macros * makefile: - Remove vec.o from OBJS (vec module is no longer used) * vec.[ch] is now obsolete; new vector types (e.g., line *) can be defined easily using a single DEFINE_VECTOR invocation
* refactor: Extract line handling logic into separate line moduledilluti0n2025-04-181-0/+18
- 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