本文介绍了C ++中的简单文本编辑器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您将创建一个简单的逐行文本编辑器.每页包含20行,每行最多包含100个字符.您可能最多有1,000页,而它仅从1页开始,并在用户键入时添加更多页.必须在需要时动态创建每个页面.创建一个Page类,然后在创建Editor类时,Editor类可以创建一个包含1000个指向Page类的指针的数组. (添加新页面时应构建实际页面)
每次都显示一个页面,页面编号在顶部,每行的左侧.底部有一个命令行,它显示了可能的命令,如下所示.
[命令:行号允许您编辑行,"N"跳至下一页,"P"跳至上一页,"Dn"删除第n行– D3删除第3行] ____

这是我所做的,并且不确定如何从此处继续:

You will make a simple line-by-line text editor. Each page contains 20 lines and each line contains up to 100 characters. You may have up to 1,000 pages, while it starts from only 1 page and adds more pages when user types in. Each page has to be dynamically created when needed. Create a Page class and the Editor class can create an array of 1000 pointers to the Page class during the construction of the Editor class. (Actual page should be constructed when a new page is added)
At each time, a page is displayed with page number on the top and the line numbers on the left side of each line. There is a command line at the bottom and it shows possible commands as shown below.
[commands: line number allows you to edit the line, „N‟ goes to next page, „P‟ goes to the previous page, „Dn‟ deletes the line n – D3 deletes line 3]____

Here''s what I have done and not sure how to proceed from here:

const int MAX_LINE = 20;<br />
const int MAX_CHAR = 100;<br />
const int MAX_PAGES = 1000;<br />
class Page {<br />
char aPage[MAX_LINE][MAX_CHAR];<br />
public:<br />
void print();<br />
void edit();<br />
void edit_line(int i);<br />
void delete_line(int i);<br />
};<br />
typedef Page * PagePtr;<br />
class Editor {<br />
PagePtr *pages;<br />
int cur;<br />
int total;<br />
public:<br />
Editor();<br />
void show_commands();<br />
void display_cur_page();<br />
void next();<br />
void prev();<br />
void edit();<br />
};

推荐答案



这篇关于C ++中的简单文本编辑器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 01:53