⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tintinmisc.cpp

📁 Windows上的MUD客户端程序
💻 CPP
📖 第 1 页 / 共 2 页
字号:
				the argument.  The argument is an integer, whose
				interpretation is as follows:

				Argument:	Result:
				---------	--------------------------------------------------
					<0		Sets the number of lines for the input window.
					0		Does nothing.
					>0		Sets the number of lines for the input window to
							(24 - arg).
----------------------------------------------------------------------------*/

void TinTin::DoSplit( const string& strArgs )
{
	if (!strArgs.IsEmpty())
	{
		int		iCount = atoi( strArgs );
		bool	boolValid = false;

		if (iCount < 0)
		{
			iCount = -iCount;
			boolValid = true;
		}
		else if ((iCount > 0) && (iCount < 24))
		{									/* The number of lines they want
												for the output window.  Assume
												a 24-line screen and set the
												number of input lines
												appropriately */
			iCount = 24 - iCount;
			boolValid = true;
		}

		if (boolValid)
		{
			GetMainInfo()->GetTextInput()->SetInputLines( iCount );
		}
	}
}


void TinTin::DoVersion()
{
	string		strFormat;
	string		strMessage;

	LOADSTRING( IDS_TINTIN_VERSION, strFormat );
	strMessage.Format( strFormat, TINTIN_VERSION );
	Message( strMessage );
}


void TinTin::DoWizList()
{
	string		strMessage;

	LOADSTRING( IDS_TINTIN_WIZLIST, strMessage );
	Message( strMessage );
}


void TinTin::DoZap()
{
	string		strMessage;

	LOADSTRING( IDS_TINTIN_ZAP, strMessage );
	Message( strMessage );

	GetMainInfo()->ShutdownWorld();
}


/*----------------------------------------------------------------------------
	TinTin::ToggleEcho
				Toggles the 'echo' state.  If 'echo' is true, then
				actions will be echoed to the screen.
----------------------------------------------------------------------------*/

void TinTin::ToggleEcho()
{
	string		strMessage;

	SetEcho( !IsEcho() );

	if (IsEcho())
	{
		LOADSTRING( IDS_TINTIN_ECHO_ON, strMessage );
	}
	else 
	{
		LOADSTRING( IDS_TINTIN_ECHO_OFF, strMessage );
	}

	Message( strMessage );
}


/*----------------------------------------------------------------------------
	TinTin::ToggleIgnore
				Toggles the 'ignore' state.  If 'ignore' is true, then
				actions will not occur.
----------------------------------------------------------------------------*/

void TinTin::ToggleIgnore()
{
	string		strMessage;

	SetIgnore( !IsIgnore() );

	if (IsIgnore())
	{
		LOADSTRING( IDS_TINTIN_IGNORE_ON, strMessage );
	}
	else 
	{
		LOADSTRING( IDS_TINTIN_IGNORE_OFF, strMessage );
	}

	Message( strMessage );
}


/*----------------------------------------------------------------------------
	TinTin::ToggleSpeedwalk
				Toggles the 'speedwalk' state.
----------------------------------------------------------------------------*/

void TinTin::ToggleSpeedwalk()
{
	string		strMessage;

	SetSpeedwalk( !IsSpeedwalk() );

	if (IsSpeedwalk())
	{
		LOADSTRING( IDS_TINTIN_SPEEDWALK_ON, strMessage );
	}
	else 
	{
		LOADSTRING( IDS_TINTIN_SPEEDWALK_OFF, strMessage );
	}

	Message( strMessage );
}


/*----------------------------------------------------------------------------
	TinTin::ToggleSub
				Toggles whether substitutions occur.
----------------------------------------------------------------------------*/

void TinTin::ToggleSub()
{
	string		strMessage;

	SetUsingSubs( !IsUsingSubs() );
	if (IsUsingSubs())
	{
		LOADSTRING( IDS_TINTIN_SUBS_ON, strMessage );
	}
	else 
	{
		LOADSTRING( IDS_TINTIN_SUBS_OFF, strMessage );
	}

	Message( strMessage );
}


/*----------------------------------------------------------------------------
	TinTin::ToggleVerbatim
				Toggles the verbatim state.  If 'verbatim' is true, then
				all text is sent 'as is' to the world.

				strArg may be 'on' or 'off' to set the mode explicitly.
----------------------------------------------------------------------------*/

void TinTin::ToggleVerbatim( const string& strArg )
{
	string		strMode( strArg );
	bool		boolError = false;

	strMode.MakeLower();

	if (strMode.IsEmpty())
	{
		SetVerbatim( !IsVerbatim() );
	}
	else if ("on" == strMode)
	{
		SetVerbatim( true );
	}
	else if ("off" == strMode)
	{
		SetVerbatim( false );
	}
	else
	{
		string		strMessage;

		LOADSTRING( IDS_TINTIN_VERBATIM_PARAM_ERR, strMessage );
		ErrMessage( strMessage );
		boolError = true;
	}

	if (!boolError)
	{
		string		strMessage;

		if (IsVerbatim())
		{
			LOADSTRING( IDS_TINTIN_VERBATIM_ON, strMessage );
		}
		else 
		{
			LOADSTRING( IDS_TINTIN_VERBATIM_OFF, strMessage );
		}

		Message( strMessage );
	}
}



#if 0

/* Autoconf patching by David Hedbor, neotron@lysator.liu.se */
/*********************************************************************/
/* file: misc.c - misc commands                                      */
/*                             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
#include <ctype.h>
#include "tintin.h"

#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif

/* externs */
extern struct session *newactive_session();
extern struct listnode *common_aliases, *common_actions, *common_subs, *common_myvars;
extern struct listnode *common_highs, *common_antisubs, *common_pathdirs;
extern char *get_arg_in_braces();
extern void term_echo();
extern int redraw, is_split;
extern struct session *sessionlist;
extern struct completenode *complete_head;
extern char tintin_char;
extern int echo;
extern int speedwalk;
extern int presub;
extern int togglesubs;
extern char vars[10][BUFFER_SIZE]; /* the %0, %1, %2,....%9 variables */
extern int mesvar[7];
extern int verbatim;

/**********************/
/* the #presub command*/
/**********************/
void presub_command(ses)
     struct session *ses;
{
  presub=!presub;
  if(presub)
    tintin_puts("#ACTIONS ARE NOW PROCESSED ON SUBSTITUTED BUFFER.",ses);
  else
    tintin_puts("#ACTIONS ARE NO LONGER DONE ON SUBSTITUTED BUFFER.",ses);
}

/**************************/
/* the #togglesubs command*/
/**************************/
void togglesubs_command(ses)
     struct session *ses;
{
  togglesubs=!togglesubs;
  if(togglesubs)
    tintin_puts("#SUBSTITUTES ARE NOW IGNORED.",ses);
  else 
    tintin_puts("#SUBSTITUTES ARE NO LONGER IGNORED.", ses);
}

/**********************/
/* the #snoop command */
/**********************/
void snoop_command(arg, ses)
     char *arg;
     struct session *ses;
{
  char buf[100];
  struct session *sesptr=ses;

  if(ses) {
    get_arg_in_braces(arg, arg,1);
    if(*arg) {
      for(sesptr=sessionlist; sesptr && strcmp(sesptr->name, arg); sesptr=sesptr->next);
      if(!sesptr) {
        tintin_puts("#NO SESSION WITH THAT NAME!", ses);
        return;
      }
    }
    if(sesptr->snoopstatus) {
      sesptr->snoopstatus=FALSE;
      sprintf(buf, "#UNSNOOPING SESSION '%s'", sesptr->name);
      tintin_puts(buf, ses);
    }
    else {
      sesptr->snoopstatus=TRUE;
      sprintf(buf, "#SNOOPING SESSION '%s'", sesptr->name);
      tintin_puts(buf, ses);
    }
  }
  else
    tintin_puts("#NO SESSION ACTIVE => NO SNOOPING", ses);
}


/***********************/
/* the #system command */
/***********************/
void system_command(arg, ses)
     char *arg;
     struct session *ses;
{
  get_arg_in_braces(arg, arg, 1);
  if(*arg) {
    tintin_puts3("^#OK EXECUTING SHELL COMMAND.", ses);
    term_echo();
#if defined(DEBUG)
    system(arg);
#else
    alarm(0);
    system(arg);
#endif
#if defined(DEBUG)
    alarm(0);
#else
    alarm(1);
#endif
    term_noecho();
    tintin_puts3("!#OK COMMAND EXECUTED.", ses);
  }
  else
    tintin_puts2("#EXECUTE WHAT COMMAND?", ses);
  prompt(NULL);

}



/*********************************************************************/
/*   tablist will display the all items in the tab completion file   */
/*********************************************************************/
void tablist(tcomplete)
     struct completenode *tcomplete;
{
   int count, done;
   char tbuf[BUFFER_SIZE];
   struct completenode *tmp;

done=0;
if (tcomplete==NULL)
  {
   tintin_puts2("Sorry.. But you have no words in your tab completion file",NULL);
   return;
  }
count=1;
*tbuf='\0';

/* 
   I'll search through the entire list, printing thre names to a line then
   outputing the line.  Creates a nice 3 column effect.  To increase the # 
   if columns, just increase the mod #.  Also.. decrease the # in the %s's
*/

for(tmp=tcomplete->next;tmp!=NULL;tmp=tmp->next) 
  {
  if ((count % 3))
     {
     if (count == 1)
        sprintf(tbuf,"%25s", tmp->strng); 
     else
        sprintf(tbuf,"%s%25s",tbuf,tmp->strng);
     done=0;
     ++count;
     }
  else
     {
     sprintf(tbuf,"%s%25s",tbuf,tmp->strng);
     tintin_puts2(tbuf, NULL);
     done=1;
     *tbuf='\0';
     ++count;
     }
  }
  if (!done)
     tintin_puts2(tbuf, NULL);
  prompt(NULL);
}

void tab_add(arg)
   char *arg;
{
   struct completenode *tmp, *tmpold, *tcomplete;
   struct completenode *newt;
   char *newcomp, buff[BUFFER_SIZE];

   tcomplete=complete_head;
  
   if ((arg == NULL) || (strlen(arg)<=0)) {
     tintin_puts("Sorry, you must have some word to add.", NULL);
     prompt(NULL);
     return;
   }
   get_arg_in_braces(arg, buff, 1);

   if ((newcomp=(char *)(malloc(strlen(buff)+1)))==NULL) {
       fprintf(stderr, "Could not allocate enough memory for that Completion word.\n");
       exit(1);
   }
   strcpy(newcomp, buff);
   tmp=tcomplete;
   while (tmp->next != NULL) {
      tmpold=tmp;
      tmp=tmp->next;
   } 

   if ((newt=(struct completenode *)(malloc(sizeof(struct completenode))))==NULL) {
       fprintf(stderr, "Could not allocate enough memory for that Completion word.\n");
       exit(1);
   }
       
   newt->strng=newcomp;
   newt->next=NULL;
   tmp->next=newt;
   tmp=newt;
   sprintf(buff,"#New word %s added to tab completion list.", arg);
   tintin_puts(buff, NULL);
   prompt(NULL);
}
   
void tab_delete(arg)
   char *arg;
{
   struct completenode *tmp, *tmpold, *tmpnext, *tcomplete;
   struct completenode *newt;
   char *oldcomp, s_buff[BUFFER_SIZE], c_buff[BUFFER_SIZE];

   tcomplete=complete_head;

   if ((arg == NULL) || (strlen(arg)<=0)) {
     tintin_puts("#Sorry, you must have some word to delete.", NULL);
     prompt(NULL);
     return;
   }
   get_arg_in_braces(arg, s_buff, 1);
   tmp=tcomplete->next;
   tmpold=tcomplete;
   if (tmpold->strng == NULL) {   /* (no list if the second node is null) */
     tintin_puts("#There are no words for you to delete!", NULL);
     prompt(NULL);
     return;
   } 
   strcpy(c_buff, tmp->strng); 
   while ((tmp->next != NULL) && (strcmp(c_buff, s_buff) != 0)) {
      tmpold=tmp;
      tmp=tmp->next;
      strcpy(c_buff, tmp->strng); 
   }
   if (tmp->next != NULL) {
      tmpnext=tmp->next;
      tmpold->next=tmpnext;
      free(tmp);
      tintin_puts("#Tab word deleted.", NULL);
      prompt(NULL);
    } else {
      if (strcmp(c_buff, s_buff) == 0) { /* for the last node to delete */
        tmpold->next=NULL;
        free(tmp);
        tintin_puts("#Tab word deleted.", NULL);
        prompt(NULL);
        return;
      }
      tintin_puts("Word not found in list.", NULL);
      prompt(NULL);
    }
}    
 
#endif	// 0

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -