linde12 / kod

terminal text editor written in Go, using xi-editor as backend
MIT License
315 stars 20 forks source link

Fix vertical scroll and update implementation of linecache #34

Closed emigr2k1 closed 5 years ago

emigr2k1 commented 6 years ago

I added support for vertical scrolling creating an "offset" on viewport to know how many lines should Kod scroll based on number of lines and invalid lines before the document. I also added some helper methods for viewport that I got from tcell. Those provide an easy way to scroll the viewport and make a part of the viewport visible. Now Kod is not responsible to move the cursor and Xi core is. Cursor will only move when there's a notification from Xi core. When Kod scrolls, it now sends a notification to Xi core to let it know the new viewport. Finally, I updated the implementation of linecache because there were some problems when Xi invalidates lines and viewport was scrolled.

linde12 commented 6 years ago

Awesome stuff as usual! I will try to look at it today, otherwise later in the week (currently choked)! Thanks :heart:

linde12 commented 6 years ago

i do think we have to refactor view, viewport and possibly break out linecache into some smaller functions to make it easier to follow. not really related to this PR, but those files are starting to "grow" :smile:

emigr2k1 commented 6 years ago

@linde12 Yes. There's also a lot of code commented and TODOs.

By the way, is there a way to ask you things related to kod? While writing this PR I had some questions but they were really "particular?" to create issues. Something like a irc or discord?

linde12 commented 6 years ago

Hm, weird, i only get some of your replies via mail but not on github. Yeah, it's messy because i basically just threw things together to get a POC hehe. I dont usually hang out in a particular IRC but i do use discord. I'll get back to you with an invite and we can talk, but i think this is great👍😁

linde12 commented 6 years ago

@emigr2k1 Here's the discord invite https://discord.gg/7x32u8t

jantb commented 6 years ago

There is a problem with the draw method, when srolling down, linecache caches up to 1000 above the view. All these lines are iterated and drawn in the draw method.

jantb commented 6 years ago

I have tested the scrolling for some time now, and it seems to work fine. What does not work is scrolling horizontal scrolling, it should not be to difficult to implement.

emigr2k1 commented 6 years ago

@jantb, Yes. But I think @linde12 wants to focus on having a stable architecture before developing "high level" details. If we implement scrolling, it will probably break when the UI changes that most likely will.