📄 commandsstoz.cpp
字号:
}
else
bResult = FALSE;
if (bResult)
{
if (_config.bStatusBar)
_statusBar.Redraw();
if (_config.bBarMessages)
PrintMessage("Bar item removed.");
}
else
{
if (_config.bBarMessages)
PrintMessage("Bar item found.");
}
}
void UnChat(CString &strLine)
{
CString strIndex;
FindStatement(strLine,strIndex);
if (strIndex.IsEmpty())
return;
ReplaceVariables(strIndex);
CString strName;
SOCKET hSocket;
CHAT *pChat;
BOOL bResult;
int nIndex = atoi(strIndex);
if (nIndex)
{
pChat = _chat.GetAt(nIndex-1);
if (pChat)
{
strName = pChat->strName;
hSocket = pChat->hSocket;
}
bResult = _chat.Remove(nIndex-1);
}
else
{
pChat = _chat.FindName(strIndex);
if (pChat)
{
strName = pChat->strName;
hSocket = pChat->hSocket;
}
bResult = _chat.Remove(strIndex);
}
if (bResult)
{
PrintMessage("Chat disconnected.");
_notifyChatDisconnect.Notify(hSocket,strName);
}
else
PrintMessage("Chat not found.");
}
void UnDo(CString &strLine)
{
CString strIndex;
FindStatement(strLine,strIndex);
// List all the items in the undo buffer.
if (strIndex.IsEmpty())
{
PrintMessage("Undo Items:");
CommandPrintOn();
CString strText;
char *ptr;
int nResult;
int nLineCount = 1;
int nNumLines = _terminal.GetWindowLines()-2;
int nInc;
UNDO *pUndo = _undo.GetFirst();
while(pUndo != NULL)
{
ptr = strText.GetBuffer(pUndo->strText.GetLength()+80);
nResult = sprintf(ptr,"%s%03d:%s %s\n",
ANSI_F_BOLDWHITE,
_undo.GetFindIndex()+1,
ANSI_RESET,
(const char *)pUndo->strText);
strText.ReleaseBuffer(nResult);
_terminal.Print(strText);
if (_config.bPause)
{
nInc = strText.GetLength() / 80 + 1;
nLineCount += nInc;
if (nLineCount >= nNumLines)
if (PausePrompt())
nLineCount = 0;
else
break;
}
pUndo = _undo.GetNext();
}
CommandPrintOff();
return;
}
int nIndex = atoi(strIndex)-1;
UNDO *pUndo = _undo.GetAt(nIndex);
if (pUndo != NULL)
{
CString strText(pUndo->strText);
ProcessLine(strText);
}
}
void UnEvent(CString &strLine)
{
CString strIndex;
FindStatement(strLine,strIndex);
if (strIndex.IsEmpty())
return;
ReplaceVariables(strIndex);
BOOL bResult;
EVENT *pEvent;
int nIndex = atoi(strIndex);
if (nIndex)
pEvent = _events.GetAt(nIndex-1);
else
pEvent = _events.FindByName(strIndex);
if (pEvent != NULL)
{
char *pBuf;
int nResult;
CString strText;
pBuf = strText.GetBuffer(pEvent->strName.GetLength()+pEvent->strEvent.GetLength()+pEvent->strGroup.GetLength()+40);
nResult = sprintf(pBuf,"%cevent {%s} {%d} {%s} {%s}",_config.chCommand,
(const char *)pEvent->strName,
pEvent->nSeconds,
(const char *)pEvent->strEvent,
(const char *)pEvent->strGroup);
strText.ReleaseBuffer(nResult);
_undo.Add(strText);
if (nIndex)
bResult = _events.Remove(nIndex-1);
else
bResult = _events.Remove(strIndex);
}
else
bResult = FALSE;
if (_config.bEventMessages)
if (bResult)
PrintMessage("Event Removed.");
else
PrintMessage("Event not found.");
}
void UnGag(CString &strLine)
{
CString strMask;
FindStatement(strLine,strMask);
if (strMask.IsEmpty())
return;
ReplaceVariables(strMask);
BOOL bResult;
GAG *pGag;
int nIndex = atoi(strMask);
if (nIndex)
pGag = _gags.GetAt(nIndex-1);
else
pGag = _gags.FindExact(strMask);
if (pGag != NULL)
{
char *pBuf;
int nResult;
CString strTemp, strText;
_gags.GagToMask(pGag,strTemp);
pBuf = strText.GetBuffer(strTemp.GetLength()+pGag->strGroup.GetLength()+30);
nResult = sprintf(pBuf,"%cgag {%s} {%s}",
_config.chCommand,
(const char *)strTemp,
(const char *)pGag->strGroup);
strText.ReleaseBuffer(nResult);
_undo.Add(strText);
if (nIndex)
bResult = _gags.Remove(nIndex-1);
else
bResult = _gags.Remove(strMask);
}
else
bResult = FALSE;
if (bResult)
{
if (_config.bGagMessages)
PrintMessage("Gag removed.");
}
else
{
if (_config.bGagMessages)
PrintMessage("Gag not found.");
}
}
void UnHighlight(CString &strLine)
{
CString strParam1;
FindStatement(strLine,strParam1);
if (strParam1.IsEmpty())
return;
ReplaceVariables(strParam1);
BOOL bResult;
HIGHLIGHT *pHigh;
int nIndex = atoi(strParam1);
if (nIndex)
pHigh = _highlights.GetAt(nIndex-1);
else
pHigh = _highlights.FindExact(strParam1);
if (pHigh != NULL)
{
CString strText, strTemp, strColor;
char *pBuf;
int nResult;
_highlights.HighlightToMask(pHigh,strTemp);
_highlights.AttrToText(pHigh->wAttr,strColor);
pBuf = strText.GetBuffer(strTemp.GetLength()+strColor.GetLength()+pHigh->strGroup.GetLength()+40);
nResult = sprintf(pBuf,"%chighlight {%s} {%s} {%s}",
_config.chCommand,
(const char *)strTemp,
(const char *)strColor,
(const char *)pHigh->strGroup);
strText.ReleaseBuffer(nResult);
_undo.Add(strText);
if (nIndex)
bResult = _highlights.Remove(nIndex-1);
else
bResult = _highlights.Remove(strParam1);
}
else
bResult = FALSE;
if (bResult)
{
if (_config.bHighMessages)
PrintMessage("Highlight removed.");
}
else
{
if (_config.bHighMessages)
PrintMessage("Highlight not found.");
}
}
void UnMacro(CString &strLine)
{
CString strParam1;
FindStatement(strLine,strParam1);
if (strParam1.IsEmpty())
return;
ReplaceVariables(strParam1);
BOOL bResult;
MACRO *pMac;
int nIndex = atoi(strParam1);
if (nIndex)
pMac = _macros.GetAt(nIndex-1);
else
pMac = _macros.FindKeyByName(strParam1);
if (pMac != NULL)
{
char *pBuf;
int nResult;
CString strText;
pBuf = strText.GetBuffer(pMac->strKeyName.GetLength()+pMac->strText.GetLength()+pMac->strGroup.GetLength()+40);
nResult = sprintf(pBuf,"%cmacro {%s} {%s} {%s}",_config.chCommand,
(const char *)pMac->strKeyName,
(const char *)pMac->strText,
(const char *)pMac->strGroup);
strText.ReleaseBuffer(nResult);
_undo.Add(strText);
if (nIndex)
bResult = _macros.Remove(nIndex-1);
else
bResult = _macros.Remove(strParam1);
}
else
bResult = FALSE;
if (bResult)
{
if (_config.bMacroMessages)
PrintMessage("Macro cleared.");
}
else
{
if (_config.bMacroMessages)
PrintMessage("Macro not defined.");
}
}
void UnSubstitute(CString &strLine)
{
CString strParam1;
FindStatement(strLine,strParam1);
if (strParam1.IsEmpty())
return;
ReplaceVariables(strParam1);
BOOL bResult;
SUB *pSub;
int nIndex = atoi(strParam1);
if (nIndex)
pSub = _subs.GetAt(nIndex-1);
else
pSub = _subs.FindExact(strParam1);
if (pSub != NULL)
{
CString strTemp, strText;
char *pBuf;
int nResult;
_subs.SubToTrigger(pSub,strTemp);
pBuf = strText.GetBuffer(strTemp.GetLength()+pSub->strSub.GetLength()+pSub->strGroup.GetLength()+40);
nResult = sprintf(pBuf,"%csub {%s} {%s} {%s}",
_config.chCommand,
(const char *)strTemp,
(const char *)pSub->strSub,
(const char *)pSub->strGroup);
strText.ReleaseBuffer(nResult);
_undo.Add(strText);
if (nIndex)
bResult = _subs.Remove(nIndex-1);
else
bResult = _subs.Remove(strParam1);
}
else
bResult = FALSE;
if (bResult)
{
if (_config.bSubMessages)
PrintMessage("Substitute removed.");
}
else
{
if (_config.bSubMessages)
PrintMessage("Substitute not found.");
}
}
void UnVariable(CString &strLine)
{
CString strParam1;
FindStatement(strLine,strParam1);
if (strParam1.IsEmpty())
return;
ReplaceVariables(strParam1);
BOOL bResult;
STRING_MAP *pStringMap;
int nIndex = atoi(strParam1);
if (nIndex)
pStringMap = _mapVars.GetAt(nIndex-1);
else
pStringMap = _mapVars.FindExactByKey(strParam1);
if (pStringMap != NULL)
{
CString strTemp, strText, strPrepare;
int nResult;
char *pBuf;
if (pStringMap->strText.IsEmpty())
{
pBuf = strTemp.GetBuffer(pStringMap->strKey.GetLength()+pStringMap->strGroup.GetLength()+40);
nResult = sprintf(pBuf,"%cempty {%s} {%s}\n",
_config.chCommand,
(const char *)pStringMap->strKey,
(const char *)pStringMap->strGroup);
strTemp.ReleaseBuffer(nResult);
}
else
{
PrepareForWrite(pStringMap->strText,strPrepare);
pBuf = strTemp.GetBuffer(pStringMap->strKey.GetLength()+strPrepare.GetLength()+pStringMap->strGroup.GetLength()+40);
nResult = sprintf(pBuf,"%cvariable {%s} {%s} {%s}\n",_config.chCommand,
(const char *)pStringMap->strKey,
(const char *)strPrepare,
(const char *)pStringMap->strGroup);
strTemp.ReleaseBuffer(nResult);
}
_undo.Add(strTemp);
if (nIndex)
bResult = _mapVars.Remove(nIndex-1);
else
bResult = _mapVars.Remove(strParam1);
}
else
bResult = FALSE;
if (bResult)
{
if (_config.bVarMessages)
PrintMessage("Variable removed.");
}
else
{
if (_config.bVarMessages)
PrintMessage("Variable not found.");
}
}
void UpdateBarItem(CString &strLine)
{
if (!_config.bStatusBar)
return;
CString strItem, strText;
FindStatement(strLine,strItem);
FindStatement(strLine,strText);
ReplaceVariables(strItem);
if (strItem.IsEmpty())
return;
BAR_ITEM *pItem;
int nIndex = atoi(strItem);
if (nIndex)
pItem = _statusBar.GetAt(nIndex-1);
else
pItem = _statusBar.FindItem(strItem);
if (pItem == NULL)
return;
if (!strText.IsEmpty())
pItem->strText = strText;
_tiUserInput.HideCursor();
_statusBar.DrawItem(pItem);
_tiUserInput.SetFocus();
_tiUserInput.ShowCursor();
}
void UpdateStatusBar(CString &strLine)
{
if (!_config.bStatusBar)
return;
_statusBar.Redraw();
}
void UploadPath(CString &strLine)
{
CString strPath;
FindStatement(strLine,strPath);
ReplaceVariables(strPath);
if (!strPath.IsEmpty())
if (strPath.Right(1) != "\\")
strPath += "\\";
_config.strUploadPath = strPath;
WriteIniString("Paths","Upload",strPath);
PrintMessage(CString("Upload path changed to: ")+strPath);
}
void Variable(CString &strLine)
{
CString strParam1, strParam2, strGroup;
CString strTemp;
int nVarNum;
FindStatement(strLine,strParam1);
FindStatement(strLine,strParam2);
FindStatement(strLine,strGroup);
if (strParam1.IsEmpty() && strParam2.IsEmpty())
{
PrintMessage("Defined Variables:");
CommandPrintOn();
CString strTemp;
char *pBuf;
int nResult;
int nLineCount = 1;
int nNumLines = _terminal.GetWindowLines()-2;
int nInc;
STRING_MAP *pMap = _mapVars.GetFirst();
while(pMap != NULL)
{
pBuf = strTemp.GetBuffer(pMap->strKey.GetLength()+pMap->strText.GetLength()+pMap->strGroup.GetLength()+40);
nResult = sprintf(pBuf,"%s%03d:%s {%s} {%s} {%s}\n",
ANSI_F_BOLDWHITE,
_mapVars.GetFindIndex()+1,
ANSI_RESET,
(const char *)pMap->strKey,
(const char *)pMap->strText,
(const char *)pMap->strGroup);
strTemp.ReleaseBuffer(nResult);
_terminal.Print(strTemp);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -