Skip to content

Commit

Permalink
完善Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Mattuy committed Dec 2, 2018
1 parent 544de7c commit 45c72a6
Show file tree
Hide file tree
Showing 10 changed files with 244 additions and 144 deletions.
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
## 特性
  你可以将控制台窗口分割为若干个**窗格**,窗格之间可创建**分割线**来区别它们。每个窗格拥有一个行缓存,包含若干****。你可以改变行缓存的大小。

  你可以动态地为**窗格**增加****,仅需要向窗格添加文本,窗格将自动把文本分割为适应的行,改变窗格大小它也将自动更新。
  你可以动态地为**窗格**增加****,仅需要向窗格添加文本,窗格将自动把文本分割为适应的行,改变窗格大小它也将自动更新。支持ANSI和UTF-8两种编码格式。

&emsp;&emsp;你可以为每一****设定字符格式,字符格式由Windows的一些<a href="#constant">常量</a>定义。

<font color="red">&emsp;&emsp;这不是一个设计严谨的库,使用需谨慎。</font>

## 开发环境
&emsp;&emsp;Windows,Visual Studio 2017
Expand Down Expand Up @@ -109,7 +110,9 @@
* 对用户输入的控制比较无力
* 只能对整行设定字符样式
* 分割线的交点没有做特殊处理很难看
* 不支持Unicode
* **功能没有全部测试**
* 由于未知原因,g++编译测试示例时失败,仅VS编译成功(不是get_s的原因==)
* 其他


Expand Down Expand Up @@ -139,6 +142,23 @@ int main() {
}
```

## 文件列表
<pre>
README.md
conctrl
|----coding.cpp //编码转换
|----coding.h
|----conctrl.cpp //定义导出函数
|----conctrl.def //导出定义文件
|----conctrl.h //声明导出函数,提供给用户
|----console-window.cpp //定义控制台窗口控制器
|----console-window.h
|----pannel.cpp //定义窗格
|----pannel.h
|----spliter.cpp //定义分割线
|----spliter.h
</pre>

## 辅助资料

<a name="constant"></a>
Expand Down
1 change: 0 additions & 1 deletion conctrl/conctrl.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
<ClCompile Include="coding.cpp" />
<ClCompile Include="conctrl.cpp" />
<ClCompile Include="console_window.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="pannel.cpp" />
<ClCompile Include="spliter.cpp" />
</ItemGroup>
Expand Down
3 changes: 0 additions & 3 deletions conctrl/conctrl.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
<ClCompile Include="spliter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="coding.h">
Expand Down
120 changes: 0 additions & 120 deletions test/test.vcxproj

This file was deleted.

17 changes: 0 additions & 17 deletions test/test.vcxproj.filters

This file was deleted.

114 changes: 114 additions & 0 deletions test_x64/conctrl.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#define _CRT_SECURE_NO_WARNINGS
#include "console_window.h"
#include "pannel.h"
#include "spliter.h"
#include "coding.h"
#include "conctrl.h"

//创建当前控制台窗口对应的控制窗口
ConsoleWindow* CreateConsoleWindow(int width, int height) {
if (width <= 5 || height <= 5 || width > 32767 || height > 32767)
return new(std::nothrow) ConsoleWindow();
else {
return new(std::nothrow) ConsoleWindow(width, height);
}
}

void DestroyConsoleWindow(ConsoleWindow* window) {
delete window;
}

//重新设置窗口和缓冲区大小
bool ResizeScreenBuffer(ConsoleWindow* window, int width, int height) {
if (width <= 5 || height <= 5 || width > 32767 || height > 32767)
return false;
return window->Resize({ (SHORT)width, (SHORT)height });
}
//设置控制台窗口标题
bool SetConsoleWindowTitle(char* _title, bool utf8) {
if (utf8) {
std::string title;
title = UTF8ToANSI(_title);
return SetConsoleTitle(title.c_str());
}
return SetConsoleTitle(_title);
}
//创建一个窗格
Pannel* CreatePannel(ConsoleWindow* window, int left, int top, int width, int height) {
if (left < 0 || top < 0
|| left > 32767 || top > 32767 || width > 32767 || height > 32767
) return NULL;
return window->NewPannel({ (SHORT)left, (SHORT)top, (SHORT)(left + width - 1), (SHORT)(top + height - 1) });
}
//删除窗格
void DestroyPannel(ConsoleWindow* window, Pannel* pannel) {
window->RemovePannel(pannel);
}
//设置Pannel行缓存大小
bool SetMaxLineCache(Pannel* pannel, int lineCount) {
if (lineCount < 0) return false;
pannel->maxLineCount = lineCount;
return true;
}
//向Pannel中添加文本
void AddPannelText(Pannel* pannel, const char* _text, bool focus, bool utf8, int attribute) {
std::string text;
if (utf8) text = UTF8ToANSI(_text);
else text = _text;
pannel->AddText(text, focus, attribute);
}
//向Pannel中添加行
void AddPannelLine(Pannel* pannel, const char* _text, bool focus, bool utf8, int attribute) {
std::string text;
if (utf8) text = UTF8ToANSI(_text);
else text = _text;
pannel->AddLine(text, focus, attribute);
}
//清空Pannel
void ClearPannel(Pannel* pannel) {
pannel->Clear();
}
//移动或改变Pannel大小
bool MovePannel(Pannel* pannel, int left, int top, int width, int height) {
if(left > 32767 || top > 32767 || width > 32767 || height > 32767) return false;
if (left < 0) left = pannel->area.Left;
if (top < 0) top = pannel->area.Top;
if (width <= 5) width = pannel->area.Right - pannel->area.Left + 1;
if (height <= 5) height = pannel->area.Bottom - pannel->area.Top+ 1;
pannel->Move({ (SHORT)left, (SHORT)top, (SHORT)(left + width - 1), (SHORT)(top + height - 1)});
return true;
}
//向前滚屏
bool ScrollPannelBackward(Pannel* pannel, int lineCount) {
return pannel->ScrollBackward(lineCount);
}
//向后滚屏
bool ScrollPannelForward(Pannel* pannel, int lineCount) {
return pannel->ScrollForward(lineCount);
}
//滚动到特定行
bool ScrollPannelTo(Pannel* pannel, int lineTo) {
return pannel->ScrollTo(lineTo);
}
//将光标设置到窗格的特定位置
bool FocusOnPannel(Pannel* pannel, int offsetLeft, int offsetTop) {
return pannel->Focus({ (SHORT)offsetLeft, (SHORT)offsetTop });
}
//创建一条分隔线。
Spliter* CreateSpliter(ConsoleWindow* window, int left, int top, int length, bool verticle, int attribute) {
if (length <= 0
|| left < 0 || left >= window->bufferSize.X
|| top < 0 || top >= window->bufferSize.Y
) return NULL;
return window->NewSpliter({ (SHORT)left, (SHORT)top}, length, verticle, attribute);
}
//删除分隔线
void DestroySpliter(ConsoleWindow* window, Spliter* spliter) {
window->RemoveSpliter(spliter);
}
//移动或重新设定分隔线长度
bool MoveSpliter(Spliter* spliter, int left, int top, int len) {
if (left < 0 || left > 32767 || top < 0 || top > 32767 || len < 0) return false;
spliter->Move({ (SHORT)left, (SHORT)top }, len);
return true;
}
Binary file added test_x64/conctrl.dll
Binary file not shown.
Loading

0 comments on commit 45c72a6

Please sign in to comment.