aboutsummaryrefslogtreecommitdiff
path: root/text.c
AgeCommit message (Collapse)AuthorFilesLines
2025-01-12array: delete onelinersRandy Palamar1-7/+7
same as buffer commit Array is completely visible
2022-11-29fix miscellaneous spelling mistakesNick Hanley1-5/+5
2020-12-10fix typos in commentsMoesasji1-17/+17
2020-10-30text: simplify iterator_initMarc André Tanner1-2/+1
This was added in c240368d5da8208c15e0263034384414d938afb3 to work around a possibly bogus tis-interpreter warning regarding multiple accesses in the same expression.
2020-10-30text: avoid invalid pointer arithmeticMarc André Tanner1-2/+2
2020-10-10text: move higher level utility functions to separate fileMarc André Tanner1-68/+0
The moved functions do not need access to internals of text.c, but instead use the public interfaces. Splitting them out should facilitate experimentation with different core text management data structures.
2020-10-10text: move generic iterator functionality to separate fileMarc André Tanner1-170/+0
2020-10-10text: move I/O related code to separate fileMarc André Tanner1-562/+3
This groups all I/O related code together to make it reusable in different core text data structure implementations.
2020-10-10text: provide public text_iterator_initMarc André Tanner1-2/+6
It can be used to initialize a (stack allocated) Iterator structure, avoiding the copying of the return value as done by text_iterator_get which depending on the implementation might be problematic.
2020-10-10text: rename internal text_iterator_initMarc André Tanner1-4/+4
This is in preparation for a public function of the same name.
2020-10-10text: mark return value of text_iterator_text as constMarc André Tanner1-4/+4
2020-10-10text: make text_snapshot return whether it succeededMarc André Tanner1-1/+2
Currently this can't fail, but one can imagine implementations which do.
2020-10-10text: mark text_delete_range range argument as constMarc André Tanner1-1/+1
2020-10-10text: mark text_save_write_range range argument as constMarc André Tanner1-1/+1
2020-10-10text: mark text_mmaped argument as constMarc André Tanner1-1/+1
2020-10-10text: mark text_write{,_range} argument as constMarc André Tanner1-2/+2
2020-10-10text: mark text_size argument as constMarc André Tanner1-1/+1
2020-10-10text: mark text_mark_get argument as constMarc André Tanner1-1/+1
2020-10-10text: mark text_iterator_byte_get argument as constMarc André Tanner1-1/+1
2020-10-10text: mark text_bytes_alloc0 argument as constMarc André Tanner1-1/+1
2020-10-10text: mark text_byte(s)_get argument as constMarc André Tanner1-2/+2
2020-10-10text: mark text_iterator_get argument as constMarc André Tanner1-3/+3
2020-10-10text: mark text_state argument as constMarc André Tanner1-1/+1
2020-10-10text: mark text_modified argument as constMarc André Tanner1-1/+1
2020-10-10text: mark text_stat argument as constMarc André Tanner1-1/+1
2020-10-10text: introduce text_iterator_textMarc André Tanner1-3/+10
2020-10-10text: introduce text_iterator_has_{next,prev}Marc André Tanner1-4/+12
Abstract away access to `it->piece` inorder to enable different implementations/backends.
2020-10-10text: add namespace prefix to block type constantsMarc André Tanner1-10/+10
2020-10-10text: avoid direct access to txt->blocks in I/O related codeMarc André Tanner1-3/+10
2020-10-10text: introduce text_savedMarc André Tanner1-10/+11
Utiltiy function to update book keeping data after a successful save, takes an optional struct stat of the new file.
2020-10-10text: use public text_stat interface where possibleMarc André Tanner1-3/+4
2020-10-10text: introduce block_loadMarc André Tanner1-24/+36
2020-10-10text: store blocks in arrayMarc André Tanner1-31/+35
Make block manipulation routines independent of core text data structure, enabling re-usage in different implementations.
2020-10-10text: simplify reading of initial file contentMarc André Tanner1-6/+7
Avoid unnecessary copy and system calls in block_read.
2020-08-29text: provide save function taking a directory descriptorMarc André Tanner1-10/+39
The standard does not specify mkstempat(3). We currently implement it in a non thread safe manner, by temporarily changing the process working directory before invoking mkstemp(3).
2020-08-29text: provide load function taking a directory descriptorMarc André Tanner1-1/+9
2020-06-28text: simplify remapping of original file contentMarc André Tanner1-9/+1
Use mmap with MAP_FIXED which replaces existing mappings without any race conditions between the munmap/mmap calls.
2020-06-22text: remove dead storeMarc André Tanner1-1/+0
2020-06-22text: code cleanup, use local variableMarc André Tanner1-8/+9
No functionl change.
2020-06-22text: fix typo in comments, no code changeMarc André Tanner1-4/+4
2020-05-13text: introduce text_save_method, remove text_save_rangeMarc André Tanner1-9/+9
This utility function is analogous to text_load_method and allows the caller to specify how the file should be saved. It is implemented as a wrapper around the lower level text_save_{begin,write,commit} primitives. The unused text_save_range function has been removed. If needed, use the aforementioned lower level functionality.
2020-01-26text: ignore fsync(2) errors on unsupported directory descriptorsMarc André Tanner1-1/+1
When saving a file by atomically renaming it to its final destination, we fsync(2) the parent directory to make sure the new directory entry is persisted. However, not all file systems support fsync on file descriptors referring to directories. As a result the save operation fails and subsequent attempts result in warnings regarding outdated file content, even though the data has most likely been successfully written. Ignoring this particular error seems fine, because it is a permanent limitation of the file system and not a temporary failure. Fixes #792
2018-05-30text: only default to mmap for files larger than 64 MiBMarc André Tanner1-1/+1
2018-05-30text: allow to specify how the file content should be loadedMarc André Tanner1-3/+5
2018-05-16text: use mkstemp(3) for temporary file creation in atomic savesMarc André Tanner1-6/+25
Instead of simply appending a tilde to the original file name, we now create an unique temporary file based on the pattern `.filename.vis.XXXXXX`. In case the file does not yet exist, we use 0666 & ~umask as permission, (this should match the previous `open(2)` based behavior).
2018-05-16text: do not unlink existing `file~` when saving to `file`Marc André Tanner1-1/+3
Fail atomic save if temporary file already exists. A follow up commit will use `mkstemp(3)` for temporary file creation.
2017-07-05text: limit write(2) calls to INT_MAX bytesMarc André Tanner1-1/+1
Otherwise this fails on macOS. Fix #578
2017-05-03text: remove text_history_get functionMarc André Tanner1-12/+0
As currently implemented this does not properly integrate with multiple cursor support. The functionality should be provided in a layer higher up. The jumplist and changelist need to be redesigned, for now they are broken.
2017-05-03text: remove text_iterate macroMarc André Tanner1-3/+9
2017-05-03text: remove text_insert_newline functionMarc André Tanner1-4/+0
This is no longer needed because we always insert \n never \r\n.