home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Global Amiga Experience
/
globalamigaexperience.iso
/
text_dtp
/
editor
/
turbotext
/
rexx
/
stripansi.ttx
< prev
next >
Wrap
Text File
|
1995-07-10
|
2KB
|
144 lines
/** $VER: StripANSI.ttx 2.0 (22.2.94)
**
** Remove ANSI codes from the current document
**/
OPTIONS RESULTS
OPTIONS FAILAT 11
SetDisplayLock ON
SetBookmark 0
GetPrefs FreeForm
form = RESULT
GetPrefs FindBackward
dir = RESULT
GetPrefs FindWholeWords
whole = RESULT
SetPrefs FreeForm OFF
SetPrefs FindBackward OFF
SetPrefs FindWholeWords OFF
/* first, convert "Esc[" to CSI */
MoveSOF
FindChange ALL FIND '1b'X||'[' CHANGE '9b'X
MoveSOF
SetPrefs FindString '9b'X
DO FOREVER
Find
IF RC ~= 0 THEN DO
LEAVE
END
i = 1
DO FOREVER
MoveRight
IF RC ~= 0 THEN DO
LEAVE
END
GetChar
IF RESULT >= '@' & RESULT <= '~' THEN DO
i = i + 1
LEAVE
END
IF RESULT < ' ' | RESULT > '?' THEN DO
LEAVE
END
i = i + 1
END
MoveLeft i-1
Delete i
MoveLeft
END
MoveSOF
SetPrefs FindString '1b'X
DO FOREVER
Find
IF RC ~= 0 THEN DO
LEAVE
END
i = 1
DO FOREVER
MoveRight
IF RC ~= 0 THEN DO
LEAVE
END
GetChar
IF RESULT >= '0' & RESULT <= '~' THEN DO
i = i + 1
LEAVE
END
IF RESULT < ' ' | RESULT > '/' THEN DO
LEAVE
END
i = i + 1
END
MoveLeft i-1
Delete i
MoveLeft
END
CALL StripReserved('90'X)
CALL StripReserved('9d'X)
CALL StripReserved('9e'X)
CALL StripReserved('9f'X)
SetPrefs FreeForm form
SetPrefs FindBackward dir
SetPrefs FindWholeWords whole
MoveBookmark 0
ClearBookmark 0
SetDisplayLock OFF
RETURN
StripReserved: PROCEDURE
PARSE ARG single
MoveSOF
SetPrefs FindString single
DO FOREVER
Find
IF RC ~= 0 THEN DO
LEAVE
END
i = 1
DO FOREVER
MoveRight
IF RC ~= 0 THEN DO
LEAVE
END
GetChar
IF RESULT == '9c'X THEN DO
i = i + 1
LEAVE
END
IF (RESULT >= ' ' & RESULT <= '~') | RESULT >= 'a0'X THEN DO
i = i + 1
END; ELSE DO
LEAVE
END
END
MoveLeft i-1
Delete i
MoveLeft
END
RETURN