summaryrefslogtreecommitdiff
path: root/src/file.hh
AgeCommit message (Collapse)Author
2025-07-10More CI compilation fixesMaxime Coste
2025-03-25Bump build to c++23Maxime Coste
2025-02-19Move command/filename completion logic to completion.ccMaxime Coste
Refactor list_files to use a callback instead of returning a vector, file.cc/hh should not know about completion logic.
2025-02-19Cleanup file.cc/hh dependenciesMaxime Coste
file.cc/hh should not know about Context, Buffer, etc... It should be a pretty low level set of helper functions. Move buffer related functions to buffer_utils and extract busy indicators to callers.
2024-12-09Print elapsed time when blocked on opening file for writingJohannes Altmanninger
Extract the logic for "waiting for shell to finish" and reuse it for potentially blocking calls to open() that use the O_WRONLY flags.
2024-08-15Remove unused ConstexprVector and rename constexpr_utils.hh to array.hhMaxime Coste
2024-08-12Reduce headers dependency graphMaxime Coste
Move more code into the implementation files to reduce the amount of code pulled by headers.
2023-10-25Remove redundant comparison operatorsMaxime Coste
Since C++20 (a != b) get automatically rewritten as !(a == b) if the != operator does not exist.
2023-04-24Fix crash after multiple terminal resizesJohannes Altmanninger
When Kakoune's terminal is shown on my laptop monitor and I plug in my external monitor, the terminal's workspace will move to that external monitor. When this happens, Kakoune may segfault. There are multiple resize events (SIGWINCH) in quick succession; it crashes because we handle SIGWINCH during rendering. The problem happens during execution of "TerminalUI::Screen::output" (frame #18). When we receive SIGWINCH while writing to stdout, write(2) fails with EAGAIN, prompting us to handle pending events (See ae001a1f9 (Run EventManager whenever writing to a file descriptor would block, 2022-05-10)). We update the screen size in check_resize() here: #4 Kakoune::TerminalUI::check_resize (force=<optimized out>) at terminal_ui.cc:683 #5 Kakoune::TerminalUI::get_next_key () at terminal_ui.cc:719 #6 operator() (__closure=0x555555984198) at terminal_ui.cc:484 #7 std::__invoke_impl<void, Kakoune::TerminalUI::TerminalUI()::<lambda(Kakoune::FDWatcher&, Kakoune::FdEvents, Kakoune::EventMode)>&, Kakoune::FDWatcher&, Kakoune::FdEvents, Kakoune::EventMode> (__f=...) at /usr/include/c++/12.2.1/bits/invoke.h:61 #8 std::__invoke_r<void, Kakoune::TerminalUI::TerminalUI()::<lambda(Kakoune::FDWatcher&, Kakoune::FdEvents, Kakoune::EventMode)>&, Kakoune::FDWatcher&, Kakoune::FdEvents, Kakoune::EventMode> (__fn=...) at /usr/include/c++/12.2.1/bits/invoke.h:111 #9 std::_Function_handler<void(Kakoune::FDWatcher&, Kakoune::FdEvents, Kakoune::EventMode), Kakoune::TerminalUI::TerminalUI()::<lambda(Kakoune::FDWatcher&, Kakoune::FdEvents, Kakoune::EventMode)> >::_M_invoke(const std::_Any_data &, Kakoune::FDWatcher &, Kakoune::FdEvents &&, Kakoune::EventMode &&) (__functor=..., __args#0=..., __args#1=<optimized out>, __args#2=<optimized out>) at /usr/include/c++/12.2.1/bits/std_function.h:290 #10 std::function<void (Kakoune::FDWatcher&, Kakoune::FdEvents, Kakoune::EventMode)>::operator()(Kakoune::FDWatcher&, Kakoune::FdEvents, Kakoune::EventMode) const (__args#2=<optimized out>, __args#1=<optimized out>, __args#0=...) at /usr/include/c++/12.2.1/bits/std_function.h:591 #11 Kakoune::FDWatcher::run (mode=Kakoune::EventMode::Urgent, events=<optimized out>) at event_manager.cc:28 #12 Kakoune::EventManager::handle_next_events (mode=mode@entry=Kakoune::EventMode::Urgent, sigmask=sigmask@entry=0x0, block=<optimized out>, block@entry=false) at event_manager.cc:143 #13 Kakoune::write (fd=1, data=...) at file.cc:273 #14 Kakoune::BufferedWriter<4096>::flush () at string.hh:236 #15 Kakoune::BufferedWriter<4096>::write (data="t file.hh:145 #16 Kakoune::TerminalUI::Screen::set_face (face=..., writer=...) at terminal_ui.cc:255 #17 operator() (line=..., __closure=<synthetic pointer>) at terminal_ui.cc:326 #18 Kakoune::TerminalUI::Screen::output (force=force@entry=true, synchronized=<optimized out>, writer=...) at terminal_ui.cc:402 #19 Kakoune::TerminalUI::redraw (force=force@entry=true) at terminal_ui.cc:571 #20 Kakoune::TerminalUI::refresh (force=<optimized out>) at terminal_ui.cc:592 #21 Kakoune::Client::redraw_ifn () at client.cc:282 #22 Kakoune::ClientManager::redraw_clients () at client_manager.cc:232 #23 Kakoune::run_server (session=..., server_init=..., client_init=..., init_buffer="fish-rust/src/ast.rs", init_coord=..., flags=Kakoune::ServerFlags::None, ui_type=Kakoune::UIType::Terminal, debug_flags=<optimized out>, files=ArrayView<Kakoune::StringView> = {...}) at main.cc:893 #24 main (argc=<optimized out>, argv=<optimized out>) at main.cc:1243 Thereafter, "TerminalUI::Screen::output" resumes and crashes due to a buffer overflow in "lines" which has been resized.
2022-12-15Support adding ByteCount to void/char pointers without castingMaxime Coste
2022-02-18Do not keep MappedFile fd openedMaxime Coste
According to the mmap man page this is not necessary, and this avoids exposing the fd.
2021-08-01Use a BufferedWriter to output in the terminal ui instead of stdioMaxime Coste
Clearer control of buffering and flushing
2021-07-31Expose BufferedWriterMaxime Coste
2021-07-20Prevent overwriting existing file in :write <explicit filename>Maxime Coste
Add a -force (equivalent to w!) switch that enables overwriting.
2019-12-03src: Reload buffers when their contents' hash changesFrank LENORMAND
Instead of triggering a reload event when the timestamp of a buffer's underlying file changes, do so when its contents are actually modified.
2019-10-17Remove explicit sizes from make_array callsMaxime Coste
2019-04-07Add a -to-file <filename> switch to the echo commandMaxime Coste
As discussed in #2836
2019-02-12Introduce a writemethod option to either overwrite or replace filesMaxime Coste
This permit to choose if files should be written by overwriting their content (the default), or by writing to a separate temporary file and rename it to the current file. As discussed in #2036
2019-02-12Refactor write_buffer_to_file to use a flags paramMaxime Coste
That is clearer than two boolean parameters.
2018-07-04src: Add a `-sync` flag to the write commandsFrank LENORMAND
2018-03-25Remove parse_filename overload and use a default parameterMaxime Coste
2018-03-23Support `%` in `path` option to mean current buffer directoryMaxime Coste
In the end, % is not that painful to work with as its only set seldomly, and we usually dont need to use expansion at the same time. Moreover, it just requires a single \ to be escaped. Fixes #1562
2018-01-20Fallback to getpwuid in the unlikely case $HOME is underfinedMaxime Coste
Add a homedir() helper function, and document the $kak_config env var.
2017-04-20src: Implement a `write!` commandFrank LENORMAND
This commit allows "forced" writes to a write-protected file, by attempting to temporarily grant the current user write permissions on it. After the buffer has been written, the previous permissions are restored if the file existed, or set to 0644 otherwise.
2017-03-15Small code tweaks regarding flags handlingMaxime Coste
2017-03-15Migrate WithBitOps template specialization to with_bit_ops functionMaxime Coste
This way we dont depend on knowing the base template to enable bit ops on an enum type.
2017-01-01Fix remaining uses of hardcoded /tmp to get the socket pathsMaxime Coste
Fixes #1097
2016-12-15Improve general security of the unix socketsMaxime Coste
* Use the stricky bit on the shared kakoune folder * Do not allow read/write access to user folder * Respect $TMPDIR when set Fixes #1007
2016-12-01Only write to remote socket when we know they are writableMaxime Coste
Buffer data (in an horribly innefficient way for now), and use the event manager to watch for the socket being ready for a write. Fixes #945
2016-11-28Cleanup include dependencies a bitMaxime Coste
2016-10-13Do not expand filenames when doing insert filename completionMaxime Coste
Fixes #855
2016-08-30Add a fd_readable(int fd) helper functionMaxime Coste
Use it instead of direct calls to select scatered around the code base.
2016-04-07Only offer directories when completing :cd argumentsMaxime Coste
Refactor code in file.cc, avoid many double stat when searching commands Fixes #646
2015-11-27Consolidate writing to fdMaxime Coste
2015-10-17More cleanups in the buffer open/reload codeMaxime Coste
2015-10-17Refactor buffer creation and reloading to be more explicitMaxime Coste
Reloading used to be implicit in the buffer creation function, which is not always nice, as code that explicitely wanted to reload a buffer could not say so.
2015-09-27Store timespec for buffer fs timestamps, not just time_tMaxime Coste
time_t has a resolution of one second, which cause troubles when a file changes multiple time during that same second.
2015-08-23Add support for listing existing sessions with kak -lMaxime Coste
Fixes #381
2015-08-23Move session socket to /tmp/kakoune/<user name>/<session>Maxime Coste
2015-06-15Small formatting fixMaxime Coste
2015-06-05Support sourcing files that use crlf end of linesMaxime Coste
2015-06-01Port even more code to use format functionMaxime Coste
2015-03-19Small code tweakMaxime Coste
2015-03-12Make split_path publicMaxime Coste
2015-03-09ArrayView content is not const anymoreMaxime Coste
As in upcoming std c++ array_view, ArrayView<T> points to mutable data, use ArrayView<const T> or alias ConstArrayView<T> for const data.
2015-01-09Track String memory allocationsMaxime Coste
2015-01-06Rename memoryview to ArrayViewMaxime Coste
2014-11-17Remove unneeded string copiesMaxime Coste
2014-11-12Cleanup includesMaxime Coste
2014-10-30Add kak binary location to PATH env var automaticallyMaxime Coste
That way the kak binary can be guaranteed to be available even if not in user PATH.