Implement @get-text

This commit is contained in:
Kovid Goyal
2018-01-09 22:48:24 +05:30
parent 6ad49bd7fb
commit e5b9bd2e5a
4 changed files with 70 additions and 9 deletions

View File

@@ -312,14 +312,20 @@ class Window:
self.screen.reset_callbacks()
self.screen = None
def buffer_as_ansi(self):
def buffer_as_ansi(self, add_history=True):
data = []
self.screen.historybuf.as_ansi(data.append)
if add_history:
self.screen.historybuf.as_ansi(data.append)
self.screen.linebuf.as_ansi(data.append)
return ''.join(data)
def buffer_as_text(self):
return str(self.screen.historybuf) + '\n' + str(self.screen.linebuf)
def buffer_as_text(self, add_history=True):
ans = str(self.screen.linebuf).rstrip('\n')
if add_history:
h = str(self.screen.historybuf)
if h.strip():
ans = h + '\n' + ans
return ans
# actions {{{