📄 tintinparse.cpp
字号:
// else if (IsAbrev( strCommand, "tablist" ))
// {
// tablist( complete_head );
// }
// else if (IsAbrev( strCommand, "tabadd" ))
// {
// tab_add( strArgs );
// }
// else if (IsAbrev( strCommand, "tabdelete" ))
// {
// tab_delete(strArgs);
// }
// else if (IsAbrev( strCommand, "textin" ))
// {
// read_file( strArgs );
// }
// else if (IsAbrev( strCommand, "unsplit" ))
// {
// unsplit_strCommand();
// }
// else if (IsAbrev( strCommand, "substitute" ))
// {
// parse_sub( strArgs );
// }
// else if (IsAbrev( strCommand, "gag" ))
// {
// if (*strArgs != '{')
// {
// strcpy( strCommand, strArgs );
// strcpy( strArgs, "{" );
// strcat( strArgs, strCommand );
// strcat( strArgs, "} " );
// }
// strcat( strArgs, " ." );
//
// parse_sub( strArgs );
// }
// else if (IsAbrev( strCommand, system_com ))
// {
// system_strCommand( strArgs );
// }
// else if (IsAbrev( strCommand, "tick" ))
// {
// tick_strCommand();
// }
// else if (IsAbrev( strCommand, "tickoff" ))
// {
// tickoff_strCommand();
// }
// else if (IsAbrev( strCommand, "tickon" ))
// {
// tickon_strCommand();
// }
// else if (IsAbrev( strCommand, "tickset" ))
// {
// tickset_strCommand();
// }
// else if (IsAbrev( strCommand, "ticksize" ))
// {
// ticksize_strCommand( strArgs );
// }
// else if (IsAbrev( strCommand, "tolower" ))
// {
// tolower_strCommand( strArgs );
// }
// else if (IsAbrev( strCommand, "togglesubs" ))
// {
// togglesubs_strCommand();
// }
// else if (IsAbrev( strCommand, "toupper" ))
// {
// toupper_strCommand( strArgs );
// }
// else if (IsAbrev( strCommand, "unaction" ))
// {
// unaction_strCommand( strArgs );
// }
// else if (IsAbrev( strCommand, "unantisubstitute" ))
// {
// unantisubstitute_strCommand( strArgs );
// }
// else if (IsAbrev( strCommand, "unhighlight" ))
// {
// unhighlight_strCommand( strArgs );
// }
// else if (IsAbrev( strCommand, "unsubstitute" ))
// {
// unsubstitute_strCommand( strArgs );
// }
// else if (IsAbrev( strCommand, "ungag" ))
// {
// unsubstitute_strCommand( strArgs );
// }
// else if (IsAbrev( strCommand, "unpath" ))
// {
// unpath_strCommand();
// }
// else if (IsAbrev( strCommand, "variable" ))
// {
// var_strCommand( strArgs );
// }
// else if (IsAbrev( strCommand, "version" ))
// {
// version_strCommand();
// }
// else if (IsAbrev( strCommand, "unvariable" ))
// {
// unvar_strCommand( strArgs );
// }
// else if (IsAbrev( strCommand, "write" ))
// {
// write_strCommand( strArgs );
// }
// else if (IsAbrev( strCommand, "writesession" ))
// {
// writesession_strCommand( strArgs );
// }
// else if (IsAbrev( strCommand, "zap" ))
// {
// zap_strCommand();
// }
#endif
}
/*----------------------------------------------------------------------------
TinTin::IsSpeedwalkDirective
Returns true if command consists only of the letters
[n,s,e,w,u,d] or digits followed by those letters.
----------------------------------------------------------------------------*/
bool TinTin::IsSpeedwalkDirective( const char* pstrCmd )
{
bool boolSpeedWalk = false;
while (*pstrCmd)
{
if ((*pstrCmd != 'n') && (*pstrCmd != 'e') && (*pstrCmd != 's') &&
(*pstrCmd != 'w') && (*pstrCmd != 'u') && (*pstrCmd != 'd') &&
!isdigit( *pstrCmd ))
{
return false;
}
if (!isdigit( *pstrCmd ))
{
boolSpeedWalk = TRUE;
}
pstrCmd++;
}
return boolSpeedWalk;
}
/*----------------------------------------------------------------------------
TinTin::DoSpeedwalk
This function will interpret and perform a speedwalk
command.
----------------------------------------------------------------------------*/
void TinTin::DoSpeedwalk( const char* pstrCmd )
{
while (*pstrCmd)
{
const char* pstrStart = pstrCmd;
bool boolMultiple = false;
char cDirection;
int iCount;
while (isdigit( *pstrCmd ))
{
pstrCmd++;
boolMultiple = true;
}
if (boolMultiple && *pstrCmd)
{
if (2 == sscanf( pstrStart, "%d%c", &iCount, cDirection ))
{
for (int iLoop = 0; iLoop < iCount; iLoop++)
{
SendToWorld( cDirection );
}
}
}
else if (*pstrCmd)
{
SendToWorld( cDirection );
}
if (*pstrCmd)
{
pstrCmd++;
}
}
}
/*----------------------------------------------------------------------------
TinTin::GetArgStopAtSpaces
Get all arguments - don't remove double-quotes or
back-slashes.
----------------------------------------------------------------------------*/
const char* TinTin::GetArgAll( const char* pstrText, string& strArg )
{
int iNestLevel = 0;
strArg = "";
pstrText = SpaceOut( pstrText );
while (*pstrText)
{
if (*pstrText == '\\')
{ /* Next character is quoted,
so leave it in to be
processed later */
strArg += *pstrText++;
if (*pstrText)
{
strArg += *pstrText++;
}
}
else if ((*pstrText == ';') && (0 == iNestLevel))
{
// Semicolon ends the command...
break;
}
else if (*pstrText == DEF_OPEN)
{ // Open argument
iNestLevel++;
strArg += *pstrText++;
}
else if (*pstrText == DEF_CLOSE)
{ // Close argument
if (0 > --iNestLevel)
{
iNestLevel = 0;
}
strArg += *pstrText++;
}
else
{ // Copy the character
strArg += *pstrText++;
}
}
return pstrText;
}
/*----------------------------------------------------------------------------
TinTin::GetArgInBraces
Get the argument. If the argument is bracketed with
curly braces, just get that part.
----------------------------------------------------------------------------*/
const char* TinTin::GetArgInBraces( const char* pstrText, string& strArg,
bool boolIncludeSpaces )
{
int iNestLevel = 0;
const char* pstrTemp;
string strResult;
pstrText = SpaceOut( pstrText );
pstrTemp = pstrText;
if (*pstrText != DEF_OPEN)
{ // This isn't bracketed in braces
if (boolIncludeSpaces)
{
pstrText = GetArgWithSpaces( pstrText, strArg );
}
else
{
pstrText = GetArgStopAtSpaces( pstrText, strArg );
}
return pstrText;
}
pstrText++;
while (*pstrText && !((*pstrText == DEF_CLOSE) && (iNestLevel == 0)))
{
if (*pstrText == DEF_OPEN)
{
iNestLevel++;
}
else if (*pstrText == DEF_CLOSE)
{
iNestLevel--;
}
strResult += *pstrText++;
}
strArg = strResult;
if (!*pstrText)
{ /* There should be a '}' still
in the buffer */
Display( "# Unmatched braces error!" );
}
else
{ // Skip the close brace
pstrText++;
}
return pstrText;
}
/*----------------------------------------------------------------------------
TinTin::GetArgStopAtSpaces
Gets a single argument, stopping at spaces and removing
quotes.
----------------------------------------------------------------------------*/
const char* TinTin::GetArgStopAtSpaces( const char* pstrText, string& strArg )
{
bool boolInside = false;
strArg = "";
pstrText = SpaceOut( pstrText );
while (*pstrText)
{
if (*pstrText == '\\')
{ // Next character is quoted
if (*++pstrText)
{
strArg += *pstrText++;
}
}
else if (*pstrText == '"')
{ // We're inside a double-quote
pstrText++;
boolInside = !boolInside;
}
else if (*pstrText == ';')
{
if (boolInside)
{ /* Semicolon inside a double-quote.
Copy it verbatim. */
strArg += *pstrText++;
}
else
{ // Semicolon ends the command...
break;
}
}
else if (!boolInside && (*pstrText == ' '))
{
// End at a space...
break;
}
else
{ // Copy the character
strArg += *pstrText++;
}
}
return pstrText;
}
/*----------------------------------------------------------------------------
TinTin::GetArgWithSpaces
Gets the entire argument, including spaces,
removing quotes.
For example:
In: "this is it" way way hmmm;
Out: this is it way way hmmm
----------------------------------------------------------------------------*/
const char* TinTin::GetArgWithSpaces( const char* pstrText, string& strArg )
{
int iNestLevel = 0;
string strTemp;
pstrText = SpaceOut( pstrText );
while (*pstrText)
{
if (*pstrText == '\\')
{
if (*++pstrText)
{
strTemp += *pstrText++;
}
}
else if ((*pstrText == ';') && (0 == iNestLevel))
{
break;
}
else if (*pstrText == DEF_OPEN)
{
iNestLevel++;
strTemp += *pstrText++;
}
else if(*pstrText == DEF_CLOSE)
{
strTemp += *pstrText++;
iNestLevel--;
}
else
{
strTemp += *pstrText++;
}
}
strArg = strTemp;
return pstrText;
}
/*----------------------------------------------------------------------------
TinTin::SpaceOut
Advances point to next non-space.
----------------------------------------------------------------------------*/
const char* TinTin::SpaceOut( const char* pstrText )
{
while (isspace( *pstrText ))
{
pstrText++;
}
return pstrText;
}
#if 0
/*********************************************************************/
/* file: parse.c - some utility-functions */
/* TINTIN III */
/* (T)he K(I)cki(N) (T)ickin D(I)kumud Clie(N)t */
/* coded by peter unold 1992 */
/*********************************************************************/
#ifdef HAVE_STRING_H
#include <string.h>
#else
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
struct session *parse_tintin_command();
void do_speedwalk();
char *get_arg_with_spaces();
extern struct listnode *searchnode_list_begin();
extern struct session *all_command();
extern struct session *read_command();
extern struct session *session_command();
extern struct session *write_command();
extern struct session *writesession_command();
extern struct session *zap_command();
extern struct completenode *complete_head;
extern char *space_out();
extern char *get_arg_in_braces();
void write_com_arg_mud();
void prompt();
extern char k_input[240];
extern struct session *sessionlist, *activesession;
extern struct listnode *common_aliases, *common_actions, *common_subs;
extern struct listnode *common_myvars, *common_antisubs;
extern char vars[10][BUFFER_SIZE]; /* the %0, %1, %2,....%9 variables */
extern char tintin_char, verbatim_char;
extern int term_echoing, verbatim;
extern int speedwalk, is_split, display_row, display_col, input_row, input_col;
extern char system_com[80];
extern void action_command();
extern void unhighlight_command();
extern char *get_arg_stop_spaces();
extern char *cryptkey;
extern char *get_arg_all();
extern void tstphandler();
/**********************************************/
/* get all arguments - don't remove "s and \s */
/**********************************************/
char *get_arg_all(s, arg)
char *s;
char *arg;
{
/* int inside=FALSE; */
int nest=0;
s=space_out(s);
while(*s) {
if(*s=='\\') {
*arg++=*s++;
if(*s)
*arg++=*s++;
}
else if(*s==';' && nest<1) {
break;
}
else if(*s==DEFAULT_OPEN) {
nest++;
*arg++=*s++;
}
else if(*s==DEFAULT_CLOSE) {
nest--;
*arg++=*s++;
}
else
*arg++=*s++;
}
*arg='\0';
return s;
}
#endif // 0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -