📄 screenedit.h
字号:
/************************************************************************************
Copyright (c) 2000 Aaron O'Neil
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1) Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2) Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3) Redistributions in binary form must reproduce the above copyright notice on
program startup. Additional credits for program modification are acceptable
but original copyright and credits must be visible at startup.
4) You may charge a reasonable copying fee for any distribution of Mud Master.
You may charge any fee you choose for support of Mud Master. You may not
charge a fee for Mud Master itself.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**************************************************************************************/
class CScreenEdit
{
public:
CScreenEdit(const char *pszText, int nMaxLen);
~CScreenEdit();
// Tells the control to start editing. Returns TRUE if the user
// wants to keep this text. FALSE if they cancelled it.
BOOL Edit();
// Returns TRUE if the user selected to save the text in the
// editor. Returns FALSE if they aborted.
BOOL IsValid() { return(m_bIsValid); }
// Appends a null to the internal buffer and returns a constant
// pointer to the data. Don't type cast this back to a normal
// pointer and modify it.
const char *GetText();
protected:
// Sets up the editor screen.
void DrawScreen();
// Draws a line from the text buffer to the screen.
void DrawLine(int nTextIndex, int nScreenLine);
// Redraws all the text in the client part of the screen.
void RedrawText();
void ArrowRight();
void ArrowLeft();
void ArrowDown();
void ArrowUp();
void Home();
void End();
void CtrlArrowLeft();
void CtrlArrowRight();
void InsertChar(unsigned char ch);
void DeleteChar();
void BackSpace();
// This puts the cursor on the matching closing/opening char
// for parens and braces.
void MatchingChar();
// Prints a menu of commands at the bottom of the screen. Returns
// the letter the user selected.
char Menu();
private:
// Using 2 screen to page flipping.
CScreen m_screen[2];
int m_nActiveScreen;
// Allocated in the constructor. Freed in destructor.
char *m_pTextBuf;
// Maximum length that text can grow to.
int m_nMaxLen;
// Current index into the text buffer.
int m_nTextIndex;
// Current length of the text buffer.
int m_nTextLen;
// The number of screen lines the text in the buffer represents.
int m_nNumLines;
// This is the character index of the text buffer that appears
// at the upper left corner of the screen.
int m_nTopIndex;
// The line and column of the cursor on the screen.
int m_nCurrentLine;
int m_nCurrentCol;
// Colors for the border.
WORD m_wBorderAttr;
// Colors for the text.
WORD m_wTextAttr;
// Colors for menu prompt.
WORD m_wMenuAttr;
// Size of the editor screen. This is the size including
// the borders. The actual client size for the text is
// smaller.
int m_nLeft;
int m_nTop;
int m_nRight;
int m_nBottom;
// The "client" area where the user's text will appear.
int m_nClientLeft;
int m_nClientTop;
int m_nClientRight;
int m_nClientBottom;
// The maximum number of characters that will fit in the
// client line.
int m_nLineLen;
BOOL m_bIsValid;
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -