easyVim  1.0
a simple vim-like text editor
show.hpp
Go to the documentation of this file.
1 
8 #ifndef EASYVIM_SHOW_HPP
9 #define EASYVIM_SHOW_HPP
10 #include <vector>
11 #include <string>
12 #include <iostream>
13 #include "config.hpp"
14 
15 
16 namespace ev {
17 
18 class window{
19 public:
20 
22  NORMAL = 0,
23  INSERT = 1,
24  COVER = 2,
25  COMMAND = 3,
28  };
29 
30  window(EVFile* f) : lineNumber(0), colNumber(0), status(NORMAL), file(f){}
31  ~window(){
32  }
33  void init();
34  void quit();
35 
40  int getInput();
41 
46  std::string getCommand();
47 
52  void flushScreen();
53 
57  void flushLine();
58 
63  void updateStatus();
64 
65  void moveTo(size_t line, size_t col);
66 
73  bool moveCur();
74 
78  void moveUp();
79 
83  void moveDown();
84 
88  void moveLeft();
89 
93  void moveRight();
94 
98  void moveHead();
99 
103  void moveEnd();
104 
108  void moveTop();
109 
113  void moveBottom();
114 
115 
116  WindowStatus getStatus(){
117  return status;
118  }
119  bool setStatus(WindowStatus s){
120  status = s;
121  return true;
122  }
123  void printWin(std::string str);
124 
125  void getCuryx(int& x, int& y);
126 
127  void refreshCur(bool flush = true);
128 
129  size_t getCurRow(){
130  return curRow;
131  }
132 
133  size_t getCurCol(){
134  return curCol;
135  }
136 
137  void setCurRow(size_t row){
138  curRow = row;
139  return;
140  }
141 
142 
143 private:
144  size_t lineNumber;
145  size_t colNumber;
146  size_t curRow, curCol;
147  WindowStatus status;
148  EVFile* file;
149  int x, y;
150 };
151 
152 }
153 
154 
155 
156 
157 #endif //EASYVIM_SHOW_HPP
Definition: core.hpp:23
Definition: show.hpp:18
int getInput()
获取用户输入,用户一旦输入就立即返回
Definition: show.cpp:60
void moveHead()
光标移动到行首
Definition: show.cpp:139
void moveUp()
光标上移
Definition: show.cpp:69
void updateStatus()
更新状态栏
Definition: show.cpp:39
void moveEnd()
光标移动到行尾
Definition: show.cpp:149
void moveTop()
光标移动到文件首行
Definition: show.cpp:159
void flushScreen()
刷新整个屏幕
Definition: show.cpp:184
void moveRight()
光标右移
Definition: show.cpp:123
void moveDown()
光标下移
Definition: show.cpp:88
void moveBottom()
光标移动到文件末行
Definition: show.cpp:171
void moveLeft()
光标左移
Definition: show.cpp:109
void flushLine()
刷新当前行文本
Definition: show.cpp:262
WindowStatus
Definition: show.hpp:21
@ WARNING_TRY_UNSAVE_QUIT
尝试不保存退出
Definition: show.hpp:26
@ WARNING_PATTERN_NOT_FOUND
未查找到匹配样式
Definition: show.hpp:27
@ NORMAL
正常模式
Definition: show.hpp:22
@ COMMAND
命令模式
Definition: show.hpp:25
@ COVER
覆盖模式
Definition: show.hpp:24
@ INSERT
插入模式
Definition: show.hpp:23
bool moveCur()
移动光标到当前行,列
Definition: show.cpp:299
std::string getCommand()
获取命令行输入,遇到' '返回输入字符串
Definition: show.cpp:278
配置文件,头文件汇总