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.
Cursor navigation in a text editor
-
- Posts: 52
- Joined: Fri Aug 11, 2023 4:56 am
Re: Cursor navigation in a text editor
This isn't really related to ESP32, but "large data buffer" for a text editor is headed down a bad path from the start.
Read up on the data structure known as 'ropes'. They're key to this class of problems.
Read up on the data structure known as 'ropes'. They're key to this class of problems.
Who is online
Users browsing this forum: **txf** and 74 guests