diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2014-01-15 18:21:38 -0800 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2014-01-15 18:21:38 -0800 |
commit | 0627ae82fb2366aa140b986e80f2e68b822e4242 (patch) | |
tree | d279bccd3b3c043b728867e24b32a2d10b170f66 /screen.cpp | |
parent | 54689f60874d46391d9da613ff1305a974a3de24 (diff) |
Clean up pager on exit from interactive read
Diffstat (limited to 'screen.cpp')
-rw-r--r-- | screen.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
@@ -45,6 +45,7 @@ efficient way for transforming that to the desired screen content. #include "highlight.h" #include "screen.h" #include "env.h" +#include "pager.h" /** The number of characters to indent new blocks */ #define INDENT_STEP 4 @@ -1027,7 +1028,7 @@ static void s_update(screen_t *scr, const wchar_t *left_prompt, const wchar_t *r if (! output.empty()) { - write_loop(1, &output.at(0), output.size()); + write_loop(STDOUT_FILENO, &output.at(0), output.size()); } /* We have now synced our actual screen against our desired screen. Note that this is a big assignment! */ @@ -1236,7 +1237,7 @@ void s_write(screen_t *s, const highlight_spec_t *colors, const int *indent, size_t cursor_pos, - const screen_data_t *pager_data) + const pager_t &pager) { screen_data_t::cursor_t cursor_arr; @@ -1325,9 +1326,10 @@ void s_write(screen_t *s, s->desired.cursor = cursor_arr; /* append pager_data */ - if (pager_data != NULL) + if (! pager.empty()) { - s->desired.append_lines(*pager_data); + const page_rendering_t rendering = pager.render(); + s->desired.append_lines(rendering.screen_data); } s_update(s, layout.left_prompt.c_str(), layout.right_prompt.c_str()); @@ -1435,6 +1437,22 @@ void s_reset(screen_t *s, screen_reset_mode_t mode) fstat(2, &s->prev_buff_2); } +bool screen_force_clear_to_end() +{ + bool result = false; + if (clr_eos) + { + data_buffer_t output; + s_write_mbs(&output, clr_eos); + if (! output.empty()) + { + write_loop(STDOUT_FILENO, &output.at(0), output.size()); + result = true; + } + } + return result; +} + screen_t::screen_t() : desired(), actual(), |