📄 tintinmisc.cpp
字号:
/*----------------------------------------------------------------------------
_ _ _
/\ | | | (_)
/ \ _ __ __| |_ __ ___ _ __ ___ ___ __| |_ __ _
/ /\ \ | '_ \ / _` | '__/ _ \| '_ ` _ \ / _ \/ _` | |/ _` |
/ ____ \| | | | (_| | | | (_) | | | | | | __/ (_| | | (_| |
/_/ \_\_| |_|\__,_|_| \___/|_| |_| |_|\___|\__,_|_|\__,_|
The contents of this file are subject to the Andromedia Public
License Version 1.0 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.andromedia.com/APL/
Software distributed under the License is distributed on an
"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
The Original Code is Pueblo client code, released November 4, 1998.
The Initial Developer of the Original Code is Andromedia Incorporated.
Portions created by Andromedia are Copyright (C) 1998 Andromedia
Incorporated. All Rights Reserved.
Andromedia Incorporated 415.365.6700
818 Mission Street - 2nd Floor 415.365.6701 fax
San Francisco, CA 94103
Contributor(s):
--------------------------------------------------------------------------
Chaco team: Dan Greening, Glenn Crocker, Jim Doubek,
Coyote Lussier, Pritham Shetty.
Wrote and designed original codebase.
------------------------------------------------------------------------------
TinTin class miscellaneous methods. Originally modified from TinTin++,
(T)he K(I)cki(N) (T)ickin D(I)kumud Clie(N)t, originally coded by
Peter Unold 1992.
----------------------------------------------------------------------------*/
// $Header: /home/cvs/chaco/modules/client/msw/ChText/TinTinMisc.cpp,v 2.6 1996/02/17 02:17:52 coyote Exp $
#include <ChTypes.h>
#include <ChDlg.h>
#include "TinTin.h"
#include "TinTinInfo.h"
#include "TinTinWizList.h"
/*----------------------------------------------------------------------------
TinTin class protected methods
----------------------------------------------------------------------------*/
void TinTin::DoBell()
{
MessageBeep( MB_OK );
}
/*----------------------------------------------------------------------------
TinTin::DoChar
Changes the TinTin escape character (start of commands.)
----------------------------------------------------------------------------*/
void TinTin::DoChar( const string& strArg )
{
string strWorking( strArg );
GetArgInBraces( strWorking, strWorking, true );
if (ispunct( strWorking[0] ))
{
string strTemp;
SetTinTinChar( strWorking[0] );
strTemp.Format( "# OK. The TinTin command character is now {%c}",
GetTinTinChar() );
Display( strTemp );
}
else
{
Display( "# Error - Please specify a punctuation character, "
"like # or /" );
}
}
void TinTin::DoCR()
{
SendToWorld( "\n" );
}
void TinTin::DoHelp( const string& strArgs )
{
string strTopic;
DWORD dwKey = 0;
GetArgStopAtSpaces( strArgs, strTopic );
if (strTopic.IsEmpty())
{
strTopic = TINTIN_HELP_PREFIX ",overview";
dwKey = (DWORD)(const char*)strTopic;
}
else
{
TTCommand cmd;
cmd = ParseTinTinCmd( strTopic );
if (ttUnknown == cmd)
{
string strFormat( "# Unknown command! ('%s')" );
string strStatus;
strStatus.Format( strFormat, (const char*)strTopic );
Display( strStatus );
}
else
{
strTopic = m_pstrCommands[(int)cmd];
strTopic = TINTIN_HELP_PREFIX ",#" + strTopic;
dwKey = (DWORD)(const char*)strTopic;
}
}
if (dwKey)
{
AfxGetApp()->WinHelp( dwKey, HELP_KEY );
}
}
void TinTin::DoInfo()
{
TinTinInfo info;
info.SetCounts( m_pListActions->GetCount(),
m_pListAliases->GetCount(),
m_pListSubs->GetCount(),
m_pListAntiSubs->GetCount(),
m_pListVars->GetCount(),
m_pListHighlights->GetCount() );
info.SetFlags( IsUsingActions(), IsUsingStartQuotes(), IsSpeedwalk(),
IsUsingSubs(), IsUsingPresubs() );
info.DoModal();
}
/*----------------------------------------------------------------------------
TinTin::DoKillAll
Empties the lists.
----------------------------------------------------------------------------*/
void TinTin::DoKillAll( bool boolQuiet )
{
m_pListAliases->Empty();
m_pListActions->Empty();
m_pListVars->Empty();
m_pListHighlights->Empty();
m_pListSubs->Empty();
m_pListAntiSubs->Empty();
m_pListPath->Empty();
m_pListPathDirs->Empty();
if (!boolQuiet)
{
Display( "# Lists cleared." );
}
}
void TinTin::DoWizList()
{
TinTinWizList wizList;
wizList.DoModal();
}
/*----------------------------------------------------------------------------
TinTin::ToggleQuotes
Toggles the 'quotes' state. If 'quotes' is true, then
tintin treats double-quotes at the beginning of
a line as the start of a quoted string. Otherwise, these
quotes are sent to the world as-is.
----------------------------------------------------------------------------*/
void TinTin::ToggleSpeedwalk()
{
m_boolSpeedwalk = !IsSpeedwalk();
if (IsSpeedwalk())
{
Display( "# Speedwalk is now on." );
}
else
{
Display( "# Speedwalk is now off." );
}
}
/*----------------------------------------------------------------------------
TinTin::ToggleStartQuotes
Toggles the 'quotes' state. If 'quotes' is true, then
tintin treats double-quotes at the beginning of
a line as the start of a quoted string. Otherwise, these
quotes are sent to the world as-is.
----------------------------------------------------------------------------*/
void TinTin::ToggleStartQuotes()
{
m_boolStartQuotes = !IsUsingStartQuotes();
if (IsUsingStartQuotes())
{
Display( "# Initial double-quotes are now processed." );
}
else
{
Display( "# Initial double-quotes are sent to the world." );
}
}
/*----------------------------------------------------------------------------
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())
{
m_boolVerbatim = !IsVerbatim();
}
else if ("on" == strMode)
{
m_boolVerbatim = true;
}
else if ("off" == strMode)
{
m_boolVerbatim = false;
}
else
{
Display( "# Error - Parameter to #verbatim must be 'on' or 'off'." );
boolError = true;
}
if (!boolError)
{
if (IsVerbatim())
{
Display( "# All text is now sent 'as is'." );
}
else
{
Display( "# Text is no longer sent 'as is'." );
}
}
}
#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 version command */
/****************************/
void version_command()
{
char temp[80];
sprintf(temp,"#You are using TINTIN++ %s\n\r", VERSION_NUM);
tintin_puts2(temp, NULL);
prompt(NULL);
}
/****************************/
/* the verbatim command, */
/* used as a toggle */
/****************************/
void verbatim_command()
{
verbatim=!verbatim;
if (verbatim)
tintin_puts2("#All text is now sent 'as is'.", (struct sesssion *)NULL);
else
tintin_puts2("#Text is no longer sent 'as is'.", (struct session *)NULL);
prompt(NULL);
}
void redraw_command()
{
redraw=!redraw;
if (redraw)
tintin_puts2("#Ok. I now redraw input line when text arrives.", (struct session *)NULL);
else
tintin_puts2("#Ok. I no longer redraw the input line.", (struct session *)NULL);
prompt(NULL);
}
/*********************/
/* the #boss command */
/*********************/
void boss_command(ses)
struct session *ses;
{
char temp[80];
int i;
for(i=0; i<50; i++) {
sprintf(temp, "in-order traverse of tree starting from node %d resulted in %d red nodes\n", i, 50-i);
tintin_puts2(temp, (struct session *)NULL);
}
getchar(); /* stop screen from scrolling stuff */
}
/*********************/
/* the #echo command */
/*********************/
void echo_command(ses)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -