pyte icon indicating copy to clipboard operation
pyte copied to clipboard

Fuse three screens into one

Open superbobry opened this issue 8 years ago • 9 comments

Any real-world terminal implementation needs history and incremental updates, so I think it makes sense to merge pyte.DiffScreen and pyte.HistoryScreen into pyte.Screen.

superbobry avatar Mar 11 '17 14:03 superbobry

I'll take a stab at it... For those interested, my fork is here.

broosa avatar May 28 '17 19:05 broosa

Sidenote: now that we have Screen.buffer as defaultdict we can simplify HistoryScreen implementation: store all lines in Screen.buffer and keep track of the current offset within the buffer. The displayed portion of the buffer is offset:offset+lines.

superbobry avatar May 28 '17 21:05 superbobry

Sidenote: now that we have Screen.buffer as defaultdict we can simplify HistoryScreen implementation: store all lines in Screen.buffer and keep track of the current offset within the buffer. The displayed portion of the buffer is offset:offset+lines.

Oh that would be nice! I'll take a look at it.

I think i've merged DiffScreen and Screen. I pushed the commit here. I stubbed out DiffScreen; it should be backwards compatible. All the tests passed fine.

BTW, how do you generate your docs? I want to make sure what I added looks okay.

If everything else looks good, let me know and I'll submit a PR.

broosa avatar May 28 '17 21:05 broosa

BTW, how do you generate your docs? I want to make sure what I added looks okay.

cd docs
make html

If everything else looks good, let me know and I'll submit a PR.

Sure, go ahead and submit one. I've looked through the commit, it looks OK. Don't forget to add yourself to AUTHORS ;)

superbobry avatar May 28 '17 23:05 superbobry

I just submitted PR #86.

broosa avatar May 29 '17 00:05 broosa

Hi @broosa, would you have time to work on 'HistoryScreen->Screen' in the upcoming weeks? If not, I might tackle that myself.

superbobry avatar Jun 04 '17 23:06 superbobry

I would be sad to see the regular screen go as I use it directly without history (actually I made my own history screen with some optimizations). If anyone wants a screen with diff, history etc. they can just use the HistoryScreen as it is right now or am I missing something ?

Wramberg avatar Jun 26 '17 18:06 Wramberg

The key idea behind this refactoring here is that after migration to defaultdict we can support history in the regular screen with almost zero effort. Therefore there is little need for a specialized subclass.

superbobry avatar Jun 26 '17 19:06 superbobry

I see - well in that case I would happily switch to the new all-in-one screen :-)

Wramberg avatar Jun 26 '17 20:06 Wramberg