Skip to content

Added autosave functionality

Theodore Wang requested to merge theodorewang12/my-konsole:saveauto into master

The autosave functionality is contained in a SaveHistoryAutoTask class, which inherits from SessionTask. The autosave mechanism hinges on two pieces of information regarding the autosave file: the number of bytes used to store the contents of dropped lines (represented by SaveHistoryAutoTask::_droppedBytes) and a list of byte offsets corresponding to the start of the contents of lines on the screen (represented by SaveHistoryAutoTask::_bytesLines). Everytime a line is dropped, SaveHistoryAutoTask::_droppedBytes is updated using _bytesLines. Everytime the output is read and saved to file, the autosave file is resized to _droppedBytes and the current screen output is appended. Everytime the output is read or the screen is resized, _bytesLines is updated.

The autosave can be started using an "Auto Save Ouput As" button in the "File" tab of the toolbar. Once the autosave is started, said button is replaced by a "Stop Auto Save" button which allows the user to stop the autosave. Internally, any errors encountered by the program would result in an KMessageBox reporting the details of the error and stopping the autosave as well. Clicking on the stop button reveals the start button again.

Similar to SaveHistoryTask, there is a file dialog which allows the user to choose which file they would like the autosave contents to be stored in.

Apart from errors involving reading session output and writing to file, modifying the file externally, renaming the file and deleting the file will also result in an error. Emulation::_currentScreen being changed will also result in an error.

The autosave is conducted at a fixed time interval, apart from an edge case where an autosave is required immediately due to internal constraints. Said fixed time interval can be set by the user in the settings of their current profile, specifically the "Advanced" tab.

Details on the internals of the autosave functionality is documented in the source files.

BUG: 208620

Merge request reports