-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp_TextEditor.h
78 lines (58 loc) · 2.16 KB
/
app_TextEditor.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef APP_TEXTEDITOR_H
#define APP_TEXTEDITOR_H
#include <string>
#include <vector>
#include <taskManagement.h>
/* Editor Buffer: implements a simple text editor.
* The underlying data structure is a linked list.
* The codes are referred to the text book. */
class EditorBuffer {
public:
// Constructor
EditorBuffer();
// Destructor
~EditorBuffer();
// Moving cursors
void moveCursorForward();
void moveCursorBackward();
void moveCursorToStart();
void moveCursorToEnd();
// Insert a character after cursor
void insertCharacter(char ch);
// Delete a charcter after cursor
void deleteCharter();
// Show the contents of the editor, as well as the location of cursor
void showContents();
// Hang on editor by store text data in memory and then close the editor
bool HangOnEditor(int taskid, std::vector <std::string> user_name, std::string username, std::string & jsonmem,
PCB_type (&mem)[100],
vector<PCB_type> & runningQueue,
vector<PCB_type> & blockQueue,
vector<PCB_type> & readyQueue);
private:
/* Cell: the basic unit of linked-list-type editor buffer.
* Each cell contains a character and a pointer to the next cell.
*/
struct Cell{
char ch;
Cell *link;
};
// Instance variables
Cell *start;
Cell *cursor;
};
// Open a editor and edit its text
void editText(EditorBuffer &editor, vector <string> user_name, string username, string & jsonmem, int taskid,
PCB_type (&mem)[100],
vector<PCB_type> & runningQueue,
vector<PCB_type> & blockQueue,
vector<PCB_type> & readyQueue);
// Print a command list for editor operations
void editorHelp();
// Initialize editor with data store in memory if it is a wake-up task
void TextEditor(int taskid, bool wakeup, string & jsonmem,
string username, vector<string> user_name, PCB_type (&mem)[100],
vector<PCB_type> & runningQueue,
vector<PCB_type> & blockQueue,
vector<PCB_type> & readyQueue);
#endif // APP_TEXTEDITOR_H