From 45c72a6b3e018a21445391acdc20cd126dceeb33 Mon Sep 17 00:00:00 2001 From: Mattuy Date: Sun, 2 Dec 2018 16:41:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84Readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 22 +++++- conctrl/conctrl.vcxproj | 1 - conctrl/conctrl.vcxproj.filters | 3 - test/test.vcxproj | 120 -------------------------------- test/test.vcxproj.filters | 17 ----- test_x64/conctrl.cpp | 114 ++++++++++++++++++++++++++++++ test_x64/conctrl.dll | Bin 0 -> 25600 bytes test_x64/conctrl.h | 106 ++++++++++++++++++++++++++++ test_x64/conctrl.lib | Bin 0 -> 5224 bytes {conctrl => test_x64}/main.cpp | 5 +- 10 files changed, 244 insertions(+), 144 deletions(-) delete mode 100644 test/test.vcxproj delete mode 100644 test/test.vcxproj.filters create mode 100644 test_x64/conctrl.cpp create mode 100644 test_x64/conctrl.dll create mode 100644 test_x64/conctrl.h create mode 100644 test_x64/conctrl.lib rename {conctrl => test_x64}/main.cpp (81%) diff --git a/README.md b/README.md index 4a7ad0b..592a682 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,11 @@ ## 特性   你可以将控制台窗口分割为若干个**窗格**,窗格之间可创建**分割线**来区别它们。每个窗格拥有一个行缓存,包含若干**行**。你可以改变行缓存的大小。 -  你可以动态地为**窗格**增加**行**,仅需要向窗格添加文本,窗格将自动把文本分割为适应的行,改变窗格大小它也将自动更新。 +  你可以动态地为**窗格**增加**行**,仅需要向窗格添加文本,窗格将自动把文本分割为适应的行,改变窗格大小它也将自动更新。支持ANSI和UTF-8两种编码格式。   你可以为每一**行**设定字符格式,字符格式由Windows的一些常量定义。 +  这不是一个设计严谨的库,使用需谨慎。 ## 开发环境   Windows,Visual Studio 2017 @@ -109,7 +110,9 @@ * 对用户输入的控制比较无力 * 只能对整行设定字符样式 * 分割线的交点没有做特殊处理很难看 +* 不支持Unicode * **功能没有全部测试** +* 由于未知原因,g++编译测试示例时失败,仅VS编译成功(不是get_s的原因==) * 其他 @@ -139,6 +142,23 @@ int main() { } ``` +## 文件列表 +
+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
+
+ ## 辅助资料 diff --git a/conctrl/conctrl.vcxproj b/conctrl/conctrl.vcxproj index f9f67dc..9f35470 100644 --- a/conctrl/conctrl.vcxproj +++ b/conctrl/conctrl.vcxproj @@ -22,7 +22,6 @@ - diff --git a/conctrl/conctrl.vcxproj.filters b/conctrl/conctrl.vcxproj.filters index dcf0c4e..6f8ab97 100644 --- a/conctrl/conctrl.vcxproj.filters +++ b/conctrl/conctrl.vcxproj.filters @@ -30,9 +30,6 @@ Source Files - - Source Files - diff --git a/test/test.vcxproj b/test/test.vcxproj deleted file mode 100644 index f7e7a8e..0000000 --- a/test/test.vcxproj +++ /dev/null @@ -1,120 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 15.0 - {629BA97E-AE88-4F62-8ABB-EDBC575D5284} - test - 10.0.17134.0 - - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - - - Level3 - MaxSpeed - true - true - true - true - - - true - true - - - - - Level3 - Disabled - true - true - - - - - Level3 - Disabled - true - true - - - - - Level3 - MaxSpeed - true - true - true - true - - - true - true - - - - - - \ No newline at end of file diff --git a/test/test.vcxproj.filters b/test/test.vcxproj.filters deleted file mode 100644 index 4863ddb..0000000 --- a/test/test.vcxproj.filters +++ /dev/null @@ -1,17 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - \ No newline at end of file diff --git a/test_x64/conctrl.cpp b/test_x64/conctrl.cpp new file mode 100644 index 0000000..450a0b0 --- /dev/null +++ b/test_x64/conctrl.cpp @@ -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; +} diff --git a/test_x64/conctrl.dll b/test_x64/conctrl.dll new file mode 100644 index 0000000000000000000000000000000000000000..2fae2cef3165fbe45c21fed4984f317e72b3c979 GIT binary patch literal 25600 zcmeHv4_H*!nfDzSVARn&8cZ-Hagty(B^qE*zybN^049zOB124qh%zG(1TxI{CkYWV zka%-4jhiNIzOHR_lXTrS{nl=6B^z4@F$}0Nn7W2U+tAjgm%yfIsiL8o@AsZNGYpzE zX`k=;o_+S)%X99z_xyR!d*1W@J@*Xe2X+aOf*`1o{C+`bM^0A`zkkV1B?!}I|NAuI zz@)ctYga9Q`?l59HBI_PN5e)(*EWHInCVw`zEPqE*N9?pCVb^u6v@74nFy-EFDJ ztDpC_#_+s{_p5$>Q5*HIe*QRrUsbcAn#QN-K#O4Yjr zp&zZUyY`?R7O1yU5E`$m952XOf6bb$L!a^L>z)=kZCjlv{Z>A1gdfc{fH$7_rN?X+ zII1e082jECC|ZXUi&TUZcI9B`1xhnPO)y%JFgGDYQ9R?y5d`l7N0Va%p7~rcXWnit z@~|t1;5lq{4QNPn7xo|#+;vD{SB@a$g}wgIMbH`El1yVI*0Ndw ze|~nAy^lw!ysvuTF9PNMnOFcF8q$BG!Y8cd?w87V&w9%h{t zYae9hF~i%k%7EA3mv`1iSp741Q}_2IQ@{JD#&fSqGM}^WdS-H7Yme(nV(B@nWfjKb zg9S#)QlkUM1{hiWu6|VS13&oRW5czo06@T!Oy{VTl?|g&UwFGVFYt_&*bYKl!ua)!A{_^vI}fQtow@2F_%T> z?zlp-=$OGQWA2VS5|6mOWA4$}TV}H(#TNMzy3qgyd;nhor+Zhlu(s1b^AJ!Wa3}bB zYMDt>0?3kSw2U=tF@R(qF<#knC;K&x6v1vSvy@0r=;XJu38c15JzHR1v}nICKcW$K z_;GC)pZ<{M@uB;;xZ_hQ*c|gFWrMe}Q|f^*C#_nLL#-pBW>=X0)3_YyV?Ny1- zcU*pd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B?eS^d1bWyyo5h|!7g4b$cmar)R zBc1xzIMHL1kTL#T0c|H#G})>v>@{@+jpGhC#=4zy^fw{5L)RyZry6UQac>}?ys2^AA6Zo+uf4lzq( z&HPPG^S9L0&)?v1&abvrHqNh0o}WBFu#VT%<3AHSYc|=!o4giPTCdQyDzrl2XG~2H zY*CP?FRY%)Wy|GoU>*p3HrU{jwnnW6!D{NE^n*phj>u(AftLnH0qg;&WO3Mo-79fFlOK@p|aXs)U=vO2JjO$|@8Jzvq&=t;uQIv>MaPZNda> z^d!Wqmew>8F_p&4Yt}m|9ozD;#!bT7$Yr6WDOnE2D*`y-QDD2&w%)aIqsxd+B2YA-^Cy*NVNa3a$hc4Jm}zg*4yi z)bW0_4^{zHQlY5gK(h%jLRv2;=f6C?{(B>+;;}Yd?3Ri1BwrZ&5ua0z!y>Rw@ZEL^ zLNhVXHCJZ#)=hQT(R4In4>fCU@`9wfdRzU5hAQlQX3Z^KT`)g=uD;0$TULoZP+QjA zZMLSl*-NHQ&a7-|vTa&lw@nWK^-WoGVVV{2$c7oaCJZpxyo@&OvYw@|SkaAkTn56kh%aZDnzMb^lq@O2U zNXkt1C4ZVS-Efnkz+g9AHP}mK@I( z^!R1~IL@S}lXfQ^O!`$)R&r(X#^j?Zr&8Wa`6%VjDgTjHlfF5T9X$g;@(9S@`C{ z%M0&YbYao9v`^D=)2->%>3JFU#akCYWE8S)Uh<4Vu){wAE=3rB$UhrtM053AEn_%AZc_PZQEL>ALjz z^vv|4bW3_``U~lM()XpGOCL%fOV?-IospWcE~6!5cgCKKeHr^R+Cl518GRZ386z2E m8S2H_#k$3@i{lq3EndFZvY0d+SYL=sN=>qWMtJ=H^7=o+TVCS; literal 0 HcmV?d00001 diff --git a/test_x64/conctrl.h b/test_x64/conctrl.h new file mode 100644 index 0000000..b215540 --- /dev/null +++ b/test_x64/conctrl.h @@ -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, ָǰ̨Ŀָ̨룬ΪIJͨ + * ̨ʧܷ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Ϊ0ANSI + */ + 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롣֧ANSIUTF-8룬UTF-8ҲתΪANSI + * 롣ĬΪfalse + * @param attribute, ıԣWindowsĿ̨ĬϺڵװ + */ + void AddPannelText(Pannel* pannel, const char* text, bool focus, bool utf8 = false, int attribute = 7); + //AddTextΨһIJͬǣַԻзβԶ뻻з + 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, ָߵijȻȡǰ߻Ǻȡ@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); + /** + * ƶ趨ָߵij + * @param left, ԴˮƽƫƣС0򲻸ı + * @param top, ԴڵĴֱƫƣС0򲻸ı + * @param len, µij/߶ȡС0򲻸ı + */ + bool MoveSpliter(Spliter* spliter, int left, int top, int len); +} +#endif // !_HEAD_CONSOLE_CONTROLLER_ diff --git a/test_x64/conctrl.lib b/test_x64/conctrl.lib new file mode 100644 index 0000000000000000000000000000000000000000..9f1234ab5a9410c840070893d9b57ea2757c6a52 GIT binary patch literal 5224 zcmcIn&2JM&6#v;SB(dYK7^Id`$rL17iKaBzp^>V{iBr@F=R>wpFG$PA-qfbX8`(~w zz4V4S@NZP&$bn05oVfK+r2YZ@9}ovF>6@J$`|WsaY@Dw2c4yw3ncvL&nzxs}vpcoM zdi3jT@cHVSU|;pF`;E2ys^7X71#lIZ4+GI_KGNyNJ>2+IZ@)Zq|`;~6Q%D8vaIc${k?M4 z+WNjyEN|~u_sUkyZP$987A$M`PN_6J0KfYqq`dmWo!#5k)<$&$R4{4d^gCol<+H$(Rj{B=|f>~B}y3OC5O0DBK?akxEL#LwvOp=Pz3#?sj_F9gb zFhVHLuy429j?e+yyyE#gQ(ZYkW76U~_M=j>?G)`=gJTBS8}+(er|LZFDL9SU?~3Jy z#zEZ*g!->(>_z(CrMZ+$u!tDq_z3gJ z;0zXU4ogVjJkBDC6w;VO6d{Bs8W(}3c~`$H9WvlVQp5%{19e4(2u*mxKED8=l4z%X<=kAPJAW&ua1}T&}lTUNU&!&7WJl z(ZBgip$JasiG}F?r>LbTv|M)%j(@sRkzHVe8gzvRo&r*v%gwsov#+cu!8vODMf9)F zh|sry>o5Irbo0xHk_b+S)HuN{Ap4Ta56Te>qKg_9x-Q4DpD~ zg`tjI0KDxs6vsQ9m=RH&oESq4^vC1}9Kp|um;Z>>fi=G;K4FyUeY%BDlpS{>Pg%*U zYVlsQ6bgHu@~5{su|>0|)IHJQ#XRMP;tEgsLv{SG@Ra|>117QSXS9ith2+#)yZP-< zeEmZJ(#U45jft(wu`ZqoaZJWa=!mM?=73Y{ wG&jcklR6?5@f?h`C)4K$Pq|F?OL #include #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);