aboutsummaryrefslogtreecommitdiffhomepage
path: root/pager.h
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-01-13 16:41:22 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-01-13 16:41:22 -0800
commit899dafb33fec62ed9258f2b65e2330a2cd483ab5 (patch)
treeb4efbfe1fa46e955771c62d0680f59667511ced2 /pager.h
parent104cf87b895d11202e70268dc9bc88b07c204e09 (diff)
Migrating new pager implementation into a class. Further work on
constructing a screen_data_t from it.
Diffstat (limited to 'pager.h')
-rw-r--r--pager.h57
1 files changed, 56 insertions, 1 deletions
diff --git a/pager.h b/pager.h
index 218f0530..8cf84f8d 100644
--- a/pager.h
+++ b/pager.h
@@ -6,10 +6,65 @@
#include "screen.h"
/* Represents rendering from the pager */
-class page_rendering_t
+struct page_rendering_t
{
screen_data_t screen_data;
};
typedef std::vector<completion_t> completion_list_t;
page_rendering_t render_completions(const completion_list_t &raw_completions, const wcstring &prefix);
+
+class pager_t
+{
+ int term_width;
+ int term_height;
+
+ completion_list_t completions;
+
+ /** Data structure describing one or a group of related completions */
+ public:
+ struct comp_t
+ {
+ /** The list of all completin strings this entry applies to */
+ wcstring_list_t comp;
+
+ /** The description */
+ wcstring desc;
+
+ /** On-screen width of the completion string */
+ int comp_width;
+
+ /** On-screen width of the description information */
+ int desc_width;
+
+ /** Preffered total width */
+ int pref_width;
+
+ /** Minimum acceptable width */
+ int min_width;
+
+ comp_t() : comp(), desc(), comp_width(0), desc_width(0), pref_width(0), min_width(0)
+ {
+ }
+ };
+
+ private:
+ typedef std::vector<comp_t> comp_info_list_t;
+ comp_info_list_t completion_infos;
+
+ int completion_try_print(int cols, const wcstring &prefix, const comp_info_list_t &lst, page_rendering_t *rendering) const;
+
+ void recalc_min_widths(comp_info_list_t * lst) const;
+ void measure_completion_infos(std::vector<comp_t> *infos, const wcstring &prefix) const;
+
+ void completion_print(int cols, int *width_per_column, int row_start, int row_stop, const wcstring &prefix, const comp_info_list_t &lst, page_rendering_t *rendering) const;
+ line_t completion_print_item(const wcstring &prefix, const comp_t *c, size_t row, size_t column, int width, bool secondary, page_rendering_t *rendering) const;
+
+
+ public:
+ void set_completions(const completion_list_t &comp);
+ void set_term_size(int w, int h);
+ wcstring prefix;
+
+ page_rendering_t render() const;
+};