3 Star 10 Fork 6

secondtonone1/cpplearn

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
screen.cpp 1.28 KB
一键复制 编辑 原始数据 按行查看 历史
secondtonone1 提交于 2022-01-14 16:48 +08:00 . map
#include "../inc/screen.h"
Screen &Screen::move(pos r, pos c)
{
//计算行的位置
pos row = r * width;
//把光标移动到指定的列
cursor = row + c;
//以左值形式返回
return *this;
}
char Screen::get(pos r, pos c) const
{
//计算行的位置
pos row = r * width;
//返回给定的字符
return contents[row + c];
}
void Screen::some_member() const
{ //在const函数中也可以修改access_ctr
++access_ctr;
}
Screen &Screen::set(char c)
{
contents[cursor] = c;
return *this;
}
Screen &Screen::set(pos r, pos col, char ch)
{
//给定位置设置新值
contents[r * width + col] = ch;
return *this;
}
const Screen &Screen::display(ostream &os) const
{
do_display(os);
return *this;
}
void Screen::do_display(ostream &os) const
{
os << "width is " << width << " "
<< "height is " << height << endl;
}
Screen &Screen::display(ostream &os)
{
do_display(os);
return *this;
}
void Window_mgr::clear(ScreenIndex i)
{
// s是一个Screen的引用,指向我们想清空的屏幕
Screen &s = screens[i];
//清空屏幕
s.contents = string(s.height * s.width, ' ');
}
Window_mgr::ScreenIndex Window_mgr::addScreen(const Screen &s)
{
screens.push_back(s);
return screens.size() - 1;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/secondtonone1/cpplearn.git
git@gitee.com:secondtonone1/cpplearn.git
secondtonone1
cpplearn
cpplearn
master

搜索帮助