I’m building a vi-like text editor from scratch, and I’m also developing my own curses library for rendering. I’ve encountered an issue where letters are sometimes skipped while typing. I’ve been able to track the cursor movement using logging, but the issue persists in the display.
Problem:
Expected behavior: Each key press should result in the correct letter appearing at the correct cursor position, with the cursor moving accordingly.
Observed behavior: The cursor moves correctly in the log (it increments by one with each key), but sometimes the letter is skipped on the screen while typing.
What I’ve tried:
I’ve implemented logging that records time, row, column, and the character being typed in the format time, row, col, letter to track where the cursor is.
I switch between normal mode and insert mode, logging "normal mode" whenever in normal mode and a key is pressed.
I’ve confirmed that the cursor position in the log updates correctly, but the rendering appears to miss characters intermittently, but with no real pattern
Files of Interest:
~400 lines in total, not big i swear, all in src/
The issue seems related to rendering, and the key files to look at are:
tui.h, tui.cpp
textbuffer.h, textbuffer.cpp
editor.h, editor.cpp
Repo: https://github.com/eric-bodhi/cursey
I suspect there might be an issue with how the rendering is triggered or updated, specifically clearing the screen and the render_file() function but I’m not sure exactly where the problem lies. I've browsed stackoverflow but was not successful.