Cursor navigation in a text editor
Posted: Tue Jun 25, 2024 10:34 am
I'm developing a text editor using esp32 to which an LCD display is connected. Currently, to edit a file, I have a single large buffer of characters which is displayed on the screen line by line. I have implemented line splitting so that a word doesn't break when it reaches the end of a line but shifts into next line. Now, how to handle cursor navigation such that when the user presses the left arrow key when the cursor is at the start of a line, the cursor should move to the end of the previous line, considering that the lines have different lengths and I don't know where the previous line ended?
I have tried to split the entire buffer into multiple buffers so that each buffer will take maximum of one line on the display. But while adding or removing characters to/from the buffer, it's really hard to keep track of all the buffers and update them dynamically.
I have tried to split the entire buffer into multiple buffers so that each buffer will take maximum of one line on the display. But while adding or removing characters to/from the buffer, it's really hard to keep track of all the buffers and update them dynamically.