Cursor navigation in a text editor

hamith
Posts: 1
Joined: Tue Jun 25, 2024 7:28 am

Cursor navigation in a text editor

Postby hamith » 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.

allAboutCircuitsThreadPhoto.png
allAboutCircuitsThreadPhoto.png (10.4 KiB) Viewed 552 times

RandomInternetGuy
Posts: 52
Joined: Fri Aug 11, 2023 4:56 am

Re: Cursor navigation in a text editor

Postby RandomInternetGuy » Sun Jun 30, 2024 2:56 pm

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.

Who is online

Users browsing this forum: No registered users and 94 guests