aboutsummaryrefslogtreecommitdiffhomepage
path: root/screen.h
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2011-12-27 18:41:38 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2011-12-27 18:41:38 -0800
commit46fa2dd2f0d104471bbb00b8e119decd91cda71d (patch)
tree77b0fe4f1a4010a576ffea441f12cc0aa40f2c4d /screen.h
parent451399b3445f2a8f929bfe8893df9b3e931ac2b1 (diff)
Migration of screen away from ad-hoc lists
Diffstat (limited to 'screen.h')
-rw-r--r--screen.h120
1 files changed, 78 insertions, 42 deletions
diff --git a/screen.h b/screen.h
index 0e2c798a..291f35c6 100644
--- a/screen.h
+++ b/screen.h
@@ -12,6 +12,79 @@
#ifndef FISH_SCREEN_H
#define FISH_SCREEN_H
+#include <vector>
+
+struct line_entry_t
+{
+ wchar_t text;
+ int color;
+};
+
+
+/**
+ A class representing a single line of a screen.
+*/
+class line_t
+{
+ public:
+ std::vector<struct line_entry_t> entries;
+
+ void resize(size_t size) {
+ entries.resize(size);
+ }
+
+ line_entry_t &entry(size_t idx) {
+ return entries.at(idx);
+ }
+
+ line_entry_t &create_entry(size_t idx) {
+ if (idx >= entries.size()) {
+ entries.resize(idx + 1);
+ }
+ return entries.at(idx);
+ }
+
+ size_t entry_count(void) {
+ return entries.size();
+ }
+};
+
+/**
+ A class representing screen contents.
+*/
+class screen_data_t
+{
+ std::vector<line_t> line_datas;
+
+ public:
+
+ int cursor[2];
+
+ line_t &add_line(void) {
+ line_datas.resize(line_datas.size() + 1);
+ return line_datas.back();
+ }
+
+ void resize(size_t size) {
+ line_datas.resize(size);
+ }
+
+ line_t &create_line(size_t idx) {
+ if (idx >= line_datas.size()) {
+ line_datas.resize(idx + 1);
+ }
+ return line_datas.at(idx);
+ }
+
+ line_t &line(size_t idx) {
+ return line_datas.at(idx);
+ }
+
+ size_t line_count(void) {
+ return line_datas.size();
+ }
+};
+
/**
The struct representing the current and desired screen contents.
*/
@@ -20,24 +93,17 @@ typedef struct
/**
The internal representation of the desired screen contents.
*/
- array_list_t desired;
+ screen_data_t desired;
/**
The internal representation of the actual screen contents.
*/
- array_list_t actual;
- /**
- The desired cursor position.
- */
- int desired_cursor[2];
- /**
- The actual cursor position.
- */
- int actual_cursor[2];
+ screen_data_t actual;
+
/**
- A stringbuffer containing the prompt which was last printed to
+ A string containing the prompt which was last printed to
the screen.
*/
- string_buffer_t actual_prompt;
+ wcstring actual_prompt;
/**
The actual width of the screen at the time of the last screen
@@ -62,36 +128,6 @@ typedef struct
screen_t;
/**
- A struct representing a single line of a screen. Consists of two
- array_lists, which must always be of the same length.
-*/
-typedef struct
-{
- /**
- The text contents of the line. Each element of the array
- represents on column of output. Because some characters are two
- columns wide, it is perfectly possible for some of the comumns
- to be empty.
- */
- array_list_t text;
- /**
- Highlight information for the line
- */
- array_list_t color;
-}
- line_t;
-
-/**
- Initialize a new screen struct
-*/
-void s_init( screen_t *s );
-
-/**
- Free all memory used by the specified screen struct
-*/
-void s_destroy( screen_t *s );
-
-/**
This is the main function for the screen putput library. It is used
to define the desired contents of the screen. The screen command
will use it's knowlege of the current contents of the screen in