完善Readme
This commit is contained in:
@@ -6,10 +6,11 @@
|
||||
## 特性
|
||||
  你可以将控制台窗口分割为若干个**窗格**,窗格之间可创建**分割线**来区别它们。每个窗格拥有一个行缓存,包含若干**行**。你可以改变行缓存的大小。
|
||||
|
||||
  你可以动态地为**窗格**增加**行**,仅需要向窗格添加文本,窗格将自动把文本分割为适应的行,改变窗格大小它也将自动更新。
|
||||
  你可以动态地为**窗格**增加**行**,仅需要向窗格添加文本,窗格将自动把文本分割为适应的行,改变窗格大小它也将自动更新。支持ANSI和UTF-8两种编码格式。
|
||||
|
||||
  你可以为每一**行**设定字符格式,字符格式由Windows的一些<a href="#constant">常量</a>定义。
|
||||
|
||||
<font color="red">  这不是一个设计严谨的库,使用需谨慎。</font>
|
||||
|
||||
## 开发环境
|
||||
  Windows,Visual Studio 2017
|
||||
@@ -109,7 +110,9 @@
|
||||
* 对用户输入的控制比较无力
|
||||
* 只能对整行设定字符样式
|
||||
* 分割线的交点没有做特殊处理很难看
|
||||
* 不支持Unicode
|
||||
* **功能没有全部测试**
|
||||
* 由于未知原因,g++编译测试示例时失败,仅VS编译成功(不是get_s的原因==)
|
||||
* 其他
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{629BA97E-AE88-4F62-8ABB-EDBC575D5284}</ProjectGuid>
|
||||
<RootNamespace>test</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -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 not shown.
@@ -0,0 +1,106 @@
|
||||
// ConsoleController
|
||||
// 2018-11-28
|
||||
// By Mattuy
|
||||
#ifndef _HEAD_CONSOLE_CONTROLLER_
|
||||
#define _HEAD_CONSOLE_CONTROLLER_
|
||||
#ifdef __cplusplus //cpp
|
||||
class ConsoleWindow;
|
||||
class Pannel;
|
||||
class Spliter;
|
||||
#else //C
|
||||
typedef void ConsoleWindow;
|
||||
typedef void Pannel;
|
||||
typedef void Spliter;
|
||||
#endif
|
||||
extern "C" {
|
||||
/**
|
||||
* 创建控制台控制器
|
||||
* @return value, 指向当前控制台的控制台操作对象的指针,作为其他函数的参数,以通过它控制
|
||||
* 控制台。失败返回0
|
||||
* @param width, 屏幕缓冲区宽度,有效范围(5, 32767),默认80
|
||||
* @param height, 屏幕缓冲区高度,有效范围(5, 32767),默认40
|
||||
*/
|
||||
ConsoleWindow* CreateConsoleWindow(int width = 80, int height = 40);
|
||||
//还原控制台,销毁控制器
|
||||
void DestroyConsoleWindow(ConsoleWindow* window);
|
||||
//重新设置窗口和缓冲区大小
|
||||
bool ResizeScreenBuffer(ConsoleWindow* window, int width, int height);
|
||||
/**
|
||||
* 设置控制台窗口标题
|
||||
* @param window, 要设置标题的窗口
|
||||
* @param title, 要设置的标题
|
||||
* @param utf8, 是否utf8编码。UTF-8请设为非0,否则当作ANSI处理
|
||||
*/
|
||||
bool SetConsoleWindowTitle(char* title, bool utf8 = false);
|
||||
/**
|
||||
* 创建一个窗格。
|
||||
* @return value, 指向一个窗格的指针
|
||||
* @param window, 窗格所属窗口
|
||||
* @param left, 窗格相对窗口的水平偏移,有效范围(5, 32767)
|
||||
* @param top, 窗格相对窗口的竖直偏移,有效范围(5, 32767)
|
||||
* @param width, 窗格的宽度,有效范围(5, 32767)
|
||||
* @param height, 窗格的高度,有效范围(5, 32767)
|
||||
*/
|
||||
Pannel* CreatePannel(ConsoleWindow* window, int left, int top, int width, int height);
|
||||
//删除窗格
|
||||
void DestroyPannel(ConsoleWindow* window, Pannel* pannel);
|
||||
//设置窗格行缓存大小(行数)
|
||||
bool SetMaxLineCache(Pannel* pannel, int lineCount);
|
||||
/**
|
||||
* 向Pannel中添加文本。如果行缓冲区中上一行不是换行符结尾或调用【AddPannelLine】函数添加的,新
|
||||
* 文本将合并到上一行。原文本属性也会被覆盖。
|
||||
* @param window, 窗格所属窗口
|
||||
* @param text, 要添加的字符串
|
||||
* @param focus, 是否将光标移动到新添加的文本后
|
||||
* @param utf8, 是否utf8编码。仅支持ANSI编码和UTF-8编码,并且UTF-8编码也将被转换为ANSI
|
||||
* 编码。默认为false
|
||||
* @param attribute, 行文本属性,由Windows定义的控制台常量,默认黑底白字
|
||||
*/
|
||||
void AddPannelText(Pannel* pannel, const char* text, bool focus, bool utf8 = false, int attribute = 7);
|
||||
//与AddText唯一的不同是,如果字符串不是以换行符结尾,将自动插入换行符
|
||||
void AddPannelLine(Pannel* pannel, const char* text, bool focus, bool utf8 = false, int attribute = 7);
|
||||
//清空Pannel。这将同时清除pannel的行缓冲区
|
||||
void ClearPannel(Pannel* pannel);
|
||||
//移动或改变Pannel大小,参数同【CreatePannel】。如果参数分量无效,该分量将不会改变
|
||||
bool MovePannel(Pannel* pannel, int left, int top, int width, int height);
|
||||
/**
|
||||
* 向前滚屏。
|
||||
* @return value, 如果滚动前已触顶返回false,否则返回true
|
||||
* @param pannel, 要滚动的窗格
|
||||
* @param lineCount, 要滚动的行数,如果小于0滚动一屏(相对窗格)
|
||||
*/
|
||||
bool ScrollPannelBackward(Pannel* pannel, int lineCount);
|
||||
//向后滚屏。
|
||||
bool ScrollPannelForward(Pannel* pannel, int lineCount);
|
||||
//滚动到特定行。如果行号小于0滚到最后,否则如果行号无效返回false
|
||||
bool ScrollPannelTo(Pannel* pannel, int lineTo);
|
||||
/**
|
||||
* 将光标设置到窗格的特定位置。
|
||||
* @return value, 如果offset超出窗格范围则设置失败
|
||||
* @param pannel, 要设置光标所在的窗格
|
||||
* @param offsetLeft, 光标相对窗格左上角的水平偏移,默认为0
|
||||
* @param offsetTop, 光标相对窗格左上角的垂直偏移,默认为0
|
||||
*/
|
||||
bool FocusOnPannel(Pannel* pannel, int offsetLeft = 0, int offsetTop = 0);
|
||||
/**
|
||||
* 创建一条分隔线。
|
||||
* @return value, 指向一条分隔线的指针
|
||||
* @param window, 窗格所属的窗口
|
||||
* @param left, 分隔线相对窗口的水平偏移,有效范围(5, 32767)
|
||||
* @param top, 分隔线相对窗口的竖直偏移,有效范围(5, 32767)
|
||||
* @param length, 分割线的长度或宽度。是前者还是后者取决于@param verticle
|
||||
* @param verticle, 是水平分隔线还是竖直分隔线。0为水平,非0为竖直
|
||||
* @param attribute, 分割线的文本属性,由Windows定义的控制台常量,默认黑底白字
|
||||
*/
|
||||
Spliter* CreateSpliter(ConsoleWindow* window, int left, int top, int length, bool verticle, int attribute = 7);
|
||||
//删除分隔线
|
||||
void DestroySpliter(ConsoleWindow* window, Spliter* spliter);
|
||||
/**
|
||||
* 移动或重新设定分隔线的长度
|
||||
* @param left, 相对窗格的水平偏移,如果小于0则不改变
|
||||
* @param top, 相对窗口的垂直偏移,如果小于0则不改变
|
||||
* @param len, 新的长度/高度。如果小于0则不改变
|
||||
*/
|
||||
bool MoveSpliter(Spliter* spliter, int left, int top, int len);
|
||||
}
|
||||
#endif // !_HEAD_CONSOLE_CONTROLLER_
|
||||
Binary file not shown.
@@ -2,16 +2,17 @@
|
||||
#include <string.h>
|
||||
#include <Windows.h>
|
||||
#include "conctrl.h"
|
||||
#pragma comment(lib, "conctrl.lib")
|
||||
int main() {
|
||||
ConsoleWindow* window = CreateConsoleWindow(80, 40);
|
||||
Pannel* messagePannel = CreatePannel(window, 0, 0, 78, 25);
|
||||
Pannel* writePannel = CreatePannel(window, 0, 26, 80, 40);
|
||||
Spliter* spliter = CreateSpliter(window, 0, 25, 80, false, FOREGROUND_GREEN);
|
||||
AddPannelText(messagePannel, "输入任意内容,回车发送", true, true, 7);
|
||||
AddPannelText(messagePannel, "请在下方输入任意内容", true, true, 7);
|
||||
FocusOnPannel(writePannel, 0, 0);
|
||||
while (true) {
|
||||
char text[1024];
|
||||
gets_s(text, 1024);
|
||||
gets(text);
|
||||
AddPannelText(messagePannel, text, false, false, FOREGROUND_RED | FOREGROUND_GREEN);
|
||||
ClearPannel(writePannel);
|
||||
FocusOnPannel(writePannel, 0, 0);
|
||||
Reference in New Issue
Block a user