COMMENT @----------------------------------------------------------------------

	Copyright (c) GeoWorks 1991 -- All Rights Reserved

PROJECT:	PC GEOS
MODULE:		Include/Objects
FILE:		vTextC.def

REVISION HISTORY:
	Name	Date		Description
	----	----		-----------
	Tony	9/91		Initial version
	JM	3/18/94		Added messages
				   MSG_VIS_TEXT_DELETE_ALL_HYPERLINKS
				   MSG_VIS_TEXT_UNSET_ALL_CONTEXTS

DESCRIPTION:
	Object definitions for VisTextClass.   

	$Id: vTextC.def,v 1.1 97/04/04 14:17:47 newdeal Exp $

------------------------------------------------------------------------------@

SetDef __VTEXTC

StartLibrary	text

UseLib ui.def

include Objects/Text/tCommon.def	; must be first so DefLib/UseLib with
					;  which we were included takes effect
include Objects/visC.def
UseLib 	spool.def
include hugearr.def
include dbase.def


VisTextClass	class VisClass

TextFocusFlags	record		;Record passed in BP
	TFF_EDITABLE_TEXT_OBJECT_HAS_FOCUS:1
	; Set if an editable text object has the focus
	TFF_OBJECT_RUN_BY_UI_THREAD:1
	; Set if the object is run by the UI thread
	:14
TextFocusFlags	end
SEARCH_REPLACE_TEXT_MAXIMUM	equ	65
					;64 chars + 1 null

SearchOptions	record
	:1

	SO_START_FROM_TOP:1
	; Do the search from the top of the document.

	SO_NO_WILDCARDS:1
	; Set if you want to treat wildcard chars as literal chars

	SO_IGNORE_SOFT_HYPHENS:1
	; Set if you want to treat soft hyphens in the "searched-in" text
	; as if they do not exist. If the string we are trying to match 
	; contains soft hyphens, do not set this flag or the strings will
	; never match.

	SO_BACKWARD_SEARCH:1,
	; Set if the user wants to search backward

	SO_IGNORE_CASE:1,
	; Set if you want to ignore case when searching for strings

	SO_PARTIAL_WORD:1,
	; Set if you want to match partial words when searching for strings

	SO_PRESERVE_CASE_OF_DOCUMENT_STRING:1
	; If set, will preserve the case of the occurrence of the search
	; string when replacing (will modify the replace string before
	; replacing it).

SearchOptions	end


	;
	; This type is to tell what type of search should be performed.
	;
SearchNoteOptionType	etype		byte, 0, 1
	SNOT_INCLUDE_NOTE		enum	SearchNoteOptionType
	SNOT_EXCLUDE_NOTE		enum	SearchNoteOptionType
	SNOT_NOTE_ONLY			enum	SearchNoteOptionType

WildCard	etype	byte
	WC_MATCH_SINGLE_CHAR		enum	WildCard, 0x10
	WC_MATCH_MULTIPLE_CHARS		enum	WildCard, 0x11
	WC_MATCH_WHITESPACE_CHAR	enum	WildCard, 0x12

global	TextSearchInString:far
;
;	Finds an occurrence of a string (str2) in another string (str1).
;	
; 	Pass: ES:BP - ptr to first char in string we are searching in (str1)
;	      ES:DI - ptr to character to start search at in string (str1)
;	      ES:BX - ptr to last char to include in search
;		       (will not match any word that begins after this
;			offset, but will match words that start before this
;			char and extend beyond it)
;
;	      DX - # chars of str1 pointed to by ES:DI
;		   (if DX=0, str1 is assumed to be null terminated, and
;			DX is calculated to be # non-null chars in the string)
;	      DS:SI - ptr to str2 (string to match)
;		      May contain WildCard chars
;	      CX - # chars in str2 (or 0 if null-terminated)
;	      AL - SearchOptions
;
;Example:
;	Want to search for the string "foo" in "I want some food", starting
;	with the "w" in "want":
;
;	ES:DI	     ES:BX
;	  V	       V
;	I want some food
;	^
;     ES:BP
;	
;	Returns: carry set if string not found
;		 ES:DI - ptr to last char checked
;
;		 - else -
;		 
;		 ES:DI - ptr to start of string found
;		 CX - # chars matched
;
;	Destroyed: nothing
;

global	TextSearchInHugeArray:far
;
;	Finds an occurrence of a string (str2) in another string (str1).
;	
; 	Pass: DS:SI - ptr to str2 (string to match)
;		      May contain WildCard chars
;	      CX - # chars in str2 (or 0 if null-terminated)
;	      SS:BP - pointer to TextSearchInHugeArrayFrame
;
;	Returns: carry set if string not found
;		 DX:AX - offset to match found
;		 BP:CX - # chars in match (useful if using wildcards)
;
;	Destroyed: nothing (TextSearchInHugeArrayFrame may be altered)
;

TextSearchInHugeArrayFrame	struct
	TSIHAF_str1Size		dword	(?)
		;Total length of string to search in (str1).

	TSIHAF_curOffset	dword	(?)
		;Offset (from start of str1) to first char to check

	TSIHAF_endOffset 	dword	(?)
		;Offset (from start of str1) to last char to check.
		;
		;Will only match words that start <= TSIHAF_endOffset.
		;
		;To check to start of string (backward searches only) pass 0:0
		;To check to end of string (forward searches only) pass 
		; 					TSIHAF_str1Size-1

	TSIHAF_searchFlags	SearchOptions

	TSIHAF_hugeArrayVMFile	hptr
	TSIHAF_hugeArrayVMBlock	hptr
		;File/Block handles for huge array we will be extracting text
		; from.
	even
TextSearchInHugeArrayFrame	ends

;--

VisTextRangeContext	record
    VTRC_PARAGRAPH_CHANGE:1	;Change done on paragraph level
    VTRC_CHAR_ATTR_CHANGE:1	;Used for a charAttr change (include last CR,
				;don't include next CR)
    VTRC_PARA_ATTR_BORDER_CHANGE:1	;Used for a paraAttr change
					;including a border
    :13
VisTextRangeContext	end


MSG_VIS_TEXT_GET_RANGE		message
;
;	Given a VisTextRange, return the text positions.
;
;	Pass:	cx - VisTextRangeContext
;		dx:bp - VisTextRange
;	Return:	range filled in
;	Compat:	Can be used with all text objects.
;

;-------
;
; Example of calling charAttr/paraAttr routines that require parameters
; on the stack:
;
; Calling MSG_VIS_TEXT_SET_POINT_SIZE
;
; Paramters to pass on stack:
;
;VisTextSetPointSizeParams	struct
;    VTSPSP_range	VisTextRange
;    VTSPSP_alignment	byte
;    VTSPSP_pointSize	WBFixed
;VisTextSetPointSizeParams	ends
;
; message 1:
;	sub	sp, size VisTextSetPointSizeParams
;	mov	bp, sp
;	mov	ss:[bp].VTSPSP_range.VTR_start.low, ?
;	mov	ss:[bp].VTSPSP_range.VTR_start.high, ?
;	mov	ss:[bp].VTSPSP_range.VTR_end.low, ?
;	mov	ss:[bp].VTSPSP_range.VTR_end.high, ?
;	mov	ss:[bp].VTSPSP_pointSize.WBF_int, ?
;	mov	ss:[bp].VTSPSP_pointSize.WBF_frac, ?
;	mov	ax, MSG_VIS_TEXT_SET_POINT_SIZE
;	mov	dx, size VisTextSetPointSizeParams
;	mov	di, mask MF_STACK or mask MF_CALL
;	call	ObjMessage
;	add	sp, size VisTextSetPointSizeParams
;
; message 2:
;	push	<point size int>
;	push	<point size frac>
;	push	<range end.high>
;	push	<range end.low>
;	push	<range start.high>
;	push	<range start.low>
;	mov	bp, sp
;	mov	ax, MSG_VIS_TEXT_SET_POINT_SIZE
;	mov	dx, size VisTextSetPointSizeParams
;	mov	di, mask MF_STACK or mask MF_CALL
;	call	ObjMessage
;	add	sp, size VisTextSetPointSizeParams
;

;------------------------------------------------------------------------------
;	Structures for generic runs and elements
;------------------------------------------------------------------------------
;
;	A generic array of runs in the small format.  
;
TextRunArrayHeader	struct
    TRAH_meta		ChunkArrayHeader
    TRAH_elementVMBlock	word		; Element block or 0
    TRAH_elementArray	lptr		; Chunk handle of ElementArray
TextRunArrayHeader	ends

;
;	A generic array of runs in the large format
;
TextLargeRunArrayHeader	struct
    TLRAH_meta		HugeArrayDirectory
    TLRAH_elementVMBlock word		; Element block or 0
TextLargeRunArrayHeader	ends

;
;	An element in a array of runs
;
TextRunArrayElement	struct
    TRAE_position	WordAndAHalf <>	; Position for start of run
    TRAE_token		word		; Token for run
TextRunArrayElement	ends

;
;	A generic array of elements
;
TextArrayType	etype	byte
TAT_CHAR_ATTRS		enum	TextArrayType
TAT_PARA_ATTRS		enum	TextArrayType
TAT_GRAPHICS		enum	TextArrayType
TAT_TYPES		enum	TextArrayType

TextElementArrayHeader	struct
    TEAH_meta		ElementArrayHeader
    TEAH_arrayType	TextArrayType
    TEAH_unused		byte
TextElementArrayHeader	ends

;------------------------------------------------------------------------------
;		Style sheet structures
;------------------------------------------------------------------------------

;
;	Private data
;

TextStyleFlags	record
    TSF_APPLY_TO_SELECTION_ONLY:1
    TSF_POINT_SIZE_RELATIVE:1
    TSF_MARGINS_RELATIVE:1
    TSF_LEADING_RELATIVE:1
    :12
TextStyleFlags	end

TextStylePrivateData	struct
    TSPD_flags		TextStyleFlags
    TSPD_unused		byte 2 dup (0)
TextStylePrivateData	ends

TextStyleElementHeader	struct
    TSEH_meta		NameArrayElement
    TSEH_baseStyle	word
    TSEH_flags		StyleElementFlags
    TSEH_reserved	byte 6 dup (?)
    TSEH_privateData	TextStylePrivateData
    TSEH_charAttrToken	word
    TSEH_paraAttrToken	word
    TSEH_name		label	char
TextStyleElementHeader	ends

	CheckHack <(offset TSEH_charAttrToken) eq (size StyleElementHeader)>

;------------------------------------------------------------------------------
;		Global routines for attributes
;------------------------------------------------------------------------------

global TextMapDefaultCharAttr:far
global TextFindDefaultCharAttr:far
global TextMapDefaultParaAttr:far
global TextFindDefaultParaAttr:far
global TextGetSystemCharAttrRun:far


;------------------------------------------------------------------------------
;		Routines for informing the text library what libs to use
;------------------------------------------------------------------------------

;
;	By default, the text library does not load any spell or hyphenation
;	libraries. Apps that will be using hyphenation or spell checking need
;	to load these libraries themselves, and these libraries will, in turn,
;	notify the text library of their existence
;

global TextSetSpellLibrary:far
;
;	Pass: bx - library handle (or 0 if library is exiting)
;	Return: nothing
;	Destroyed: nothing
;

global TEXTSETHYPHENATIONCALL:far
;
;Pass (on-stack):
;	(void *) to pass to ProcCallFixedOrMovable to call to get
;	      	 hyphenation position
;
;	Routine is passed args on stack (pushed in this order):
;			fptr	ptrToWordToHyphenate
;			word	lengthOfShortestWordToHyphenate
;
;	Routine returns:
;		AX - 0 if error or no hyphenation
;				- else -
;		AX - handle of block containing HyphenationPoints structure

HyphenationPoints	struct
	HP_wordLen	word
	HP_array	label	byte
	; null terminated array of hyphenation points	
HyphenationPoints	ends

;------------------------------------------------------------------------------
;		Messages to set character attributes (charAttrs)
;------------------------------------------------------------------------------

;
; Common to all of these messages:
;	Pass:	dx - size {structure} (if called remotely)
;		ss:bp - {structure}
;	Return:	ax, cx, dx - destroyed
;		bp - unchanged
;	Compat:	Can be used with all text objects.
;
; Each of these messages takes a structure that indicates the range of text
; to change and the values to change it to.
;

;---

MSG_VIS_TEXT_SET_CHAR_ATTR_BY_DEFAULT		message
;
;	Set: the entire charAttr structure via a default charAttr
;
VisTextSetCharAttrByDefaultParams	struct
    VTSCABDP_range	VisTextRange
    VTSCABDP_charAttr	VisTextDefaultCharAttr
VisTextSetCharAttrByDefaultParams	ends

;---

MSG_VIS_TEXT_SET_CHAR_ATTR		message
;
;	Set: the entire charAttr structure via a VisTextCharAttr structure
;
VisTextSetCharAttrParams	struct
    VTSCAP_range		VisTextRange
    VTSCAP_charAttr		fptr.VisTextCharAttr
VisTextSetCharAttrParams	ends

;---

MSG_VIS_TEXT_SET_CHAR_ATTR_BY_TOKEN	message
;
;	Set: the entire charAttr structure via a VisTextCharAttr structure
;
;	Passing CA_NULL_ELEMENT as the token causes "revert to base style"
;
VisTextSetCharAttrByTokenParams	struct
    VTSCABTP_range		VisTextRange
    VTSCABTP_charAttr		word
VisTextSetCharAttrByTokenParams	ends

;---

MSG_VIS_TEXT_SET_FONT_ID		message	MetaTextMessages
;
;	Set: the font ID
;
VisTextSetFontIDParams	struct
    VTSFIDP_range	VisTextRange
    VTSFIDP_fontID	FontID		
VisTextSetFontIDParams	ends

;---

MSG_VIS_TEXT_SET_FONT_WEIGHT		message	MetaTextMessages
;
;	Set: the font weight
;
VisTextSetFontWeightParams	struct
    VTSFWP_range	VisTextRange
    VTSFWP_fontWeight	byte		
    even
VisTextSetFontWeightParams	ends

;---

MSG_VIS_TEXT_SET_FONT_WIDTH		message	MetaTextMessages
;
;	Set: the font width
;
VisTextSetFontWidthParams	struct
    VTSFWIP_range	VisTextRange
    VTSFWIP_fontWidth	byte
    even
VisTextSetFontWidthParams	ends

;---

MSG_VIS_TEXT_SET_POINT_SIZE		message	MetaTextMessages
;
;	Set: the point size
;
VisTextSetPointSizeParams	struct
    VTSPSP_range	VisTextRange
    VTSPSP_pointSize	WWFixed			;only WBFixed actually stored
VisTextSetPointSizeParams	ends

;---

MSG_VIS_TEXT_SET_SMALLER_POINT_SIZE	message	MetaTextMessages
;
;	Set: the point size to a smaller point size
;
VisTextSetSmallerPointSizeParams	struct
    VTSSPSP_range	VisTextRange
    VTSSPSP_minimumSize	word
VisTextSetSmallerPointSizeParams	ends

;---

MSG_VIS_TEXT_SET_LARGER_POINT_SIZE	message	MetaTextMessages
;
;	Set: the point size to a larger point size
;
VisTextSetLargerPointSizeParams	struct
    VTSLPSP_range	VisTextRange
    VTSLPSP_maximumSize	word
VisTextSetLargerPointSizeParams	ends

;---

MSG_VIS_TEXT_SET_TEXT_STYLE		message	MetaTextMessages
;
;	Set: the text style and extended style bits
;
; If both the set bit and the clear bit is set then the bit is toggled
;
VisTextSetTextStyleParams	struct
    VTSTSP_range		VisTextRange
    VTSTSP_styleBitsToSet	word	;TextStyle (can ignore high byte)
    VTSTSP_styleBitsToClear	word	;TextStyle (can ignore high byte)
    VTSTSP_extendedBitsToSet	word	;VisTextExtendedStyles
    VTSTSP_extendedBitsToClear	word	;VisTextExtendedStyles
VisTextSetTextStyleParams	ends

;---

MSG_VIS_TEXT_SET_COLOR		message	MetaTextMessages
;
;	Set: the text color
;
VisTextSetColorParams	struct
    VTSCP_range		VisTextRange
    VTSCP_color		ColorQuad
VisTextSetColorParams	ends

;---

MSG_VIS_TEXT_SET_GRAY_SCREEN		message	MetaTextMessages
;
;	Set: the gray screen
;
VisTextSetGrayScreenParams	struct
    VTSGSP_range	VisTextRange
    VTSGSP_grayScreen	SystemDrawMask
    even
VisTextSetGrayScreenParams	ends

;---

MSG_VIS_TEXT_SET_PATTERN		message	MetaTextMessages
;
;	Set: the hatch
;
VisTextSetPatternParams	struct
    VTSHAP_range	VisTextRange
    VTSHAP_hatch	GraphicPattern
VisTextSetPatternParams	ends

;---

MSG_VIS_TEXT_SET_CHAR_BG_COLOR		message	MetaTextMessages
;
;	Set: the character background color
;
;	Pass: VisTextSetColorParams
;

;---

MSG_VIS_TEXT_SET_CHAR_BG_GRAY_SCREEN		message	MetaTextMessages
;
;	Set: the character background gray screen
;
;	Pass: VisTextSetGrayScreenParams
;

;---

MSG_VIS_TEXT_SET_CHAR_BG_PATTERN			message	MetaTextMessages
;
;	Set: the character background hatch
;
;	Pass: VisTextSetPatternParams
;

;---

MSG_VIS_TEXT_SET_TRACK_KERNING		message MetaTextMessages
;
;	Set: the track kerning value
;
VisTextSetTrackKerningParams	struct
    VTSTKP_range	VisTextRange
    VTSTKP_trackKerning	BBFixed
    even
VisTextSetTrackKerningParams	ends

;------------------------------------------------------------------------------
;		Other character attributes (charAttrs) messages
;------------------------------------------------------------------------------

VisTextCharAttrFlags	record
    VTCAF_MULTIPLE_FONT_IDS:1		;Set if more than one font
    VTCAF_MULTIPLE_POINT_SIZES:1	;Set if more than one point size
    VTCAF_MULTIPLE_COLORS:1		;Set if more than one color
    VTCAF_MULTIPLE_GRAY_SCREENS:1	;Set if more than one gray screen
    VTCAF_MULTIPLE_PATTERNS:1		;Set if more than one hatch
    VTCAF_MULTIPLE_TRACK_KERNINGS:1	;Set if more than one track kerning
    VTCAF_MULTIPLE_FONT_WEIGHTS:1	;Set if more than one font weight
    VTCAF_MULTIPLE_FONT_WIDTHS:1	;Set if more than one font width
    VTCAF_MULTIPLE_BG_COLORS:1		;Set if more than one bg color
    VTCAF_MULTIPLE_BG_GRAY_SCREENS:1	;Set if more than one bg gray screen
    VTCAF_MULTIPLE_BG_PATTERNS:1	;Set if more than one bg hatch
    VTCAF_MULTIPLE_STYLES:1		;Set if more than one (ssheet) style
    :4
VisTextCharAttrFlags	end

VisTextCharAttrDiffs	struct
    VTCAD_diffs		VisTextCharAttrFlags
    VTCAD_extendedStyles VisTextExtendedStyles
    VTCAD_textStyles	TextStyle
    even
VisTextCharAttrDiffs	ends

MSG_VIS_TEXT_GET_CHAR_ATTR		message
;
;	Return the charAttr structure for the specified range.
;
;	Pass:	dx - size VisTextGetAttrParams (if called remotely)
;		ss:bp - VisTextGetAttrParams structure
;	Return:	ax - charAttr token (0 if multiple)
;		buffer - filled
;		dx - destroyed
;		bp - unchanged
;	Compat:	Can be used with all text objects.
;

VisTextGetAttrFlags	record
    VTGAF_MERGE_WITH_PASSED:1		;If set then merge the attributes for
					;this object with the passed attributes
    :15
VisTextGetAttrFlags	end

VisTextGetAttrParams	struct
    VTGAP_range		VisTextRange
    VTGAP_attr		fptr	;attribute structure (e.g. VisTextCharAttr)
    VTGAP_return	fptr	;diff structure (e.g. VisTextCharAttrDiffs)
    VTGAP_flags		VisTextGetAttrFlags
VisTextGetAttrParams	ends

;---

MSG_VIS_TEXT_ADD_CHAR_ATTR		message
;
;	Add a given charAttr to the charAttr array and initialize its reference
;	count to one.
;
;	Pass:	dx - size VisTextCharAttr (if called remotely)
;		ss:bp - VisTextCharAttr
;	Return:	ax - charAttr token
;		cx, dx - destroyed
;		bp - unchanged
;	Compat:	This method cannot be used on a text object that does not have
;		multiple charAttrs

MSG_VIS_TEXT_REMOVE_CHAR_ATTR		message
;
;	Remove a given charAttr from the charAttr array.
;
;	Pass:	cx - token of charAttr to remove
;	Return:	ax, cx, dx, bp - destroyed
;	Compat:	This method cannot be used on a text object that does not have
;		multiple charAttrs
;

;------------------------------------------------------------------------------
;		Messages to set paragraph attributes (paraAttrs)
;------------------------------------------------------------------------------
;
; Common to all of these messages:
;	Pass:	dx - size {structure} (if called remotely)
;		ss:bp - {structure}
;	Return:	ax, cx, dx - destroyed
;		bp - unchanged
;	Compat:	Can be used with all text objects.
;
; Each of these messages takes a structure that indicates the range of text
; to change and the values to change it to.
;

;---

MSG_VIS_TEXT_SET_PARA_ATTR_BY_DEFAULT		message
;
;	Set: the entire paraAttr structure via a default paraAttr
;
VisTextSetParaAttrByDefaultParams	struct
    VTSPABDP_range	VisTextRange
    VTSPABDP_paraAttr	VisTextDefaultParaAttr
VisTextSetParaAttrByDefaultParams	ends

;---

MSG_VIS_TEXT_SET_PARA_ATTR		message
;
;	Set: the entire paraAttr structure via a VisTextParaAttr structure
;
VisTextSetParaAttrParams	struct
    VTSPAP_range		VisTextRange
    VTSPAP_paraAttr		fptr.VisTextParaAttr
VisTextSetParaAttrParams	ends

;---

MSG_VIS_TEXT_SET_PARA_ATTR_BY_TOKEN	message
;
;	Set: the entire paraAttr structure via a VisTextCharAttr structure
;
VisTextSetParaAttrByTokenParams	struct
    VTSPABTP_range		VisTextRange
    VTSPABTP_paraAttr		word
VisTextSetParaAttrByTokenParams	ends

;---

MSG_VIS_TEXT_SET_BORDER_BITS		message
;
;	Set: the border bits
;
VisTextSetBorderBitsParams	struct
    VTSBBP_range	VisTextRange
    VTSBBP_bitsToSet	VisTextParaBorderFlags
    VTSBBP_bitsToClear	VisTextParaBorderFlags
VisTextSetBorderBitsParams	ends

;---

MSG_VIS_TEXT_SET_BORDER_WIDTH		message
;
;	Set: the border width
;
VisTextSetBorderWidthParams	struct
    VTSBWP_range	VisTextRange
    VTSBWP_width	byte
    even
VisTextSetBorderWidthParams	ends

;---

MSG_VIS_TEXT_SET_BORDER_SPACING		message
;
;	Set: the border spacing
;
;	Pass: VisTextSetBorderWidthParams
;

;---

MSG_VIS_TEXT_SET_BORDER_SHADOW		message
;
;	Set: the border shadow
;
;	Pass: VisTextSetBorderWidthParams
;

;---

MSG_VIS_TEXT_SET_BORDER_COLOR		message	MetaTextMessages
;
;	Set: the border bits
;
;	Pass: VisTextSetColorParams
;

;---

MSG_VIS_TEXT_SET_BORDER_GRAY_SCREEN	message	MetaTextMessages
;
;	Set: the border gray screen
;
;	Pass: VisTextSetGrayScreenParams
;

;---

MSG_VIS_TEXT_SET_BORDER_PATTERN			message	MetaTextMessages
;
;	Set: the border hatch
;
;	Pass: VisTextSetPatternParams
;

;---

MSG_VIS_TEXT_SET_PARA_ATTRIBUTES		message	MetaTextMessages
;
;	Set: the paragraph attribtues (justification, ...)
;
VisTextSetParaAttrAttributesParams	struct
    VTSPAAP_range	VisTextRange
    VTSPAAP_bitsToSet	VisTextParaAttrAttributes
    VTSPAAP_bitsToClear	VisTextParaAttrAttributes
VisTextSetParaAttrAttributesParams	ends

;---

MSG_VIS_TEXT_SET_LINE_SPACING		message
;
;	Set: the line spacing
;
VisTextSetLineSpacingParams	struct
    VTSLSP_range	VisTextRange
    VTSLSP_lineSpacing	BBFixed
VisTextSetLineSpacingParams	ends

;---

MSG_VIS_TEXT_SET_DEFAULT_TABS		message
;
;	Set: the default tabs
;
VisTextSetDefaultTabsParams	struct
    VTSDTP_range	VisTextRange
    VTSDTP_defaultTabs	word		;points * 8
VisTextSetDefaultTabsParams	ends

;---

MSG_VIS_TEXT_SET_LEFT_MARGIN		message
;
;	Set: the left margin
;
VisTextSetMarginParams	struct
    VTSMP_range		VisTextRange
    VTSMP_position	word		;points * 8
VisTextSetMarginParams	ends

;---

MSG_VIS_TEXT_SET_RIGHT_MARGIN		message
;
;	Set: the right margin
;
;	Pass: VisTextSetMarginParams
;

;---

MSG_VIS_TEXT_SET_PARA_MARGIN		message
;
;	Set: the paragraph margin
;
;	Pass: VisTextSetMarginParams
;

;---

MSG_VIS_TEXT_SET_LEFT_AND_PARA_MARGIN		message
;
;	Set: the left margin and the paragraph margin
;
;	Pass: VisTextSetMarginParams
;

;---

MSG_VIS_TEXT_SET_SPACE_ON_TOP		message
;
;	Set: the space on top
;
VisTextSetSpaceOnTBParams	struct
    VTSSOTBP_range	VisTextRange
    VTSSOTBP_spacing	BBFixed
VisTextSetSpaceOnTBParams	ends

;---

MSG_VIS_TEXT_SET_SPACE_ON_BOTTOM	message
;
;	Set: the space on bottom
;
;	Pass: VisTextSetSpaceOnTBParams
;

;---

MSG_VIS_TEXT_SET_LEADING		message
;
;	Set: the leading
;
VisTextSetLeadingParams	struct
    VTSLP_range		VisTextRange
    VTSLP_leading	word		;points * 8
VisTextSetLeadingParams	ends

;---

MSG_VIS_TEXT_SET_PARA_BG_COLOR		message
;
;	Set: the background color
;
;	Pass: VisTextSetColorParams
;

;---

MSG_VIS_TEXT_SET_PARA_BG_GRAY_SCREEN		message
;
;	Set: the border gray screen
;
;	Pass: VisTextSetGrayScreenParams
;

;---

MSG_VIS_TEXT_SET_PARA_BG_PATTERN			message
;
;	Set: the paragraph background hatch
;
;	Pass: VisTextSetPatternParams
;

;---

MSG_VIS_TEXT_SET_TAB			message
;
;	Set: a tab
;
VisTextSetTabParams	struct
    VTSTP_range		VisTextRange
    VTSTP_tab		Tab
VisTextSetTabParams	ends

;---

MSG_VIS_TEXT_CLEAR_TAB			message
;
;	Set: Clear a tab
;
VisTextClearTabParams	struct
    VTCTP_range		VisTextRange
    VTCTP_position	word		;points * 8
VisTextClearTabParams	ends

;---

MSG_VIS_TEXT_MOVE_TAB			message
;
;	Set: Move a tab
;
VisTextMoveTabParams	struct
    VTMTP_range		VisTextRange
    VTMTP_destPosition	word		;points * 8
    VTMTP_sourcePosition word		;points * 8
VisTextMoveTabParams	ends

MSG_VIS_TEXT_CLEAR_ALL_TABS			message
;
;	Set: Clear all tabs
;
VisTextClearAllTabsParams	struct
    VTCATP_range		VisTextRange
VisTextClearAllTabsParams	ends

;---

MSG_VIS_TEXT_SET_PREPEND_CHARS		message
;
;	Set: The characters to prepend at the start of a paragraph
;
VisTextSetPrependCharsParams	struct
    VTSPCP_range	VisTextRange
    VTSPCP_chars	char 4 dup (0)
VisTextSetPrependCharsParams	ends

;---

MSG_VIS_TEXT_SET_HYPHENATION_PARAMS	message
;
;	Set: the hyphenation parameters
;
VisTextSetHyphenationPParams	struct
    VTSHP_range		VisTextRange
    VTSHP_bitsToSet	VisTextHyphenationInfo
    VTSHP_bitsToClear	VisTextHyphenationInfo
VisTextSetHyphenationPParams	ends

;---

MSG_VIS_TEXT_SET_DROP_CAP_PARAMS	message
;
;	Set: the drop cap parameters
;
VisTextSetDropCapPParams	struct
    VTSDCP_range	VisTextRange
    VTSDCP_bitsToSet	word	;VisTextDropCapInfo
    VTSDCP_bitsToClear	word	;VisTextDropCapInfo
VisTextSetDropCapPParams	ends

;---

MSG_VIS_TEXT_SET_KEEP_PARAMS	message
;
;	Set: the keep (lines together) parameters
;
VisTextSetKeepPParams	struct
    VTSKP_range		VisTextRange
    VTSKP_bitsToSet	word	;VisTextKeepInfo
    VTSKP_bitsToClear	word	;VisTextKeepInfo
VisTextSetKeepPParams	ends

;---

MSG_VIS_TEXT_SET_PARAGRAPH_NUMBER	message
;
;	Set: The paragraph number
;
VisTextSetParagraphNumberParams	struct
    VTSPNP_range		VisTextRange
    VTSPNP_startingParaNumber	word
VisTextSetParagraphNumberParams	ends

;------------------------------------------------------------------------------
;		Other character attributes (charAttrs) messages
;------------------------------------------------------------------------------

VisTextParaAttrFlags	record
    VTPAF_MULTIPLE_LEFT_MARGINS:1
    VTPAF_MULTIPLE_RIGHT_MARGINS:1
    VTPAF_MULTIPLE_PARA_MARGINS:1
    VTPAF_MULTIPLE_LINE_SPACINGS:1
    VTPAF_MULTIPLE_DEFAULT_TABS:1
    VTPAF_MULTIPLE_TOP_SPACING:1
    VTPAF_MULTIPLE_BOTTOM_SPACING:1
    VTPAF_MULTIPLE_LEADINGS:1
    VTPAF_MULTIPLE_BG_COLORS:1
    VTPAF_MULTIPLE_BG_GRAY_SCREENS:1
    VTPAF_MULTIPLE_BG_PATTERNS:1
    VTPAF_MULTIPLE_TAB_LISTS:1
    VTPAF_MULTIPLE_STYLES:1
    VTPAF_MULTIPLE_PREPEND_CHARS:1
    VTPAF_MULTIPLE_STARTING_PARA_NUMBERS:1
    VTPAF_MULTIPLE_NEXT_STYLES:1
VisTextParaAttrFlags	end

VisTextParaAttrFlags2	record
    VTPAF2_MULTIPLE_LANGUAGES:1
    VTPAF2_MULTIPLE_JUSTIFICATION_TYPES:1
    :14
VisTextParaAttrFlags2	end

VisTextParaAttrBorderFlags	record
    VTPABF_MULTIPLE_BORDER_LEFT:1		;Match with VTPBF_LEFT
    VTPABF_MULTIPLE_BORDER_TOP:1		;Match with VTPBF_TOP
    VTPABF_MULTIPLE_BORDER_RIGHT:1		;Match with VTPBF_RIGHT
    VTPABF_MULTIPLE_BORDER_BOTTOM:1		;Match with VTPBF_BOTTOM
    VTPABF_MULTIPLE_BORDER_DOUBLES:1		;Match with VTPBF_DOUBLE
    VTPABF_MULTIPLE_BORDER_DRAW_INNERS:1	;Match with VTPBF_DRAW_INNER
    VTPABF_MULTIPLE_BORDER_ANCHORS:1
    VTPABF_MULTIPLE_BORDER_WIDTHS:1
    VTPABF_MULTIPLE_BORDER_SPACINGS:1
    VTPABF_MULTIPLE_BORDER_SHADOWS:1
    VTPABF_MULTIPLE_BORDER_COLORS:1
    VTPABF_MULTIPLE_BORDER_GRAY_SCREENS:1
    VTPABF_MULTIPLE_BORDER_PATTERNS:1
    :3
VisTextParaAttrBorderFlags	end

VisTextParaAttrDiffs		struct
    VTPAD_diffs			VisTextParaAttrFlags
    VTPAD_diffs2		VisTextParaAttrFlags2
    VTPAD_borderDiffs		VisTextParaAttrBorderFlags
    VTPAD_attributes		VisTextParaAttrAttributes
    VTPAD_hyphenationInfo	VisTextHyphenationInfo
    VTPAD_keepInfo		VisTextKeepInfo
    VTPAD_dropCapInfo		VisTextDropCapInfo
    even
VisTextParaAttrDiffs	ends

MSG_VIS_TEXT_GET_PARA_ATTR		message
;
;	Return the paraAttr structure for the specified range.
;
;	Pass:	dx - size VisTextGetAttrParams (if called remotely)
;		ss:bp - VisTextGetAttrParams structure
;	Return:	ax - paraAttr token (0 if multiple)
;		buffer - filled
;		bp - unchanged
;	Compat:	Can be used with all text objects.
;

;---

MSG_VIS_TEXT_ADD_PARA_ATTR		message
;
;	Add a given paraAttr to the paraAttr array and initialize its reference
;	count to one.
;
;	Pass:	dx - size of paraAttr passed
;		ss:bp - VisTextParaAttr
;	Return:	ax - paraAttr token
;	Return:	cx, dx - destroyed
;		bp - unchanged
;	Compat:	This method cannot be used on a text object that does not have
;		multiple paraAttrs
;

;---

MSG_VIS_TEXT_REMOVE_PARA_ATTR		message
;
;	Remove a given paraAttr from the paraAttr array.
;
;	Pass:	cx - token of paraAttr to remove
;	Return:	ax, cx, dx, bp - destroyed
;	Compat:	This method cannot be used on a text object that does not have
;		multiple paraAttrs
;

;------------------------------------------------------------------------------
;		Messages to deal with style sheets
;------------------------------------------------------------------------------

MSG_VIS_TEXT_SUBST_ATTR_TOKEN		message
;
; Substitute an attribute token as part of a style sheet change.  This message
; exists to allow a higher level manager to pass this message to all text
; objects sharing the same attribute arrays (and thus the same styles)
;
; Pass:
;	ss:bp - VisTextSubstAttrTokenParams
; Return:
;	none

VisTextSubstAttrTokenParams	struct
    VTSATP_oldToken			word
    VTSATP_newToken			word
    VTSATP_runOffset			word
    VTSATP_updateRefFlag		word
    VTSATP_relayedToLikeTextObjects	word
    VTSATP_recalcFlag			fptr.word
VisTextSubstAttrTokenParams	ends


MSG_VIS_TEXT_RECALC_FOR_ATTR_CHANGE	message
;
; Recalculate text objects as part of a style sheet change.  This message
; exists to allow a higher level manager to pass this message to all text
; objects sharing the same attribute arrays (and thus the same styles)
;
; Pass:
;	cx - non-zero if this message has been relayed to like text objects

;------------------------------------------------------------------------------
;		Messages to set type information
;------------------------------------------------------------------------------

;
;	Definition of a text type element.
;

VisTextType	struct
    VTT_meta		RefElementHeader
    VTT_hyperlinkName	word		;name array element (-1 = none)
    VTT_hyperlinkFile	word		;name array element (-1 = none)
    VTT_context		word		;name array element (-1 = none)
    VTT_unused		byte 1 dup (0)
VisTextType	ends

.assert ((size VisTextType) and 1) eq 0

;---
;
; Common to all of these messages:
;	Pass:	dx - size {structure} (if called remotely)
;		ss:bp - {structure}
;	Return:	ax, cx, dx - destroyed
;		bp - unchanged
;	Compat:	This method cannot be used on a text object that does not have
;		multiple types or does not have a name array
;
; Each of these messages takes a structure that indicates the range of text
; to change and the values to change it to.
;
;---

VisTextSetContextFlags	record
     :4
     VTCF_ENSURE_CONTEXT_NOT_ALREADY_SET:1
				;TRUE: before setting context, make sure it's
				;      not already set somewhere 
     VTCF_REDIRECT_HYPERLINKS:1	;TRUE: take hyperlinks pointing
				;      to the context currently
				;      set on passed range and
				;      redirect them to point to
				;      the context now being set
     VTCF_SHOWING_HYPERLINKS:1	;TRUE: hyperlinks are shown in boxed style
     VTCF_TOKEN:1		;TRUE: context and hyperlink are tokens,
				;      not list indices
VisTextSetContextFlags	end

MSG_VIS_TEXT_SET_HYPERLINK		message
;
;	Set: the hyperlink
;


VisTextSetHyperlinkParams	struct
    VTSHLP_range	VisTextRange
    VTSHLP_context	word		; help context link to (token or index)
    VTSHLP_file		word		; help file link (token or index)
    VTSHLP_flags	VisTextSetContextFlags
	even
VisTextSetHyperlinkParams	ends

;---

MSG_VIS_TEXT_SET_CONTEXT		message
;
; Set the context for the specified range.
;
; Context:	Sent to set a context when the index or token for the
; 		context is available to be passed. If only the name
;		text is available, use MSG_VIS_TEXT_SET_CONTEXT_GIVEN_NAME_TEXT
;		instead.
; Source:	Hyperlink controller, TextHelp controller
; Destination:	Text object
; Interception: May be intercepted.
;			VTSCXP_range	- range over which to set context
;			VTSCXP_context	- context name (token or index)
;			VTSCXP_flags	- VTCF_TOKEN if context is token
;					  VTCF_REDIRECT_HYPERLINKS if desired
; Return:	nothing
;

VisTextSetContextParams	struct
    VTSCXP_range	VisTextRange
    VTSCXP_context	word		; context name (token or index)
					;  for messages that need it
    VTSCXP_flags	VisTextSetContextFlags
    VTSCXP_object	optr		; object holding name for
					;  messages that need it
	even
VisTextSetContextParams	ends

;---

VisTextMessages = VisTextMessages + 1

;---

VisTextTypeDiffs	record
    VTTD_MULTIPLE_HYPERLINKS:1
    VTTD_MULTIPLE_CONTEXTS:1
    :14
VisTextTypeDiffs	end

MSG_VIS_TEXT_GET_TYPE		message
;
;	Return the type for the specified range.
;
;	Pass:	dx - size VisTextGetAttrParams (if called remotely)
;		ss:bp - VisTextGetAttrParams structure
;	Return:	ax - type token (0 if multiple)
;		buffer - filled
;		bp - unchanged
;		dx - VisTextTypeDiffs
;	Compat:	This method cannot be used on a text object that does not have
;		multiple types or does not have a name array

;---

MSG_VIS_TEXT_ADD_TYPE		message
;
;	Add a given type to the type array and initialize its reference
;	count to one.
;
;	Pass:	dx - size VisTextType (if called remotely)
;		ss:bp - VisTextType
;	Return:	ax - type token
;		cx, dx - destroyed
;		bp - unchanged
;	Compat:	This method cannot be used on a text object that does not have
;		multiple types
;

;---

MSG_VIS_TEXT_REMOVE_TYPE	message
;
;	Remove a given type from the type array.
;
;	Pass:	cx - token of type to remove
;	Return:	ax, cx, dx, bp - destroyed
;	Compat:	This method cannot be used on a text object that does not have
;		multiple types

;------------------------------------------------------------------------------
;		Messages to set name information
;------------------------------------------------------------------------------

;
; "Token" for names & types in the current file
;
VIS_TEXT_CURRENT_FILE_TOKEN	equ	-1
VIS_TEXT_NIL_CONTEXT_TOKEN	equ	-1

VisTextNameType	etype	byte
VTNT_CONTEXT		enum	VisTextNameType
VTNT_FILE		enum	VisTextNameType

VisTextContextType etype	byte
VTCT_TEXT		enum VisTextContextType
VTCT_CATEGORY		enum VisTextContextType
VTCT_QUESTION		enum VisTextContextType
VTCT_ANSWER		enum VisTextContextType
VTCT_DEFINITION		enum VisTextContextType
VTCT_FILE		enum VisTextContextType, 255


VisTextNameData	struct
    VTND_type		VisTextNameType
    VTND_contextType	VisTextContextType
    VTND_file		word		;token of file
    VTND_helpText	DBGroupAndItem	;help text (0 in GeoWrite doc)
VisTextNameData	ends

;---

MSG_VIS_TEXT_ADD_NAME	message
;
;	Add a name to the name array (or add a reference to an existing name).
;	Set the data for the name to the given data.
;
;	Pass:	dx - size VisTextAddNameParams (if called remotely)
;		ss:bp - VisTextAddNameParams
;	Return:	ax - name token
;		carry - set if name newly added
;		dx - non-zero if newly added
;		cx, dx, bp - destroyed
;	Compat:	This method cannot be used on a text object that does not have
;		multiple names
;
VisTextAddNameParams	struct
    VTANP_name		fptr.char	;ptr to name
    VTANP_size		word		;length of name (0 for NULL-terminated)
    VTANP_flags		NameArrayAddFlags
    VTANP_data		VisTextNameData
VisTextAddNameParams	ends

;---

MSG_VIS_TEXT_FIND_NAME		message
;
;	Find a name in the name array.
;
;	Pass:	dx - size VisTextFindNameParams (if called remotely)
;		ss:bp - VisTextFindNameParams
;	Return:	carry - set if found
;		ax - token (CA_NULL_ELEMENT if not found)
;	Compat:	This method cannot be used on a text object that does not have
;		multiple types
;
VisTextFindNameParams	struct
    VTFNP_name		fptr.char	;name to find
    VTFNP_size		word		;length of name (0 for NULL-terminated)
    VTFNP_data		fptr.VisTextNameData ;buffer for data (0 for none)
VisTextFindNameParams	ends

;---

MSG_VIS_TEXT_FIND_NAME_BY_TOKEN		message
;
;	Return the data for a name token
;
;	Pass:	cx:dx - buffer of size MAX_VIS_TEXT_NAME_ARRAY_ELT_SIZE
;		bp - token
;	Return:	ax - length of element
;		buffer - filled
;	Compat:	This method cannot be used on a text object that does not have
;		multiple types
;

;---

MSG_VIS_TEXT_ADD_REF_FOR_NAME		message
;
;	Add a reference for a name
;
;	Pass:	cx - token
;	Return:	none
;	Compat:	This method cannot be used on a text object that does not have
;		multiple types
;

;---

MSG_VIS_TEXT_REMOVE_NAME	message
;
;	Remove a given name from the name array.
;
;	Pass:	cx - token of name to remove
;	Return:	ax, cx, dx, bp - destroyed
;	Compat:	This method cannot be used on a text object that does not have
;		multiple charAttrs
;

;------------------------------------------------------------------------------
;		Messages to set graphic information
;------------------------------------------------------------------------------
;
; "graphics" are a general purpose mechanism to embed things in the text
; stream.  Graphics can have data stored several ways:
;   * vm chains
;   * db items
;   * lmem chunks -- this format is not supported for cut/copy/paste
;
; graphics can be of several types
;   * gstrings -- handled automatically
;   * annotations -- handled automatically   *** NOT YET SUPPORTED ***
;   * custom
;
; Graphics are treated as characters, and thus reasonably small graphics can
; be in the middle of a line of text.
;
;		Structures for graphics
;
;	Size of opaque structure in VisTextGraphic

VIS_TEXT_GRAPHIC_OPAQUE_SIZE	=	32
;
;	Types of graphics
;
VisTextGraphicType	etype byte
VTGT_GSTRING		enum	VisTextGraphicType
VTGT_VARIABLE		enum	VisTextGraphicType

;
;	Flags for graphics
;
VisTextGraphicFlags	record
    VTGF_DRAW_FROM_BASELINE:1		;If set then draw from baseline else
					;draw from top
    VTGF_HANDLES_POINTER:1		;Graphic can deal with pointer messages
    VTGF_HOT_SPOT:1			;Graphic defines a hot spot
    :13
VisTextGraphicFlags	end
;
;	Type dependent data
;
; VTGT_GSTRING: gstring
;	VTG_opaque = VisTextGraphicGString
;
VisTextGraphicGString	struct
    VTGG_tmatrix	TransMatrix
    VTGG_drawOffset	XYOffset
VisTextGraphicGString	ends
;
; VTGT_VARIABLE: message sent to object.  See documentation below
;	VTG_opaque = VisTextGraphicVariable
;
VisTextGraphicVariable	struct
    VTGV_manufacturerID	ManufacturerID
    VTGV_type		VisTextVariableType
    VTGV_privateData	byte	(VIS_TEXT_GRAPHIC_OPAQUE_SIZE-4) dup (?)
VisTextGraphicVariable	ends

VisTextGraphicOpaque	type	VIS_TEXT_GRAPHIC_OPAQUE_SIZE dup (byte)

VisTextGraphicData	union
    VTGD_gstring	VisTextGraphicGString
    VTGD_variable	VisTextGraphicVariable
    VTGD_opaque		VisTextGraphicOpaque
VisTextGraphicData	end

	CheckHack <(size VisTextGraphicData) eq VIS_TEXT_GRAPHIC_OPAQUE_SIZE>
;
;	Definition of a text graphic element.
;
VisTextGraphic	struct
    VTG_meta		RefElementHeader	; Basic element management.
    VTG_vmChain		dword			; This is a dword value to
						; pass to the VMChain routines.
						;
						; If only the low word is 0, 
    						; then the high word is a VM
						; handle.
						;
						; If both are non-zero, it is
						; a DB item (high word is group
						; low word is item)
						;
						; If the high word is 0, 
						; then the low word is an 
						; LMemChunk.
						;
						; If both are 0, then there is
						; no data.
						;
    VTG_size		XYSize			;Size of the graphic (0
						;means dynamic)
    VTG_type		VisTextGraphicType
    VTG_flags		VisTextGraphicFlags
    VTG_reserved	byte 4 dup (?)
    VTG_data		VisTextGraphicData
VisTextGraphic	ends

.assert ((size VisTextGraphic) and 1) eq 0

VIS_TEXT_DEFAULT_GRAPHIC_WIDTH		=	10
VIS_TEXT_DEFAULT_GRAPHIC_HEIGHT		=	10

;---

ReplaceWithGraphicParams	struct
    RWGP_range		VisTextRange		;range to replace
    RWGP_pasteFrame	word			;ptr to frame if quick paste.
						;0 otherwise.
    RWGP_sourceFile	word			;source vm file
    RWGP_graphic	VisTextGraphic
ReplaceWithGraphicParams	ends

MSG_VIS_TEXT_REPLACE_WITH_GRAPHIC	message
;
;	Replace with given range with a graphic.
;
;	Pass:	dx - size ReplaceWithGraphicParams
;		ss:bp - ReplaceWithGraphicParams
;	Return:	ax, cx, dx - destroyed
;		bp - unchanged
;	Compat:	As described above, only text objects stored in vm files can
;		paste in graphics stored in vm blocks.
;

MSG_VIS_TEXT_GET_GRAPHIC_AT_POSITION	message
;
;	Get the VisTextGraphic structure corresponding to a graphic at
;	the passed position.
;
;	Pass: DX - size VisTextGetGraphicAtPositionParams
;	      SS:BP - ptr to VisTextGetGraphicAtPositionParams
;
;	Return: data returned in passed pointer.
;

VisTextGetGraphicAtPositionParams	struct
	VTGGAPP_position	dword
	VTGGAPP_retPtr		fptr.VisTextGraphic
VisTextGetGraphicAtPositionParams	ends

;-------------------------------

MSG_VIS_TEXT_GRAPHIC_VARIABLE_SIZE		message
;
; Find the size of a variable graphic.  The default handler for this sends
; a MSG_GEN_DOCUMENT_GET_VARIABLE up the visual tree (via
; MSG_VIS_VUP_CALL_OBJECT_OF_CLASS).
;
;	Pass:	cx - gstate
;		dx:bp - VisTextGraphic (dx always = ss)
;
;	Return:	cx - width
;		dx - height

MSG_VIS_TEXT_GRAPHIC_VARIABLE_DRAW		message
;
; Draw a variable graphic.  The default handler for this sends
; a MSG_GEN_DOCUMENT_GET_VARIABLE up the visual tree (via
; MSG_VIS_VUP_CALL_OBJECT_OF_CLASS).
;
;	Pass:	cx - gstate with font and current position set
;		dx:bp - VisTextGraphic (dx always = ss)
;
;	Return:	cx - width of graphic
;		dx - height of graphic

MSG_VIS_TEXT_GRAPHIC_VARIABLE_START_SELECT	message

MSG_VIS_TEXT_GRAPHIC_VARIABLE_OPEN		message

MSG_VIS_TEXT_GRAPHIC_VARIABLE_CLOSE		message


VisTextGraphicCompressParams	struct
    VTGCP_graphic	fptr.VisTextGraphic	; graphic containing gstring
    VTGCP_sourceFile	hptr.FileHandle		; file where gstring is stored
    VTGCP_destFile	hptr.FileHandle		; file for new gstring 
    VTGCP_format	BMFormat		; BMFormat in low byte
    VTGCP_compressFlag	byte			; non-zero to compress bitmaps
    VTGCP_xDPI		word			; x Resolution for bitmaps
    VTGCP_yDPI		word			; y Resolution for bitmaps
VisTextGraphicCompressParams	ends

global	VisTextGraphicCompressGraphic:far
;
; Copy a VisTextGraphic GString to a new GString, optimizing its bitmaps
; along the way.
;
;	Pass:	ss:bp - VisTextGraphicCompressParams
;
;	Return: dx:ax - VMChain of new GString
;


;------------------------------------------------------------------------------
;	Utility routine for format numbers
;------------------------------------------------------------------------------

; This routine is commonly used by handlers for variable graphics

global VISTEXTFORMATNUMBER:far

VisTextFormatNumber equ <VISTEXTFORMATNUMBER>

;
; Pass: (on stack, pushed in this order):
;	fptr.char - buffer
;	dword - number
;	word - VisTextNumberType
; Return: none
; Destroy: none

;------------------------------------------------------------------------------
;	Messages to load and save data in text objects
;------------------------------------------------------------------------------
;
; These data structures are used to store a text object in a DB item.  Do not
; use these unless absolutely necessary
;
	; Possibly add graphics, graphic runs, and names
VisTextSaveType	etype	byte
VTST_NONE		enum	VisTextSaveType	;nothing saved
VTST_SINGLE_CHUNK	enum	VisTextSaveType	;single attr sttucture
VTST_RUNS_ONLY		enum	VisTextSaveType
VTST_RUNS_AND_ELEMENTS	enum	VisTextSaveType

VisTextSaveDBFlags	record
    VTSDBF_TEXT:1		;set if text is saved (0 means null text)
    VTSDBF_CHAR_ATTR VisTextSaveType:2
    VTSDBF_PARA_ATTR VisTextSaveType:2
    VTSDBF_TYPE VisTextSaveType:2
    VTSDBF_GRAPHIC VisTextSaveType:2
    VTSDBF_STYLE:1
    VTSDBF_REGION:1		;not currently implemented
    VTSDBF_NAME:1
    :4
VisTextSaveDBFlags	end

MSG_VIS_TEXT_SAVE_TO_DB_ITEM		message
;
; Save a text object to a DB item
;
; If an override VM file exists the DB item will be saved in it.  Overwise
; the DB item will be saved in the file associated with the object.
;
; Pass:
;	cx.dx - DBItem to save to (or 0 to allocate)
;	bp - VisTextSaveDBFlags
; Return:
;	cx.dx - DBItem saved

MSG_VIS_TEXT_SAVE_TO_DB_ITEM_WITH_STYLES		message
;
; Save a text object to a DB item, passing a StyleSheetParams structure.
;
; This message is intended for applications that have multiple text objects
; sharing common attribute structures.  Only VTST_RUNS_ONLY should be passed
; for charAttr and paraAttr (and likely type and graphic) and normally
; VTST_STYLE will not be passed.
;
; If an override VM file exists the DB item will be saved in it.  Overwise
; the DB item will be saved in the file associated with the object.
;
; Pass:
;	ss:bp - VisTextSaveToDBWithStylesParams
; Return:
;	cx.dx - DBItem saved

VisTextSaveStyleSheetParams	struct
    VTSSSP_common		StyleSheetParams
    VTSSSP_graphicsElements	word		;VM block of graphics elements
    VTSSSP_treeBlock		word
    VTSSSP_graphicTreeOffset	word		;offset in treeBlock
VisTextSaveStyleSheetParams	ends

VisTextSaveToDBWithStylesParams	struct
    VTSTDBWSP_params	fptr.VisTextSaveStyleSheetParams
    VTSTDBWSP_dbItem	dword		;DBItem to save to (or 0 to allocate)
    VTSTDBWSP_flags	VisTextSaveDBFlags
    VTSTDBWSP_xferFile	word		;if non-zero then the StyleSheetParams
					;are not initialized and this is the
					;file to put the arrays in
VisTextSaveToDBWithStylesParams	ends

MSG_VIS_TEXT_LOAD_FROM_DB_ITEM		message
;
; Load a text object from a DB item
;
; Pass:
;	cx.dx - DBItem to load from
;	bp - VMFileHandle to use (or 0 to use VTI_vmFile)
; Return:
;	none

MSG_VIS_TEXT_LOAD_FROM_DB_ITEM_WITH_STYLES		message
;
; Load a text object from a DB item, passing a StyleSheetParams structure.
;
; Pass:
;	ss:bp - VisTextLoadFromDBWithStylesParams
; Return:
;	none

VisTextLoadFromDBWithStylesParams	struct
    VTLFDBWSP_params	fptr.StyleSheetParams
    VTLFDBWSP_dbItem	dword		;DBItem to load from
    VTLFDBWSP_file	hptr		;file (or 0)
VisTextLoadFromDBWithStylesParams	ends


MSG_VIS_TEXT_SET_VM_FILE		message
;
; Change the file handle with which the text object is associated
;
; Pass:
;	cx - VMFileHandle
; Return:
;	none

;------------------------------------------------------------------------------
;	Messages to create and destroy the data structures used to store
;	attributes
;------------------------------------------------------------------------------

MSG_VIS_TEXT_CREATE_STORAGE	message
;
;	Create storage structures for a text object.  Note that additional
;	levels of attribute storage can only be *set*.
;
;	These bits can be set:
;		VTSF_MULTIPLE_CHAR_ATTRS, VTSF_MULTIPLE_PARA_ATTRS,
;		VTSF_TYPES, VTSF_GRAPHICS
;
; Pass:
;	cl - VisTextStorage flags to set
;	ch - non-zero to create regions
; Return:
;	none
; Compat:
;	Can be used with small or large objects as long as the object does
;	not already have the structures to be added.

MSG_VIS_TEXT_CHANGE_ELEMENT_ARRAY	message
;
;	Change the element array being used for the text object.  This
;	allows an application to easily set up multiple objects referencing
;	common element arrays.
;
;	If you are changing multiple arrays, do the name and style arrays;
;	first because to change the element array the text object must free
;	the old element array. To do this is must know how this array is
;	stored (with chunk or VM block). It does this by looking at the
;	character attributes and assuming that the styles/names are stored
;	in the same way.  Thus we must change the styles/names while the
;	character attributes are still stored in a chunk so that the old
;	style/name array will be freed correctly.
;
; Pass:
;	cl - VisTextStorageFlags for field to replace (one of these bits should
;	     be set:
;		VTSF_MULTIPLE_CHAR_ATTRS
;		VTSF_MULTIPLE_PARA_ATTRS
;		VTSF_TYPES
;		VTSF_GRAPHICS
;		VTSF_STYLES
;		VTSF_NAMES
;	ch - non-zero if word passed in dx is a VM block, zero if it is a
;	     chunk handle
;	dx - VM block handle or chunk handle containing element array (depends
;	     on ch)
;	bp - token for empty run to cover object (char, para, type)

MSG_VIS_TEXT_FREE_STORAGE		message
;
;	Remove all runs associated with this object.
;	Basically all elements which are referred to have their reference
;	counts decremented and if the reference counts go to zero, the
;	elements are removed.
;	Use caution with this method.
;
; Pass:
;	cx - non-zero to remove element arrays also
; Return:
;	none

;------------------------------------------------------------------------------
;	Messages to create and manipulate transfer items
;------------------------------------------------------------------------------
;
;		Structure of a transfer item (TIF_TEXT)
;
; Note that some of the blocks in the tree are lmem blocks.  For VM chains the
; first word of a block must be the VM block handle of the next linked data
; block.  For the lmem code, the first word must be the block handle.
; Also, the HF_LMEM bit in the handle must be set for the lmem code, but it
; must not be set for the clipboard.
;
; To handle this conflict, the text object clears the HF_LMEM bit and stuffs
; the VM block handle link (always 0 for now) before calling the clipboard.
; When it gets a block from the clipboard, the text object locks it and
; temporarily sets the HF_LMEM bit.
;
; The element arrays in lmem blocks use the chunk handle
; "VM_ELEMENT_ARRAY_CHUNK" defined below.
;

VM_ELEMENT_ARRAY_CHUNK	= (((size LMemBlockHeader) + 3) and not 3)

TextTransferBlockHeader	struct
    TTBH_meta		VMChainTree
    TTBH_reservedOther	word	20 dup (0)

TTBH_firstVM	label	word
    TTBH_text		dword		;huge array id
    TTBH_charAttrRuns	dword		;huge array id
    TTBH_paraAttrRuns	dword		;huge array id
    TTBH_typeRuns	dword		;huge array id
    TTBH_graphicRuns	dword		;huge array id
TTBH_firstLMem	label	word
    TTBH_charAttrElements dword		;vm block handle
    TTBH_paraAttrElements dword		;vm block handle
    TTBH_typeElements	dword		;vm block handle
    TTBH_graphicElements dword		;vm block handle
    TTBH_styles		dword		;vm block handle
    TTBH_names		dword		;vm block handle
    TTBH_pageSetup	dword		;vm block handle
TTBH_lastLMem	label	word
    TTBH_reservedVM	dword	10 dup (0)
TextTransferBlockHeader	ends
;
;	This is the structure stored in TTBH_pageSetup
;
PageSetupInfo	struct	
	PSI_meta		VMChainLink
	PSI_pageSize		XYSize	;Pixels (Points)
	PSI_layout		PageLayout
	PSI_numColumns		word
	PSI_columnSpacing	word	;Points * 8
	PSI_ruleWidth		word	;Pixels (Points)

;	The margins are relative to the edges of the page, and are in
;	points * 8

	PSI_leftMargin		word
	PSI_rightMargin		word
	PSI_topMargin		word
	PSI_bottomMargin	word
PageSetupInfo	ends
;---

global	VTFClearSmartQuotes:far

global TextAllocClipboardObject:far
;
; Allocate a temporary object associated with the clipboard file for purposes
; of producing a transfer item.
;
; Pass:
;	al - VisTextStorageFlags for object. Only the following bits may
;	     be set:
;		VTSF_MULTIPLE_CHAR_ATTRS
;		VTSF_MULTIPLE_PARA_ATTRS
;		VTSF_TYPES
;		VTSF_GRAPHICS
;		VTSF_STYLES
;	     The following are assumed set if al is 0:
;		VTSF_LARGE, VTSF_DEFAULT_CHAR_ATTR, VTSF_DEFAULT_PARA_ATTR
;	ah - non-zero to create regions for object
;	bx - file with which to associate object, or 0 for clipboard file
; Return:
;	^lbx:si - object

TextClipboardOption	etype	word
TCO_COPY			enum	TextClipboardOption
TCO_RETURN_TRANSFER_FORMAT	enum	TextClipboardOption
TCO_RETURN_TRANSFER_ITEM	enum	TextClipboardOption
TCO_RETURN_NOTHING		enum	TextClipboardOption

global TextFinishWithClipboardObject:far
;
; Finish with an object created by TextAllocClipboardObject
;
; Pass:
;	^lbx:si - object
;	ax - TextClipboardOption
;	cx:dx - owner for clipboard item
;	es:di - name for clipboard item (di = -1 for default)
; Return:
;	object destroyed
;	ax - return value:
;		TCO_COPY			nothing; transfer item is
;						generated from the object and
;						set as the normal transfer item
;		TCO_RETURN_TRANSFER_FORMAT	VM block handle to store in
;						high word of CIFI_vmChain (low
;						word must be 0)
;		TCO_RETURN_TRANSFER_ITEM	VM block handle of block with
;						ClipboardItemHeader and text
;						rendered from the object in
;						the appropriate formats
;		TCO_RETURN_NOTHING		nothing. just destroys the
;						text object.


;---

	; Parameters sent on the stack to all transfer routines

CommonTransferParams	struct
    CTP_range		VisTextRange
    CTP_pasteFrame	word		;ptr to frame if quick paste.
					;0 otherwise.
    CTP_vmFile		word		;VM file handle
    CTP_vmBlock		word		;VM block handle
CommonTransferParams	ends

MSG_VIS_TEXT_REPLACE_WITH_TEXT_TRANSFER_FORMAT	message
;
;	Replace the given range with a text transfer item.  The range passed
;	is the range to replace.  (0, 0) can be passed to insert and the
;	beginning.  (TEXT_ADDRESS_PAST_END, TEXT_ADDRESS_PAST_END) can be
;	passed to append at the end.
;
;	Pass:	dx - size CommonTransferParams (if called remotely)
;		ss:bp - CommonTransferParams structure
;	Return:	ax, cx, dx - destroyed
;		bp - unchanged
;	Compat:	Can be used with all text objects

MSG_VIS_TEXT_CREATE_TRANSFER_FORMAT	message
;
;	Create a text transfer item for a range of text.
;
;	Pass:	dx - size CommonTransferParams (if called remotely)
;		ss:bp - CommonTransferParams structure
;	Return:	ax - vm block handle of newly created transfer block
;		cx, dx - destroyed
;		bp - unchanged
;	Compat:	Can be used with all text objects

;------------------------------------------------------------------------------
;	      Method for modifying text in a text object
;------------------------------------------------------------------------------

MSG_VIS_TEXT_REPLACE_ALL_PTR		message
;
; Replace the entire text of an object with text referenced by a pointer.
;	PASS:	dx:bp	= Pointer to the text string
;		cx	= String length, or 0 if null-terminated
;

MSG_VIS_TEXT_REPLACE_ALL_OPTR	message
;
; Replace the entire text of an object with text referenced by a chunk.
;	PASS:	^ldx:bp	= Pointer to the text string
;		cx	= String length, or 0 if null-terminated
;

MSG_VIS_TEXT_REPLACE_ALL_BLOCK		message
;
; Replace the entire text of an object with text referenced by a block.
;	PASS:	^hdx	= Pointer to the text string
;		cx	= String length, or 0 if null-terminated
;

MSG_VIS_TEXT_REPLACE_ALL_VM_BLOCK	message
;
; Replace the entire text of an object with text referenced by a vm-block.
;	PASS:	^vdx:bp	= Pointer to the text string
;		cx	= String length, or 0 if null-terminated
;

MSG_VIS_TEXT_REPLACE_ALL_DB_ITEM	message
;
; Replace the entire text of an object with text referenced by a db-item.
; The text is assumed to be NULL terminated.
;	PASS:	dx	= File
;		bp	= Group
;		cx	= Item
;

MSG_VIS_TEXT_REPLACE_ALL_HUGE_ARRAY	message
;
; Replace the entire text of an object with text referenced by a huge-array.
;	PASS:	dx	= File
;		bp	= HugeArray
;		cx	= String length, or 0 if null-terminated
;

MSG_VIS_TEXT_REPLACE_SELECTION_PTR	message
MSG_VIS_TEXT_REPLACE_SELECTION		equ MSG_VIS_TEXT_REPLACE_SELECTION_PTR
;
; Replace the selection of an object with text referenced by a pointer.
;	PASS:	dx:bp	= Pointer to the text string
;		cx	= String length, or 0 if null-terminated
;

MSG_VIS_TEXT_REPLACE_SELECTION_OPTR	message
;
; Replace the selection of an object with text referenced by a chunk.
;	PASS:	^ldx:bp	= Pointer to the text string
;		cx	= String length, or 0 if null-terminated
;

MSG_VIS_TEXT_REPLACE_SELECTION_BLOCK		message
;
; Replace the selection of an object with text referenced by a block.
;	PASS:	^hdx	= Pointer to the text string
;		cx	= String length, or 0 if null-terminated
;

MSG_VIS_TEXT_REPLACE_SELECTION_VM_BLOCK	message
;
; Replace the selection of an object with text referenced by a vm-block.
;	PASS:	^vdx:bp	= Pointer to the text string
;		cx	= String length, or 0 if null-terminated
;

MSG_VIS_TEXT_REPLACE_SELECTION_DB_ITEM	message
;
; Replace the selection of an object with text referenced by a db-item.
; The text is assumed to be NULL terminated.
;	PASS:	dx	= File
;		bp	= Group
;		cx	= Item
;

MSG_VIS_TEXT_REPLACE_SELECTION_HUGE_ARRAY	message
;
; Replace the selection of an object with text referenced by a huge-array.
;	PASS:	dx	= File
;		bp	= HugeArray
;		cx	= String length, or 0 if null-terminated
;

MSG_VIS_TEXT_APPEND_PTR		message
MSG_VIS_TEXT_APPEND		equ	MSG_VIS_TEXT_APPEND_PTR
;
; Append to an object with text referenced by a pointer.
;	PASS:	dx:bp	= Pointer to the text string
;		cx	= String length, or 0 if null-terminated
;

MSG_VIS_TEXT_APPEND_OPTR		message
;
; Append to an object with text referenced by a chunk.
;	PASS:	^ldx:bp	= Pointer to the text string
;		cx	= String length, or 0 if null-terminated
;

MSG_VIS_TEXT_APPEND_BLOCK		message
;
; Append to an object with text referenced by a block.
;	PASS:	^hdx	= Pointer to the text string
;		cx	= String length, or 0 if null-terminated
;

MSG_VIS_TEXT_APPEND_VM_BLOCK		message
;
; Append to an object with text referenced by a vm-block.
;	PASS:	^vdx:bp	= Pointer to the text string
;		cx	= String length, or 0 if null-terminated
;

MSG_VIS_TEXT_APPEND_DB_ITEM		message
;
; Append to an object with text referenced by a db-item.
; The text is assumed to be NULL terminated.
;	PASS:	dx	= File
;		bp	= Group
;		cx	= Item
;

MSG_VIS_TEXT_APPEND_HUGE_ARRAY		message
;
; Append to an object with text referenced by a huge-array.
;	PASS:	dx	= File
;		bp	= HugeArray
;		cx	= String length, or 0 if null-terminated
;

MSG_VIS_TEXT_GET_ALL_PTR		message
;
; Get the entire text of an object into a buffer referenced by a pointer.
;	PASS:	dx:bp	= Pointer to the text string
;	RETURN:	cx	= String length not counting the NULL
;		dx, bp	= Unchanged
;

MSG_VIS_TEXT_GET_ALL_OPTR	message
;
; Get the entire text of an object into a buffer referenced by a chunk.
; The chunk will always exist on return. It will contain at least a NULL.
;	PASS:	^ldx:bp	= Pointer to the text string
;		bp	= 0 to allocate a chunk handle
;	RETURN:	cx	= Chunk handle of the chunk in which the text was placed
;			  Chunk resized to be the size of the null terminated
;				text.
;		ax	= String length not counting the NULL
;

MSG_VIS_TEXT_GET_ALL_BLOCK		message
;
; Get the entire text of an object into a buffer referenced by a block.
; The block will always exist on return. It will contain at least a NULL.
;	PASS:	^hdx	= Pointer to the text string
;			= 0 to allocate a new block
;	RETURN:	cx	= Block handle of the chunk in which the text was placed
;			  Block resized to be the size of the null terminated
;				text.
;		ax	= String length not counting the NULL
;		dx, bp	= Unchanged
;

MSG_VIS_TEXT_GET_ALL_VM_BLOCK	message
;
; Get the entire text of an object into a buffer referenced by a vm-block.
; The vm-block will always exist on return. It will contain at least a NULL.
;	PASS:	^vdx:bp	= Pointer to the text string
;		bp	= 0 to allocate a new vm-block
;	RETURN:	cx	= VM-Block handle of the chunk in which the text was
;				placed.
;			  VM-Block resized to be the size of the null terminated
;				text.
;		ax	= String length not counting the NULL
;		dx, bp	= Unchanged
;

MSG_VIS_TEXT_GET_ALL_DB_ITEM	message
;
; Get the entire text of an object into a buffer referenced by a db-item.
; The db-item will always exist on return. It will contain at least a NULL.
;	PASS:	dx	= File
;		bp	= Group
;		cx	= Item
;			= 0 to allocate a new item
;	RETURN:	cx	= DB-Item of the chunk in which the text was placed.
;			  DB-Item resized to be the size of the null terminated
;				text.
;		bp 	= Group	(may be different from above if DB_UNGROUPED
;			  	 passed).
;		ax	= String length not counting the NULL
;		dx	= Unchanged
;

MSG_VIS_TEXT_GET_ALL_HUGE_ARRAY	message
;
; Get the entire text of an object into a buffer referenced by a huge-array.
; The huge-array will always exist on return. It will contain at least a NULL.
;	PASS:	dx	= File
;		bp	= HugeArray
;			= 0 to allocate a new array
;	RETURN:	cx	= Array handle of the chunk in which the text was placed
;			  Array resized to be the size of the null terminated
;				text.
;		dx:ax	= String length not counting the NULL
;		bp	= Unchanged
;

MSG_VIS_TEXT_GET_SELECTION_PTR		message
;
; Get the selected text of an object into a buffer referenced by a pointer.
;	PASS:	dx:bp	= Pointer to the text string
;	RETURN:	cx	= String length not counting the NULL
;		dx, bp	= Unchanged
;

MSG_VIS_TEXT_GET_SELECTION_OPTR	message
;
; Get the selected text of an object into a buffer referenced by a chunk.
; The chunk will always exist on return. It will contain at least a NULL.
;	PASS:	^ldx:bp	= Pointer to the text string
;		bp	= 0 to allocate a chunk handle
;	RETURN:	cx	= Chunk handle of the chunk in which the text was placed
;			  Chunk resized to be the size of the null terminated
;				text.
;		ax	= String length not counting the NULL
;		dx, bp	= Unchanged
;

MSG_VIS_TEXT_GET_SELECTION_BLOCK	message
;
; Get the selected text of an object into a buffer referenced by a block.
; The block will always exist on return. It will contain at least a NULL.
;	PASS:	^hdx	= Pointer to the text string
;			= 0 to allocate a new block
;	RETURN:	cx	= Block handle of the chunk in which the text was placed
;			  Block resized to be the size of the null terminated
;				text.
;		ax	= String length not counting the NULL
;		dx, bp	= Unchanged
;

MSG_VIS_TEXT_GET_SELECTION_VM_BLOCK	message
;
; Get the selected text of an object into a buffer referenced by a vm-block.
; The vm-block will always exist on return. It will contain at least a NULL.
;	PASS:	^vdx:bp	= Pointer to the text string
;		bp	= 0 to allocate a new vm-block
;	RETURN:	cx	= VM-Block handle of the chunk in which the text was
;				placed.
;			  VM-Block resized to be the size of the null terminated
;				text.
;		ax	= String length not counting the NULL
;		dx, bp	= Unchanged
;

MSG_VIS_TEXT_GET_SELECTION_DB_ITEM	message
;
; Get the selected text of an object into a buffer referenced by a db-item.
; The db-item will always exist on return. It will contain at least a NULL.
;	PASS:	dx	= File
;		bp	= Group
;			= 0 to allocate a new item
;	RETURN:	cx	= DB-Item of the chunk in which the text was placed.
;			  DB-Item resized to be the size of the null terminated
;				text.
;		bp 	= Group	(may be different from above if DB_UNGROUPED
;			  	 passed).
;		ax	= String length not counting the NULL
;		dx	= Unchanged
;


MSG_VIS_TEXT_GET_SELECTION_HUGE_ARRAY	message
;
; Get the selected text of an object into a buffer referenced by a huge-array.
; The huge-array will always exist on return. It will contain at least a NULL.
;	PASS:	dx	= File
;		bp	= HugeArray
;			= 0 to allocate a new array
;	RETURN:	cx	= Array handle of the chunk in which the text was placed
;			  Array resized to be the size of the null terminated
;				text.
;		dx:ax	= String length not counting the NULL
;		bp	= Unchanged
;

MSG_VIS_TEXT_DELETE_ALL		message
;
; Delete text of an object.
;	PASS:	nothing
;	RETURN:	nothing
;

MSG_VIS_TEXT_DELETE_SELECTION	message
;
; Delete selected text of an object.
;	PASS:	nothing
;	RETURN:	nothing
;

MSG_VIS_TEXT_GET_SELECTION_RANGE	message
;
; Get the range of the selection.
;	PASS:	dx:bp	= Pointer to a VisTextRange to fill in
;	RETURN:	VisTextRange filled in
;

MSG_VIS_TEXT_SELECT_RANGE_SMALL	message
;
; Select a range in the object.
;	PASS:	cx	= Start of range to select
;		dx	= End of range to select
;	COMPAT:	This only works with small model objects.
;

MSG_VIS_TEXT_SELECT_ALL		message
;
; Select the entire object
;	PASS:	nothing
;	RETURN:	nothing
;

MSG_VIS_TEXT_SELECT_START	message
;
; Place the cursor at the start of the text.
;	PASS:	nothing
;	RETURN:	nothing
;

MSG_VIS_TEXT_SELECT_END	message
;
; Place the cursor at the end of the text.
;	PASS:	nothing
;	RETURN:	nothing
;

MSG_VIS_TEXT_SELECT_RELATIVE	message
;
; Place the cursor at a position relative to its current one.
;	PASS:	cx	= New start selection relative to old start selection.
;		dx	= New end selection relative to old end selection.
;	RETURN:	nothing
;

;------------------------------------------------------------------------------
;	Messages to change or get the state of the text object
;------------------------------------------------------------------------------

MSG_VIS_TEXT_GET_STATE		message
;
;	Get the VTI_state
;
;	Pass:	none
;	Return:	cl - VTI_state (VisTextStates)
;		ax, ch, dx, bp - destroyed
;	Compat:	Can be used with all text objects

MSG_VIS_TEXT_GET_FEATURES	message
;
; 	Gets the VTI_features bits
;
;	Pass: nothing
;	Return: cx - VisTextFeatures
;		ax, dx, bp -destroyed
;

MSG_VIS_TEXT_SET_FEATURES	message
;
;	Sets the VTI_features bits.
;
;	Pass: cx - bits to set
;	      dx - bits to clear
;
;	Return: nothing
;		ax, cx, dx, bp - destroyed
;

MSG_VIS_TEXT_SET_MAX_LENGTH		message
;
;	Set the maximum length of the text.  If the current text is too long,
;	text at the end is removed. This only applies to small text objects.
;
;	Pass:	cx - new maximum length.
;	Return:	ax, cx, dx, bp - destroyed
;	Compat:	Can be used with all text objects

MSG_VIS_TEXT_GET_MAX_LENGTH		message
;
;	Get the maximum length of the text.
;
;	Pass:	none
;	Return:	cx - maximum length.
;	Return:	ax, dx, bp - unchanged
;	Compat:	Can be used with all text objects

MSG_VIS_TEXT_GET_USER_MODIFIED_STATE		message
;
;	Get the user modified status of the text object.
;	Return:	cx - non-zero if user modified
;	Return:	ax,dx, bp - unchanged
;	Compat:	Can be used with all text objects

MSG_VIS_TEXT_SET_NOT_USER_MODIFIED		message
;
;	Mark a text object as not user modified
;	Return:	ax, cx, dx, bp - unchanged
;	Compat:	Can be used with all text objects

MSG_VIS_TEXT_SET_USER_MODIFIED		message
;
;	Mark a text object as user-modified
;	NOTE: This does *not* send out the MSG_META_TEXT_USER_MODIFIED notification
;	Return:	ax, cx, dx, bp - unchanged
;	Compat:	Can be used with all text objects

MSG_VIS_TEXT_SET_WASH_COLOR		message
;
;	Set the wash color for behind the text.
;	Pass:	ch - VisTextColorMapMode
;		cl - if (ch == CF_RGB), Red
;		     if (ch == CF_INDEX), Color index.
;		dl - Green (if CF_RGB).
;		dh - Blue (if CF_RGB).
;	Return:	ax, cx, dx, bp - destroyed
;	Compat:	Can be used with all text objects

MSG_VIS_TEXT_GET_WASH_COLOR		message
;
;	Get the wash color for behind the text.
;	Pass:	none
;	Return:	ch - VisTextColorMapMode
;		cl - if (ch == CF_RGB), Red
;		     if (ch == CF_INDEX), Color index.
;		dl - Green (if CF_RGB).
;		dh - Blue (if CF_RGB).
;	Return:	ax, cx, dx, bp - destroyed
;	Compat:	Can be used with all text objects

MSG_VIS_TEXT_MODIFY_EDITABLE_SELECTABLE	message
;
; Modify the editable and/or selectable state of the object
;
; Pass:
;	cl - VisTextStates to set
;	ch - VisTextStates to clear

;------------------------------------------------------------------------------
;	Internal methods used by specific UI
;------------------------------------------------------------------------------

MSG_VIS_TEXT_UPDATE_GENERIC		message
;
;	Update the generic instance data from the visual instance data.
;
;	Pass:	none
;	Return:	ax, cx, dx, bp - destroyed
;	Compat:	Can be used with all text objects.

;------------------------------------------------------------------------------
;	Messages that can be subclassed to add functionality
;------------------------------------------------------------------------------

VisTextNotifyCharAttrChange	struct
    VTNCAC_charAttr		VisTextCharAttr
    VTNCAC_charAttrToken	word
    VTNCAC_charAttrDiffs	VisTextCharAttrDiffs
VisTextNotifyCharAttrChange	ends

;---

VisTextNotifyParaAttrChange	struct
    VTNPAC_paraAttr		VisTextMaxParaAttr
    VTNPAC_paraAttrToken	word
    VTNPAC_paraAttrDiffs	VisTextParaAttrDiffs
    VTNPAC_regionOffset		sdword
    VTNPAC_regionWidth		sword
    VTNPAC_selectedTab		word
VisTextNotifyParaAttrChange	ends

;---

VisTextNotifyTypeChange	struct
    VTNTC_type			VisTextType
    VTNTC_typeToken		word
    VTNTC_typeDiffs		VisTextTypeDiffs
    VTNTC_index			VisTextType	;VTNTC_type as list indices
VisTextNotifyTypeChange	ends

;---

VisTextNotifySelectionChange	struct
    VTNSC_selectStart		dword
    VTNSC_selectEnd		dword
    VTNSC_lineNumber		dword
    VTNSC_lineStart		dword
    VTNSC_region		word
    VTNSC_regionStartLine	dword
    VTNSC_regionStartOffset	dword
VisTextNotifySelectionChange	ends

;---

VisTextNotifyHyperlinkabilityChange	struct
    VTNHC_hyperlinkable		BooleanWord
VisTextNotifyHyperlinkabilityChange	ends

;---

VisTextNotifyCountChange	struct
    VTNCC_charCount		dword
    VTNCC_wordCount		dword
    VTNCC_lineCount		dword
    VTNCC_paraCount		dword
VisTextNotifyCountChange	ends

;---

VisTextNameChangeType	etype	byte
    VTNCT_NULL			enum VisTextNameChangeType
    VTNCT_ADD			enum VisTextNameChangeType
    VTNCT_REMOVE		enum VisTextNameChangeType
    VTNCT_RENAME		enum VisTextNameChangeType

VisTextNotifyNameChange		struct
    VTNNC_count			word		; this field must come first!
    VTNNC_type			VisTextNameType ; type of affected name
    VTNNC_changeType		VisTextNameChangeType	; type of change
    VTNNC_index			word		; index of affected name
    VTNNC_fileIndex		word		; file index, if VTNT_CONTEXT
VisTextNotifyNameChange		ends

;---

VisTextCursorPositionChange	struct
    VTCPC_lineNumber		dword
    VTCPC_rowNumber		dword
VisTextCursorPositionChange	ends

;---

MSG_VIS_TEXT_GENERATE_NOTIFY		message
;
; Generate notification structures as needed and send them out.  This allows
; subclasses to send out their own notifications and allows subclasses to
; combine the notification data from several text objects.
;
; Pass:
;	cx=ss (for C version)
;	ss:bp - VisTextGenerateNotifyParams

VisTextNotificationFlags	record
    VTNF_SELECT_STATE:1
    VTNF_CHAR_ATTR:1
    VTNF_PARA_ATTR:1
    VTNF_TYPE:1
    VTNF_SELECTION:1
    VTNF_COUNT:1
    VTNF_STYLE_SHEET:1
    VTNF_STYLE:1
    VTNF_SEARCH_ENABLE:1
    VTNF_SPELL_ENABLE:1
    VTNF_NAME:1
    VTNF_CURSOR_POSITION:1
    VTNF_HYPERLINKABILITY:1
    :3
VisTextNotificationFlags	end

VIS_TEXT_STANDARD_NOTIFICATION_FLAGS equ mask VTNF_SELECT_STATE or \
					 mask VTNF_CHAR_ATTR or \
					 mask VTNF_PARA_ATTR or \
					 mask VTNF_TYPE or \
					 mask VTNF_STYLE or \
					 mask VTNF_STYLE_SHEET or \
					 mask VTNF_CURSOR_POSITION or \
					 mask VTNF_HYPERLINKABILITY

; VTNF_CURSOR_POSITION is only used if ATTR_VIS_TEXT_NOTIFY_CURSOR_POSITION
; is set


VIS_TEXT_GAINED_TARGET_NOTIFICATION_FLAGS equ \
				VIS_TEXT_STANDARD_NOTIFICATION_FLAGS or \
				mask VTNF_SEARCH_ENABLE or \
				mask VTNF_SPELL_ENABLE or \
				mask VTNF_NAME

VisTextNotifySendFlags	record
    VTNSF_UPDATE_APP_TARGET_GCN_LISTS:1
    ; Set if pertinent Application Target GCN Lists should be updated with
    ; changes in status

    VTNSF_NULL_STATUS:1
    ; Send notification of null status, for all notification types (used only
    ; to notify GCN Lists of loss of eligibility to update, i.e. lost target)
    ; The text output will always be sent only meaningful info.

    VTNSF_STRUCTURE_INITIALIZED:1
    ; Set if the rest of the VisTextGenerateNotifyParams structure is
    ; initialized

    VTNSF_SEND_AFTER_GENERATION:1
    ; Set to send the notifications after generating them

    VTNSF_SEND_ONLY:1
    ; Set to send the notifications *only*

    VTNSF_RELAYED_TO_LIKE_TEXT_OBJECTS:1
    ; Set if the message has been registered with the object responsible
    ; for relaying the message to multiple text objects.

    :10

VisTextNotifySendFlags	end

VisTextGenerateNotifyParams	struct
    VTGNP_notificationTypes	VisTextNotificationFlags
    VTGNP_sendFlags		VisTextNotifySendFlags
    VTGNP_notificationBlocks	hptr 16 dup (?)
VisTextGenerateNotifyParams	ends

MSG_VIS_TEXT_CHAR_ATTR_VIRTUAL_TO_PHYSICAL	message
;
;	Convert a virtual charAttr to a physical charAttr.  This message is
;	only sent if the VTS_SUBCLASS_VIRT_PHYS_TRANSLATION bit is set in
;	VTS_states.  This message is sent before the default processing.
;
;	Pass:	cx:dx - VisTextCharAttr
;	Return:	none

MSG_VIS_TEXT_PARA_ATTR_VIRTUAL_TO_PHYSICAL	message
;
;	Convert a virtual paraAttr to a physical paraAttr.  This message is
;	only sent if the VTS_SUBCLASS_VIRT_PHYS_TRANSLATION bit is set in
;	VTS_states.  This message is sent before the default processing.
;
;	Pass:	cx:dx - VisTextParaAttr
;	Return:	none

;------------------------------------------------------------------------------
; The following methods are passed to the OD VTI_output
;------------------------------------------------------------------------------

MSG_META_TEXT_USER_MODIFIED	message	MetaTextMessages
;
;	Sent when the user modifies the text
;	This message is sent to the text object itself first.
;
; NOTE:  the text object sends this notification first to its destination, &
; then to itself for internal update.  If you intercept this message at the
; destination, be aware the text object's MODIFIED state has not yet been
; updated, & so operations that modify that state, such as
; MSG_VIS_TEXT_SET_NOT_USER_MODIFIED, or MSG_GEN_TEXT_SET_MODIFIED_STATE,
; may not be synchronously called.  If you need to perform such operations,
; such as the case where you need to clear the modified status in order to
; receive notification on every keypress, use the MF_FORCE_QUEUE and
; MF_PLACE_AT_FRONT flags when sending the message, so as to allow the text
; object to first finish updating itself.
; 
;	Pass:	cx:dx - object
;	Return:	none

MSG_META_TEXT_CR_FILTERED	message	MetaTextMessages
;
;	Sent when a CR is filtered out of the text input.
;	This message is sent to the text object itself first.
;
;	Pass: 	cx = character value
;		dl = CharFlags
;		dh = ShiftState
;		bp low = ToggleState
;		bp high = scan code
;	Return:	none

MSG_META_TEXT_TAB_FILTERED	message	MetaTextMessages
;
;	Sent when a tab is filtered out of the text input.
;	This message is sent to the text object itself first.
;
;	Pass: 	cx = character value
;		dl = CharFlags
;		dh = ShiftState
;		bp low = ToggleState
;		bp high = scan code
;	Return:	none
;	Return:	none

MSG_META_TEXT_LOST_FOCUS	message	MetaTextMessages
;
; 	Sent when text object loses the focus.
;
;	Pass:	cx:dx - object
;	Return:	none


MSG_META_TEXT_GAINED_FOCUS	message	MetaTextMessages
;
; 	Sent when text object gains the focus.
;
;	Pass:	cx:dx - object
;	Return:	none


MSG_META_TEXT_LOST_TARGET	message	MetaTextMessages
;
; 	Sent when text object loses the target.
;
;	Pass:	cx:dx - object
;	Return:	none


MSG_META_TEXT_GAINED_TARGET	message	MetaTextMessages
;
; 	Sent when text object gains the target.
;
;	Pass:	cx:dx - object
;	Return:	none


MSG_META_TEXT_EMPTY_STATUS_CHANGED	message	MetaTextMessages
;
; 	Sent when text object becomes empty or not empty
;	This message is sent to the text object itself first.
;
;	Pass:	cx:dx - text object
;		bp - non-zero if text is becoming non-empty
;	Return:	none

MSG_META_TEXT_NOT_USER_MODIFIED	message	MetaTextMessages
;
;	Sent when the text object is set not user modified.
;	This message is sent to the text object itself first.
;
;	Pass:	cx:dx - object
;	Return:	none


;------------------------------------------------------------------------------
; The following methods are assumed to be handled by a sub-class (usually the
; specific ui).
;------------------------------------------------------------------------------

MSG_VIS_TEXT_EDIT_DRAW		message
;
;	This method is invoked after the text has been drawn so that the
;	specific UI or sub-class can handle anything special that it needs to.
;
;	Pass:	none
;	Return:	none

MSG_VIS_TEXT_SHOW_SELECTION		message
;
;	Sent from the text display to allow subclasses of text display to make
;	the current selection visible.  For instance, in an openlook text
;	display the text may be in a window, and the openlook implementation
;	can use this method handler to scroll the selection onscreen.  The
;	text display doesn't handle this method itself.
;
;	Pass:	ss:bp - VisTextShowSelectionArgs
;	Return:	none

VisTextShowSelectionFlags	record
    VTSSF_DRAGGING:1
    :15
VisTextShowSelectionFlags	end

VisTextShowSelectionArgs	struct
    VTSSA_params	MakeRectVisibleParams
    VTSSA_flags		VisTextShowSelectionFlags
VisTextShowSelectionArgs	ends

MSG_VIS_TEXT_HEIGHT_NOTIFY		message
;
;	A method sent out by the object, to itself (for use in subclassing),
;	which announces any change it text height.  Will be used to drive
;	changes in visual box height, conversion to scrolled version.
;
;	For large objects dx is meaningless.  For large objects this message
;	*must* be passed to the superclass.
;
;	Pass:	dx - New height of text at current with (-1 if infinite)
;	Return:	none

MSG_VIS_TEXT_ENTER_OVERSTRIKE_MODE	message
;
;	Enter overstrike mode. Leave insert mode.
;
;	Pass:	cx - non-zero if called from the text object.
;	Return:	none

MSG_VIS_TEXT_ENTER_INSERT_MODE	message
;
;	Enter insert mode. Leave overstrike mode.
;
;	Pass:	cx - non-zero if called from the text object.
;	Return:	none

MSG_VIS_TEXT_GET_MINIMUM_DIMENSIONS	message
;
; Figure the minimum dimensions of a text object whose geometry is valid and
; which has been calculated. This is to allow applications which create
; text objects to figure their minimum size, given some initial configuration.
;
; The height and width returned will already be accounting for the lr and tb
; margin values, so the caller should not have to.
;
;	PASS:	dx:bp	= VisTextMinimumDimensionsParameters
;	RETURN:	Paramters filled in
;
VisTextMinimumDimensionsParameters	struc
    VTMDP_height	WBFixed
    VTMDP_width		WBFixed
VisTextMinimumDimensionsParameters	ends

;------------------------------------------------------------------------------
;	Filtering messages
;------------------------------------------------------------------------------

; The text object allows various mechanisms for filtering text.  The simplest
; is the VisTextFilter variable stored in VTI_filters, which covers most
; basic filtering situations.
;
; More complex filtering can be implemented using the filtering messages
; below.  Because these messages can impose a non-trivial performance
; penalty, they are only sent out if the ATTR_VIS_TEXT_EXTENDED_FILTER
; attribute exists.
;
; ATTR_VIS_TEXT_EXTENDED_FILTER allows several levels of filtering as
; controlled by the data stored with it (VisTextExtendedFilterTypes)

VisTextExtendedFilterType	etype	byte
VTEFT_REPLACE_PARAMS		enum	VisTextExtendedFilterType
	; This causes MSG_VIS_TEXT_FILTER_VIA_REPLACE_PARAMS to be sent
VTEFT_CHARACTER_LEVELER_LEVEL		enum	VisTextExtendedFilterType
	; This causes MSG_VIS_TEXT_FILTER_VIA_CHARACTER to be sent
VTEFT_BEFORE_AFTER		enum	VisTextExtendedFilterType
	; This causes MSG_VIS_TEXT_FILTER_VIA_BEFORE_AFTER to be sent


MSG_VIS_TEXT_FILTER_VIA_REPLACE_PARAMS		message
;
; Filter text that is about to be entered in the text object.
;
; Pass:
;	ss:bp - VisTextReplaceParameters
; Return:
;	carry - set to reject replacement

MSG_VIS_TEXT_FILTER_VIA_CHARACTER		message
;
; Filter text that is about to be entered in the text object.  The text
; object calls this message for each character in the replacement text.
;
; Pass:
;	cx - character
; Return:
;	cx - 0 to reject replacement, otherwise the replacement char

MSG_VIS_TEXT_FILTER_VIA_BEFORE_AFTER		message
;
; Filter text that is about to be entered in the text object.  This message
; passes two buffers containing the current text in the text object and
; the (proposed) new text for the object.
;
; This message can only be used on small text objects.
;
; If the buffer is going to be rejected it is legal to call text object
; messages from within this handler
;
; Pass:
;	cx - chunk handle of "before" text
;	dx - chunk handle of "after" text
;	ss:bp - VisTextReplaceParameters (this is normally not needed but
;		can be used for various obscure and devious purposes)
; Return:
;	carry - set to reject buffer

;------------------------------------------------------------------------------
;	Style sheet messages
;------------------------------------------------------------------------------

MSG_VIS_TEXT_LOAD_STYLE_SHEET	message
;
;	Merge data from a given style sheet
;
; Pass:
;	ss:bp - StyleSheetParams
; Return:
;	none

MSG_VIS_TEXT_LOAD_STYLE_SHEET_PARAMS	message
;
;	Fill in the passed StyleSheetParams struct
;
; Pass:
;	ss:bp - StyleSheetParams
;	cx - nonzero to preserve xfer arrays
;
; Return:
;	ss:bp - StyleSheetParams filled in

;------------------------------------------------------------------------------
; The following methods are implemented in the file: textMethodGeometry.asm
;------------------------------------------------------------------------------

MSG_VIS_TEXT_GET_MIN_WIDTH		message
;
;	Returns minimum width that can be supported for attributes of the
;	text object.
;
;	Pass:	none
;	Return:	cx - minimum width which can be supported
;		ax, dx, bp - destroyed
;	Compat:	Can be used with all text objects.

MSG_VIS_TEXT_GET_AVERAGE_CHAR_WIDTH		message
;
;	Returns the average character width for the first font/charAttr
;	combination.
;
;	Pass:	none
;	Return:	cx - average character width
;		ax, dx, bp - destroyed
;	Compat:	Can be used with all text objects.

MSG_VIS_TEXT_CALC_HEIGHT		message
;
;	A routine which may be called to figure out how tall the text would be
;	if the width were changed.
;
;	Pass:	cx - A width
;		dx - non-zero if the result should be cached. This should
;		     only be passed from the specific UI. If you are not
;		     the specific UI you should pass dx == 0 always.
;	Return:	dx - Height of text at given width
;		ax, cx, bp - destroyed
;	Compat:	Cannot be used with document objects

MSG_VIS_TEXT_GET_LINE_HEIGHT		message
;
;	Get the height of a line in a single-line text object only. This will
;	not work for multi-line objects - use MSG_VIS_TEXT_GET_LINE_INFO
;	instead.
;
;	Pass:	none
;	Return:	ax - line height.
;		cx, dx, bp - destroyed
;	Compat:	Cannot be used with document objects

MSG_VIS_TEXT_RECALC_AND_DRAW		message
;
;	Recalculate and redraw the text object.  Call this after you have made
;	a change to the text objects instance data without its knowledge.
;
;	Pass:	none
;	Return:	ax, cx, dx, bp - destroyed
;	Compat:	Can be used with all text objects.

MSG_VIS_TEXT_GET_ONE_LINE_WIDTH	message
;
;	Calculate the width of the text if it were all to appear on one line,
;	assuming one charAttr.
;
;	Pass:	cx - Number of chars to use in the calculation
;				  (or zero to use entire string)
;	Return:	cx - Width of the text
;		ax, dx, bp - destroyed
;	Compat:	Cannot be used with document objects.  Only intended for one
;		line text objects

MSG_VIS_TEXT_GET_SIMPLE_MIN_WIDTH		message
;
;	Returns minimum width that can be supported for current text, font &
;	charAttr.  Just like the regular version but assumes that the caller is
;	not worried about keeping a width large enough for the largest border
;	possible.
;
;	Pass:	none
;	Return:	cx - minimum width which can be supported

;-----------------------------------------------------------------------------
;
;	 Methods to handle search and replace and spell
;
;-----------------------------------------------------------------------------

;**************************************************************************
;
;	Methods sent from the search and replace and spell check boxes
;
;**************************************************************************

MSG_SEARCH		message	MetaSearchSpellMessages
;
;	Method sent out by the search box to tell an object to start a
;	search. The search string may contain WildCard chars.
;
;	Pass: dx - handle of block containing words (should be freed by method
;	       	   handlers)
;		Format of block:
;			SearchReplaceStruct<>
;			data	Null-Terminated Search String
;

SearchReplaceStruct	struct
	SRS_searchSize	word
	;# chars in search string (including null terminator)

	SRS_replaceSize	word
	;# chars in replace string (including null terminator)

	SRS_params	SearchOptions
	;Parameters for search and replace

	SRS_replyObject	optr
	;OD of object to send string-not-found message to

	SRS_replyMsg	word
	;Message sent to SRS_replyObject if the string was not
	; found

	SRS_searchString	label	char
	;The search string
SearchReplaceStruct	ends


MSG_REPLACE_CURRENT		message		MetaSearchSpellMessages
;
;	Method sent out by spell check library to tell the application to 
;	replace the current string with the passed text.
;
;	Pass: dx - handle of block containing words (should be freed by method
;	       	   handlers)
;		Format of block:
;			SearchReplaceStruct<>
;			data	Null-Terminated Search String
;			data	Null-Terminated Replace string
;

MSG_REPLACE_ALL_OCCURRENCES			message	MetaSearchSpellMessages
;
;	Method sent out by spell check library to tell the text object to 
;	replace the all occurences of the current word (after the start of
;	the current selection) with the passed text.
;
;	Pass: dx - handle of block containing words (should be freed by method
;	       	   handlers)
;	      cx - non-zero if it should do a replace all throughout the
;		   entire document (as opposed to after the current position)
;
;		Format of block:
;			SearchReplaceStruct<>
;			data	Null-Terminated Search String
;			data	Null-Terminated Replace string
;

MSG_REPLACE_ALL_OCCURRENCES_IN_SELECTION	message	MetaSearchSpellMessages
;
;	Method sent out by spell check library to tell the text object to 
;	replace the all occurences of the current word in the selected area
;	with the passed text.
;
;	Pass: dx - handle of block containing words (should be freed by method
;	       	   handlers)
;
;		Format of block:
;			SearchReplaceStruct<>
;			data	Null-Terminated Search String
;			data	Null-Terminated Replace string
;

MSG_ABORT_ACTIVE_SPELL		message	MetaSearchSpellMessages
MSG_ABORT_ACTIVE_SEARCH		message	MetaSearchSpellMessages
;
;	Sent out to the GAGCNLT_APP_TARGET_NOTIFY_SEARCH_SPELL_CHANGE gcnlist
;	to let the search/spell boxes know that the user has aborted the
;	current search/spell.
;
;	Pass: nothing
;	Return: nothing
;

MSG_META_GET_OBJECT_FOR_SEARCH_SPELL	message	MetaSearchSpellMessages
;
;	This is a message that the text object sends to itself when it needs
;	to determine in what object it should start/continue a search and
;	replace (for example, a search can wrap across multiple objects - when
;	the end of one object is reached, the text object sends this to
;	itself, and the app can intercept this message to cause the search to
;	continue in the appropriate object). 
;
;	Pass: BP - GetSearchSpellObjectParam
;	      ^lCX:DX - the object that the search/replace is currently in
;	Return: CX:DX <- ptr to requested object
;	Destroyed: ax, bp
;

GetSearchSpellObjectType	etype	word
	GSSOT_FIRST_OBJECT	enum	GetSearchSpellObjectType
;	This is used by the spell check code to determine in which object to
;	start spell checking when the user clicks on "Check Entire Document".
;	It is also used by the search code to wrap a search to the beginning
;	after it has reached the end.

	GSSOT_LAST_OBJECT	 enum	GetSearchSpellObjectType
;	This is used by the search code to wrap a backwards search around to
;	the end.

	GSSOT_NEXT_OBJECT	 enum	GetSearchSpellObjectType
;	This is used by the search/spell/replace all code to get the next
;	object in which to continue a search/spell/replace all. At the end
;	of the chain of objects, it should return 0:0.

	GSSOT_PREV_OBJECT	enum	GetSearchSpellObjectType
;	This is used by the backwards search code. After reaching the
;	start of the chain, it should return 0:0.

GetSearchSpellObjectParam	record
    GSSOP_RELAYED_FLAG:1
    :11
    GSSOP_TYPE	GetSearchSpellObjectType:4
GetSearchSpellObjectParam	end

MSG_META_GET_CONTEXT	message	MetaSearchSpellMessages
;
;	Gets information from the destination text object so it can be
;	displayed on the screen.
;
;	Pass: ss:bp - GetContextParams
;	Return: nothing
;	Destroyed: ax, cx, dx, bp
;

ContextLocation	etype	word
	CL_STARTING_AT_POSITION		enum	ContextLocation
	; Gets "numCharsToGet" chars starting at GCP_position

	CL_ENDING_AT_POSITION		enum	ContextLocation
	; Gets text ending at the passed selection

	CL_CENTERED_AROUND_POSITION	enum	ContextLocation
	; Gets "numCharsToGet" chars centered around GCP_position

	CL_CENTERED_AROUND_SELECTION	enum	ContextLocation
	; Gets "numCharsToGet" chars centered around the selection

	CL_CENTERED_AROUND_SELECTION_START	enum	ContextLocation
	; Gets "numCharsToGet" chars centered around the start of the
	; selection

	CL_SELECTED_WORD		enum	ContextLocation
	; Gets selection, or surrounding word, or whatever

GetContextParams	struct
	GCP_replyObj		optr
	; Output to reply to via MSG_META_CONTEXT

	GCP_numCharsToGet	word
	; Max # chars to return

	GCP_location		ContextLocation
	GCP_position		dword
GetContextParams	ends

MSG_META_GENERATE_CONTEXT_NOTIFICATION	message	MetaSearchSpellMessages
;
;	Creates a context block and sends it to the GAGCNLT_NOTIFY_TEXT_CONTEXT
;	list.
;
;	Pass: ss:bp - GetContextParams (GCP_replyObj ignored)
;	Return: nothing
;	Destroyed: nothing
;


MSG_META_CONTEXT	message	MetaSearchSpellMessages
;
;	Message used to return context to the SpellControl object.
;
;	Pass: bp - block containing ContextData
;	Return: nothing (block is freed by SpellControl)
;	Destroyed: ax, cx, dx, bp
;

ContextData	struct
	CD_object	optr
	; What object the context is coming from
	
	CD_numChars	dword
	; The # chars in the text object

	CD_range	VisTextRange
	; The range of characters that this context represents

	CD_selection	VisTextRange
	; What the current text selection is

	CD_contextData	label	char
	; Null-terminated data
ContextData	ends

MSG_META_DISPLAY_OBJECT_FOR_SEARCH_SPELL	message	MetaSearchSpellMessages
;
;	Force the object onto the screen.
;
;	Pass:	none
;	Return:	none

;------------------------------------------------------------------------------
; These are used by the specific ui and are special, consider carefully whether
; or not you really want to use these.
;------------------------------------------------------------------------------

MSG_VIS_TEXT_SCROLL_ONE_LINE		message
;
;	Scroll a one line object so a given position is displayed.
;
;	Pass:	cx - position to make visible.
;		     This position is kind of screwed up. It is the offset
;		     into the text, plus the offset to the left edge of the
;		     object, plus the lrMargin.
;	Return:	ax, cx, dx, bp - destroyed
;	Compat:	Can only be used on one line objects

MSG_VIS_TEXT_GET_SCROLL_AMOUNT	message
;
;	Decide the amount to scroll vertically.
;
;	Pass:	dx - offset to scroll from.
;		cx - suggested amount to scroll. (Positive or negative).
;	Return:	dx - amount to scroll.
;		ax - destroyed
;		cx, bp - unchanged
;	Compat:	Cannot be use on one line objects

MSG_VIS_TEXT_SCROLL_PAGE_UP		message
MSG_VIS_TEXT_SCROLL_PAGE_DOWN		message
;
; Scrolls a text object up or down a page if it's scrollable.
;

MSG_VIS_TEXT_SCREEN_UPDATE		message 
;
;	Make the screen update itself.
;
;	Pass:	none
;	Return:	none

;------------------------------------------------------------------------------
; These are used internally and shouldn't be used by anyone...
;------------------------------------------------------------------------------
MSG_VIS_TEXT_FLASH_CURSOR_ON		message private
;
;	Flash the cursor on.
;
;	Pass:	none
;	Return:	none

MSG_VIS_TEXT_FLASH_CURSOR_OFF	message private
;
;	Flash the cursor off.
;
;	Pass:	none
;	Return:	none

;-----------------------------------------------------------------------------
; Methods used internally by the search and replace/spell code. 
;-----------------------------------------------------------------------------

MSG_VIS_TEXT_SPELL_CHECK_FROM_OFFSET	message	private
;
;	Starts a spell check in this object at the passed offset.
;	It ignores the SpellCheckStartOption field, and instead uses
;	SCFOS_offset.
;
;	Pass: SS:BP <- ptr to SpellCheckFromOffsetStruct
;		DX <- size of SpellCheckFromOffsetStruct
;
;	Returns: nothing
;	Destroyed: ax, cx, dx, bp
;

SpellCheckFromOffsetFlags	record
	SCFOF_CHECK_NUM_CHARS:1
	;If set, VisTextSpellCheckFromOffset will check the passed # chars

SpellCheckFromOffsetFlags	end

SpellCheckFromOffsetStruct	struct
	SCFOS_ICBuff	hptr
	; ICBuff to pass to spell check library

	SCFOS_flags	SpellCheckFromOffsetFlags
	; Flags to say whether or not to skip the next word in the document

	SCFOS_numChars	dword
	; # chars to spell check total (if we want to skip the next word,
	; the size of that word is deducted from this total).

	SCFOS_offset	dword
	; Offset into text to begin spell checking

	SCFOS_replyOptr	optr
	; Optr of object reply messages (such as SPELL_CHECK_COMPLETED) should
	; be sent to
	even
SpellCheckFromOffsetStruct	ends


MSG_VIS_TEXT_SEARCH_FROM_OFFSET		message	
;
;	Does a wrap-around search from the passed offset into the text object.
;
;	Pass: dx - size of SearchFromOffsetStruct
;	      ss:bp - ptr to SearchFromOffsetStruct
;
;	Returns: results in passed-in ptr to SearchFromOffsetReturnStruct
;

SearchFromOffsetReturnStruct	struct
	SFORS_object	optr	(?)
	; Ptr to object that match was found in (or 0:0 if not found)

	SFORS_offset	dword	(?)
	; Offset into object where match was found (ala VisTextRange)

	SFORS_len	dword	(?)
	; Length of match

SearchFromOffsetReturnStruct	ends
SearchFromOffsetFlags	record
	SFOF_STOP_AT_STARTING_POINT:1
		;Set (internally) if this search has wrapped around
SearchFromOffsetFlags	end

SearchFromOffsetStruct	struct
	SFOS_data	hptr.SearchReplaceStruct
		;Handle of block with data in this format:
		;			SearchReplaceStruct<>
		;			data	Null-Terminated Search String
		;			data	Null-Terminated Replace string
	SFOS_startObject	optr
		;OD of object where current search began.

	SFOS_startOffset	dword
		;Offset into object where current search began. This offset
		; is *not* an offset to a char, but rather an offset between
		; chars (i.e. the beginning of an object is 0, between the
		; first and second chars = 1, etc)
		; (Can range from 0 to <text size>).

	SFOS_currentOffset	dword
		;Offset between chars in text object to start search.
		; (Can range from 0 to <text size>).
	SFOS_flags	SearchFromOffsetFlags

	SFOS_retStruct		fptr.SearchFromOffsetReturnStruct
		;A pointer to where to store the return values
	even
SearchFromOffsetStruct	ends

MSG_VIS_TEXT_REPLACE_ALL_OCCURRENCES_FROM_OFFSET	message 
;
;	Method sent out by text object to do a "replace all" from the passed
;	offset.
;
;	Pass: ss:[bp] - ptr to ReplaceAllFromOffsetStruct
;
;		     (This replace all is assumed to start at the passed offset
;		       and continue until the end of the chain of text objects
;		       is reached)
;
;	Returns: cx - # replaces that actually occurred
;	Destroyed: ax, dx, bp
;

ReplaceAllFromOffsetFlags	record
	RAFOF_CONTINUING_REPLACE:1
	; Set if this message was generated to continue a replace all sent to
	; a different object

	RAFOF_HAS_UNDO:1
	; Set if this action will be undoable - mainly used for error-checking,
	; to ensure that all objects involved in a ReplaceAll are undoable.
	:14
ReplaceAllFromOffsetFlags	end

ReplaceAllFromOffsetStruct	struct
	RAFOS_data		hptr.SearchReplaceStruct
;	Data in this format:
;			SearchReplaceStruct<>
;			data	Null-Terminated Search String
;			data	Null-Terminated Replace string
;
;	NOTE: The sender of this message is responsible for freeing the
;	      passed SearchReplaceStruct. 
;	

	RAFOS_startOffset	dword
;	Offset in this object to begin replace all
;
	RAFOS_flags	ReplaceAllFromOffsetFlags
;	These flags are set internally by the text object - do not set them.
;

ReplaceAllFromOffsetStruct	ends


MSG_VIS_TEXT_REPLACE_ALL_OCCURRENCES_IN_RANGE	message
;
;	Method sent out by text object to do a "replace all" over the passed
;	range.
;
;	Pass: ss:bp - ptr to ReplaceAllInRangeStruct
;
;	Return: cx - # replaces that actually occurred
;	Destroyed: ax, dx, bp
;

ReplaceAllInRangeStruct	struct
	RAIRS_data	hptr.SearchReplaceStruct
;	Data in this format:
;			SearchReplaceStruct<>
;			data	Null-Terminated Search String
;			data	Null-Terminated Replace string
;
;	NOTE: The sender of this message is responsible for freeing the
;	      passed SearchReplaceStruct. 
;	
	RAIRS_range	VisTextRange <>
ReplaceAllInRangeStruct	ends

VisTextMessages = VisTextMessages + 1

;------------------------------------------------------------------------------
; Predefined filters
;------------------------------------------------------------------------------

VisTextFilterClass	etype	byte
VTFC_NO_FILTER		enum	VisTextFilterClass	;no filter
VTFC_ALPHA		enum	VisTextFilterClass	;alpha chars only
VTFC_NUMERIC		enum	VisTextFilterClass	;numberic only
VTFC_SIGNED_NUMERIC	enum	VisTextFilterClass	;signed numeric
VTFC_SIGNED_DECIMAL	enum	VisTextFilterClass	;numeric, with decimal
VTFC_FLOAT_DECIMAL	enum	VisTextFilterClass	;numeric,decimal,e,E
VTFC_ALPHA_NUMERIC	enum	VisTextFilterClass	;alphanumeric
VTFC_FILENAMES		enum	VisTextFilterClass	;legal PCGEOS filenames
VTFC_DOS_FILENAMES	enum	VisTextFilterClass	;legal DOS filenames
VTFC_DOS_PATH		enum 	VisTextFilterClass	;legal DOS path
VTFC_DATE		enum	VisTextFilterClass	;legal date
VTFC_TIME		enum	VisTextFilterClass	;legal time
VTFC_DASHED_ALPHA_NUMERIC    enum VisTextFilterClass	;alphanumeric plus '-'
VTFC_NORMAL_ASCII	enum	VisTextFilterClass	;normal ascii chars
VTFC_DOS_VOLUME_NAMES	enum	VisTextFilterClass	;legal DOS volume names
VTFC_DOS_CHARACTER_SET	enum	VisTextFilterClass	;DOS character set
VTFC_ALLOW_COLUMN_BREAKS enum	VisTextFilterClass	;Allow column-breaks

VisTextFilters		record
	VTF_NO_SPACES:1				;no spaces allowed
	;NOTE: This only filters out C_SPACE in text libraries v3.1 and below.
	; Starting with 3.2, non-breaking-spaces, em-spaces, etc get filtered
	; as well.
	VTF_NO_TABS:1				;no tabs
	VTF_UPCASE_CHARS:1			;make uppercase
	VTF_FILTER_CLASS VisTextFilterClass:5	;filter classes
						;(keep in low bits!)
VisTextFilters		end


;
; Specific UI's define mappings between keys and functions using the following
; data structures.
;
; Don't make changes to these without also making changes to the visTextBindings
; table in textMethodInput.
;
VisTextKeyFunction	etype	word, 0, 6

VTKF_FORWARD_LINE			enum VisTextKeyFunction
VTKF_BACKWARD_LINE			enum VisTextKeyFunction

VTKF_SELECT_ADJUST_FORWARD_LINE		enum VisTextKeyFunction
VTKF_SELECT_ADJUST_BACKWARD_LINE	enum VisTextKeyFunction

VTKF_FORWARD_CHAR			enum VisTextKeyFunction
VTKF_BACKWARD_CHAR			enum VisTextKeyFunction

VTKF_FORWARD_WORD			enum VisTextKeyFunction
VTKF_BACKWARD_WORD			enum VisTextKeyFunction

VTKF_FORWARD_PARAGRAPH			enum VisTextKeyFunction
VTKF_BACKWARD_PARAGRAPH			enum VisTextKeyFunction

VTKF_START_OF_LINE			enum VisTextKeyFunction
VTKF_END_OF_LINE			enum VisTextKeyFunction

VTKF_START_OF_TEXT			enum VisTextKeyFunction
VTKF_END_OF_TEXT			enum VisTextKeyFunction

VTKF_SELECT_WORD			enum VisTextKeyFunction

	;==========================================
	; None of the following entries are supported:
	;	VTKF_SELECT_LINE
	;	VTKF_SELECT_PARAGRAPH
	;	VTKF_SELECT_OBJECT
	;
VTKF_SELECT_LINE			enum VisTextKeyFunction
VTKF_SELECT_PARAGRAPH			enum VisTextKeyFunction
VTKF_SELECT_OBJECT			enum VisTextKeyFunction
	;==========================================

VTKF_SELECT_ADJUST_FORWARD_CHAR		enum VisTextKeyFunction
VTKF_SELECT_ADJUST_BACKWARD_CHAR	enum VisTextKeyFunction

VTKF_SELECT_ADJUST_FORWARD_WORD		enum VisTextKeyFunction
VTKF_SELECT_ADJUST_BACKWARD_WORD	enum VisTextKeyFunction

VTKF_SELECT_ADJUST_FORWARD_PARAGRAPH	enum VisTextKeyFunction
VTKF_SELECT_ADJUST_BACKWARD_PARAGRAPH	enum VisTextKeyFunction

VTKF_SELECT_ADJUST_TO_START		enum VisTextKeyFunction
VTKF_SELECT_ADJUST_TO_END		enum VisTextKeyFunction

VTKF_SELECT_ADJUST_START_OF_LINE	enum VisTextKeyFunction
VTKF_SELECT_ADJUST_END_OF_LINE		enum VisTextKeyFunction

VTKF_DELETE_BACKWARD_CHAR		enum VisTextKeyFunction
VTKF_DELETE_BACKWARD_WORD		enum VisTextKeyFunction
VTKF_DELETE_BACKWARD_LINE		enum VisTextKeyFunction
VTKF_DELETE_BACKWARD_PARAGRAPH		enum VisTextKeyFunction
VTKF_DELETE_TO_START			enum VisTextKeyFunction

VTKF_DELETE_CHAR			enum VisTextKeyFunction
VTKF_DELETE_WORD			enum VisTextKeyFunction
VTKF_DELETE_LINE			enum VisTextKeyFunction
VTKF_DELETE_PARAGRAPH			enum VisTextKeyFunction
VTKF_DELETE_TO_END			enum VisTextKeyFunction

VTKF_DELETE_EVERYTHING			enum VisTextKeyFunction

VTKF_DESELECT				enum VisTextKeyFunction

VTKF_TOGGLE_OVERSTRIKE_MODE		enum VisTextKeyFunction

VTKF_TOGGLE_SMART_QUOTES		enum VisTextKeyFunction

VTKF_PAGE_UP				enum VisTextKeyFunction
VTKF_PAGE_DOWN				enum VisTextKeyFunction

VTKF_INSERT_TIME			enum VisTextKeyFunction
VTKF_INSERT_DATE			enum VisTextKeyFunction
VTKF_INSERT_NAME			enum VisTextKeyFunction

VTKF_SELECT_ADJUST_BACKWARD_PAGE	enum VisTextKeyFunction
VTKF_SELECT_ADJUST_FORWARD_PAGE		enum VisTextKeyFunction

MSG_VIS_TEXT_DO_KEY_FUNCTION	message
;
;	Perform one of the VisTextKeyFunction on a text object without
;	having had to hit the proper key. Useful when GenDataTriggers are what
;	are performing the function and you don't want to/can't figure out the
;	shortcut being used by the specific UI to implement the function.
;
;	Pass:	cx - VisTextKeyFunction to perform
;		bp - data for function
;	Return:	ax, cx, dx, bp - destroyed
;	Compat:	Can be used with all text objects.

;------------------------------------------------------------------------------
;	      Method for getting text from a text object
;------------------------------------------------------------------------------

MSG_VIS_TEXT_REPLACE_TEXT	message
;
;	Replace a range of text with some new text.
;
;	Pass:	ss:bp - pointer to a VisTextReplaceParameters structure on
;			the stack.
;			See VisTextReplace() for more details (below)
;			on how to create and pass this structure.
;			Really, you ought to look...
;	Return:	carry - set if error
;		ax - destroyed
;		cx, dx, bp - unchanged
;	Compat:	Can be used with all text objects
;

;*****************************************************************************
; The following definitions apply to the new VisTextReplace and also to
; VisTextGetTextRange.
;*****************************************************************************
;
; This structure defines a reference to text. It can be:
;	Pointer
;	Memory segment and chunk
;	Memory block and chunk
;	Memory block handle
;	VM file and VM block
;	VM file and DBase item
;	VM file and huge-array handle
;
TextReferenceType	etype	word, 0, 2

TRT_POINTER		enum	TextReferenceType
TextReferencePointer	struct
    TRP_pointer		fptr.char
    ;
    ; MSG_VIS_TEXT_GET_TEXT_RANGE Documentation:
    ; ------------------------------------------
    ; VTGRF_RESIZE has no meaning with this sort of reference.
    ;
    ; The TRP_pointer field must always be filled in.
    ;
    ; VTGRF_ALLOCATE and VTGRF_ALLOCATE_ALWAYS are not valid flags to pass
    ; with this type of text reference.
    ;
    ; This is the safest way to copy text out of a text object. Since the
    ; caller allocates the block it can also handle errors in the allocation.
    ;
    ; Must be fptr for XIP'ed geodes
    ;
TextReferencePointer	ends

TRT_SEGMENT_CHUNK	enum	TextReferenceType
TextReferenceSegmentChunk	struct
    TRSC_chunk		word
    TRSC_segment	word
    ;
    ; MSG_VIS_TEXT_GET_TEXT_RANGE Documentation:
    ; ------------------------------------------
    ; The TRSC_segment field must be filled in.
    ;
    ; It is assumed that the lmem heap will be able to accomodate this
    ; allocation. The caller is responsible for ensuring that this is the
    ; case.
    ;
    ; If VTGRF_RESIZE is passed then either the passed chunk or the allocated
    ; chunk will be resized to accomodate the text.
    ;
TextReferenceSegmentChunk	ends

TRT_OPTR		enum	TextReferenceType
TextReferenceBlockChunk	struct
    TRBC_ref		optr.char
    ;
    ; MSG_VIS_TEXT_GET_TEXT_RANGE Documentation:
    ; ------------------------------------------
    ; The handle field of the TRBC_ref field must be filled in. 
    ;
    ; It is assumed that the lmem heap will be able to accomodate this
    ; allocation. The caller is responsible for ensuring that this is the
    ; case.
    ;
    ; If VTGRF_RESIZE is passed then either the passed chunk or the allocated
    ; chunk will be resized to accomodate the text.
    ;
TextReferenceBlockChunk	ends

TRT_BLOCK		enum	TextReferenceType
TextReferenceBlock	struct
    TRB_handle		hptr.char
    ;
    ; MSG_VIS_TEXT_GET_TEXT_RANGE Documentation:
    ; ------------------------------------------
    ; No fields need to be filled in in order to allocate a destination buffer.
    ; The heap allocation request will be made with the HAF_NO_ERR flag.
    ;
    ; If VTGRF_RESIZE is passed then either the passed block or the allocated
    ; block will be resized to accomodate the text.
    ;
TextReferenceBlock	ends

TRT_VM_BLOCK		enum	TextReferenceType
TextReferenceVMBlock	struct
    TRVMB_file		hptr
    TRVMB_block		word
    ;
    ; MSG_VIS_TEXT_GET_TEXT_RANGE Documentation:
    ; ------------------------------------------
    ; The TRVMB_file must be filled in if you want a VM block to be
    ; allocated.
    ;
    ; If VTGRF_RESIZE is passed then either the passed vm-block or the allocated
    ; vm-block will be resized to accomodate the text.
    ;
TextReferenceVMBlock	ends

TRT_DB_ITEM		enum	TextReferenceType
TextReferenceDBItem	struct
    TRDBI_file		hptr
    TRDBI_item		word
    TRDBI_group		word
    ;
    ; MSG_VIS_TEXT_GET_TEXT_RANGE Documentation:
    ; ------------------------------------------
    ; Both the TRDBI_file and the TRDBI_group fields must be filled in if
    ; you want a VM block to be allocated. 
    ;
    ; If the TRDBI_group field is set to DB_UNGROUPED then the item will be
    ; allocated ungrouped. TRDBI_group will hold the group in which the
    ; item was allocated on return.
    ;
    ; If VTGRF_RESIZE is passed then either the passed db-item or the allocated
    ; db-item will be resized to accomodate the text.
    ;
TextReferenceDBItem	ends

TRT_HUGE_ARRAY		enum	TextReferenceType
TextReferenceHugeArray	struct
    TRHA_file		hptr
    TRHA_array		word
    ;
    ; MSG_VIS_TEXT_GET_TEXT_RANGE Documentation:
    ; ------------------------------------------
    ; The TRHA_file field must be set if you want a huge-array to be 
    ; allocated.
    ;
    ; It does not make sense to pass VTGRF_RESIZE when the text reference is
    ; a huge-array. The huge-array will always be forced to be the correct
    ; size for the text.
    ;
TextReferenceHugeArray	ends

;
; A union containing all the various references.
;
TextReferenceUnion	union
    TRU_pointer		TextReferencePointer
    TRU_segChunk	TextReferenceSegmentChunk
    TRU_blockChunk	TextReferenceBlockChunk
    TRU_block		TextReferenceBlock
    TRU_vmBlock		TextReferenceVMBlock
    TRU_dbItem		TextReferenceDBItem
    TRU_hugeArray	TextReferenceHugeArray
TextReferenceUnion	end

;
; The typed reference
;
TextReference	struct
    TR_type	TextReferenceType
    TR_ref	TextReferenceUnion
TextReference	ends

VisTextReplaceFlags	record
    VTRF_FILTER:1		;Set to filter replacement
    VTRF_KEYBOARD_INPUT:1	;Set if data is coming from the kbd input
    VTRF_USER_MODIFICATION:1	;Set if replace is due to a user action
    VTRF_UNDO:1			;Set if replace is due to an undo
    VTRF_DO_NOT_SEND_CONTEXT_UPDATE:1	;Set if this is part of a
    					; multi-part replace, and so the
					; text object should not send a 
					; context update (used internally
					; to the text object only)
    VTRF_TRUNCATE:1		;Set to truncate inserted text as necessary
				; to fit in available space.
    :10
VisTextReplaceFlags	end

;
; This is the structure that is passed to MSG_VIS_TEXT_REPLACE.
;
VisTextReplaceParameters	struct
	;
	; The VisTextRange *must* come first in this structure
	;
    VTRP_range		VisTextRange		; Range to replace

    VTRP_insCount	dword			; # of characters to insert.
    VTRP_textReference	TextReference		; Reference to text to insert
    VTRP_flags		VisTextReplaceFlags
    align	word
VisTextReplaceParameters	ends

;
; It is possible to ask the text object to compute the length of the text
; being inserted by passing the following constant in the high word of the
; VTRP_insCount field.
;
INSERT_COMPUTE_TEXT_LENGTH	=	0x01ff

VTRP_pointerReference  equ <VTRP_textReference.TR_ref.TRU_pointer.TRP_pointer>

MSG_VIS_TEXT_GET_TEXT_RANGE	message
;
; Get a range of text from the text object. The buffer must be able to hold
; the number of bytes requested. The caller is responsible for making sure
; that this is the case. It is legal to ask for more characters than actually
; exist in the text object.
;	The returned string is null terminated in every case except
;	when the user requests the string in a huge-array.
;
;	PASS:	ss:bp	= VisTextGetTextRangeParameters
;	RETURN:	dx.ax	= Number of characters in the returned string, not
;			  counting any NULL terminator.
;		cx/bp	= Depends on the TextReferenceType and allocation flags
;		    TRT_POINTER		- destroyed
;		    TRT_SEGMENT_CHUNK	- cx = allocated chunk handle
;		    TRT_OPTR		- cx = allocated chunk handle
;		    TRT_BLOCK		- cx = allocated block handle
;		    TRT_VM_BLOCK	- cx = allocated vm block handle
;		    TRT_DB_ITEM		- cx = group, bp = item
;		    TRT_HUGE_ARRAY	- cx = allocated huge-array
;		 The string returned is null terminated in every case.
;

;
; These flags are part of the structure passed to MSG_VIS_TEXT_GET_TEXT_RANGE
;
VisTextGetTextRangeFlags	record
    VTGTRF_ALLOCATE:1
	;
	; Set:	 Allocate destination.
	; Clear: Use destintation provided
	;

    VTGTRF_ALLOCATE_ALWAYS:1
	;
	; Set:	 Allocate even if there is no text to copy.
	; Clear: Use destintation provided
	;

    VTGTRF_RESIZE_DEST:1
	;
	; Set: If possible resize the destination so that it is just
	;      large enough to hold the text and no larger.
	;
    :5
VisTextGetTextRangeFlags	end

;
; This is the structure passed to MSG_VIS_TEXT_GET_TEXT_RANGE
;
VisTextGetTextRangeParameters	struct
	;
	; The VisTextRange *must* come first in this structure
	;
    VTGTRP_range		VisTextRange	; Range to get
    
    VTGTRP_textReference	TextReference	; Reference to the text
    VTGTRP_flags		VisTextGetTextRangeFlags
    align	word
VisTextGetTextRangeParameters	ends

VTGTRP_pointerReference  equ <VTGTRP_textReference.TR_ref.TRU_pointer.TRP_pointer>

;
; It is important to know that if you pass the "allocate" or "allocate always"
; flags there are some fields that need to be filled in. These are documented
; in the various TextReference* structure definitions.
;

MSG_VIS_TEXT_SELECT_RANGE		message
;
;	Sets the selected area of the text to the passed range.
;
;	PASS:	ss:bp	= VisTextRange
;		dx	= Size of VisTextRange if called remotely
;	RETURN:	ax, cx, dx, bp - destroyed
;	COMPAT:	Can be used with all text objects.

MSG_VIS_TEXT_SHOW_POSITION		message
;
;	Display a position in the text on the screen.
;
;	Pass:	dx.cx	= Offset into the text to display.
;		This can be any of the special values for VTR_start.
;	Compat:	Can be used with all text objects
;

MSG_VIS_TEXT_SET_FILTER			message
;
;	Sets the current text filter.
;
;	Note: This does not affect any text that already exists in the text
;	      object. 
;	
;	Pass: CL - VisTextFilters
;	Return: nothing
;	Destroyed: ax, cx, dx, bp
;	Compat: Can be used with all text objects
;

MSG_VIS_TEXT_GET_FILTER			message
;
;	Gets the current text filter.
;	
;	Pass: nothing
;	Return: CL - VisTextFilters
;	Compat: Can be used with all text objects
;

MSG_VIS_TEXT_SET_OUTPUT			message
;
;	Sets the VTI_output field.
;
;	Pass: CX:DX - new optr
;	Return: nothing
;	Destroyed: ax, cx, dx, bp
;	Compat: Can be used with all text objects
;

MSG_VIS_TEXT_GET_OUTPUT			message
;
;	Gets the current VTI_output field.
;
;	Pass: nothing
;	Return: CX:DX - optr
;	Compat: Can be used with all text objects
;

MSG_VIS_TEXT_SET_LR_MARGIN			message
;
;	Sets the VTI_lrMargin field.
;	NOTE: Should not be used with GenText objects, as the specific UI
;	      likes to set this itself.
;
;	Pass: CL - new Left/Right margin
;	Return: nothing
;	Destroyed: ax, cx, dx, bp
;	Compat: Should not be used with Gen-based text objects;
;

MSG_VIS_TEXT_GET_LR_MARGIN			message
;
;	Gets the current VTI_lrMargin field.
;
;	Pass: nothing
;	Return: CL - current left/right margin
;	Compat: Should not be used with Gen-based text objects
;

MSG_VIS_TEXT_SET_TB_MARGIN			message
;
;	Sets the VTI_tbMargin field.
;	NOTE: Should not be used with GenText objects, as the specific UI
;	      likes to set this itself.
;
;	Pass: CL - new top/bottom margin
;	Return: nothing
;	Destroyed: ax, cx, dx, bp
;	Compat: Should not be used with Gen-based text objects
;

MSG_VIS_TEXT_GET_TB_MARGIN			message
;
;	Gets the current VTI_tbMargin field.
;
;	Pass: nothing
;	Return: CL - current top/bottom margin
;	Compat: Should not be used with Gen-based text objects
;

MSG_VIS_TEXT_REPLACE_WITH_HWR			message
;
;	Does HWR on the current text object.
;
; 	Pass: ss:[bp] - VisTextReplaceWithHWRParams
;

VisTextHWRFlags	record
	VTHWRF_NO_CONTEXT:1
	; This is sent when the ink is being quick-copied to the object, or
	; in other cases where the user did not draw the ink on top of the
	; object, and so the position of the object is not useful information
	; for the recognizer.

	VTHWRF_USE_PASSED_CONTEXT:1
	:14
VisTextHWRFlags	end

VisTextReplaceWithHWRParams	struct
	VTRWHWRP_range		VisTextRange

	VTRWHWRP_flags		VisTextHWRFlags
	VTRWHWRP_ink		hptr.InkHeader
	;Call MemDecRefCount on ink block when done

	VTRWHWRP_context	HWRContext
VisTextReplaceWithHWRParams	ends


MSG_VIS_TEXT_SET_HWR_CONTEXT			message
;
;	This sets up the context for the current handwriting recognition
;	attempt. This allows the specific UI to set up the context depending
;	upon what is visible.
;
;	NOTE: If you want to set your own context, do not pass this message
;	      to the superclass, as the VisText handler resets the context
;	      to "none".
;
;	Pass: nothing
;	Returns: nothing
;	Destroys: ax, cx, dx, bp
;
;

MSG_VIS_TEXT_SET_HWR_FILTER			message
;
;	Sets up the filter for the current handwriting recognition attempt.
;	This allows an app writer to set up his own custom filters instead.
;
;	Pass: nothing
;	Returns: nothing
;	Destroys: ax, cx, dx, bp
;

MSG_VIS_TEXT_SET_SELECTED_TAB	message
;
; Set the position of the selected tab.
;
; Pass:
;	cx - position (13.3), -1 for none
; Return:
;	none

MSG_VIS_TEXT_GET_TEXT_SIZE	message
;
; Get the length of the text
;
; Pass:
;	none
; Return:
;	dxax - text length (number of chars)

;------------------------------------------------------------------------------

MSG_VIS_TEXT_INVALIDATE_RANGE	message
;
; Invalidate a range in a suspended object or else force recalculation of
; the range in an active object.
;	PASS:	dx:bp	= VisTextRange
;

MSG_VIS_TEXT_ATTRIBUTE_CHANGE	message
;
; The text object sends this message to itsself when it is changing its
; attributes.

;------------------------------------------------------------------------------

MSG_VIS_TEXT_GET_LINE_INFO	message
;
; Get line and field information associated with a given line of the
; text object.
;	PASS:	dx:bp	= VisTextGetLineInfoParameters
;	RETURN:	Buffer filled with line info
;		cx	= Number of bytes actually copied
;		carry set if there is no such line
;	Destroyed: ax, cx, dx, bp
;

MAX_LINE_INFO_SIZE	equ	size LineInfo + (VIS_TEXT_MAX_TABS * size FieldInfo)
VisTextGetLineInfoParameters	struct
    VTGLIP_buffer	fptr.LineInfo	; Pointer to buffer to use
	;This method handler will return a LineInfo structure followed by
	; a number of FieldInfo structures, depending upon how many tabs
	; are in the line.
    VTGLIP_bsize	word		; Size of buffer
    VTGLIP_line		dword		; Line to get information for
VisTextGetLineInfoParameters	ends

;------------------------------------------------------------------------------

;
; This is what is stored with each name in the ElementArray.
;

VisTextNameArrayElement	struc
    VTNAE_meta	NameArrayElement
    VTNAE_data	VisTextNameData
VisTextNameArrayElement	ends

;
; Maximum size of a name array element plus 1 so that, in a buffer of
; this size, there's always space to null-terminate the name after
; getting the element.
;
MAX_VIS_TEXT_NAME_ARRAY_ELT_SIZE	equ	(NAME_ARRAY_MAX_NAME_SIZE+ \
						(size VisTextNameArrayElement)+1)

VisTextNameCommonFlags	record
	VTNCF_COLOR_MONIKERS_FOR_UNSET_CONTEXTS:1
						; SET: use green gstring
						;  monikers for context
						;  names not yet applied
						; CLEAR: use a regular text
						;  moniker for all names
	VTNCF_DISABLE_MONIKERS_FOR_SET_CONTEXTS:1
						; SET: disable monikers
						;  for context names
						;  applied to text
	:6
VisTextNameCommonFlags	end

VisTextNameCommonParams	struct
    VTNCP_data		VisTextNameData	;type (context or file) & file
    VTNCP_index		word		;index of name
    VTNCP_object	optr		;OD of text or list object
    VTNCP_message	word		;message to send to object
    VTNCP_flags		VisTextNameCommonFlags
					;flags for some of the messages
					; that use this structure
    even
VisTextNameCommonParams	ends

MSG_VIS_TEXT_DEFINE_NAME		message
;
;	Define a new name (context or file)
;
;	Pass:	dx - size (VisTextNameCommonParams)
;		ss:bp - VisTextNameCommonParams
;		    VTNCP_data - type and associated file
;		    VTNCP_object - text object with name
;

;---

MSG_VIS_TEXT_DELETE_NAME		message
;
; Delete a name (context or file)
;
;	Pass:	ss:bp VisTextNameCommonParams
;		dx - size (VisTextNameCommonParams)
;		   VTNCP_data - type and associated file
;		   VTNCP_index - index of name in list
;

;---

MSG_VIS_TEXT_RENAME_NAME		message
;
; Rename a name (context or file)
;
;	Pass:	dx - size (VisTextNameCommonParams)
;		ss:bp VisTextNameCommonParams
;		   VTNCP_data - type and associated file
;		   VTNCP_index - index of name in list
;		   VTNCP_object - text object with new name
;

;---

MSG_VIS_TEXT_UPDATE_NAME_LIST	message
;
; Update a list of names
;
;	Pass:	dx - size of VisTextNameCommonParams (if remote call)
;		ss:bp - VisTextNameCommonParams
;		    VTNCP_data - type and associated file
;		    VTNCP_object - list object to update
;

;---

MSG_VIS_TEXT_GET_NAME_LIST_MONIKER	message
;
; Get a moniker for a name list
;
;	Pass:	dx - size of VisTextNameCommonParams (if remote call)
;		ss:bp - VisTextNameCommonParams
;		    VTNCP_data - type and associated file
;		    VTNCP_index - index of name in list
;		    VTNCP_object - list object to update
;

;---

MSG_VIS_TEXT_FOLLOW_HYPERLINK		message
;
; Follow the selected hyperlink
;
; NOTE: if the selection includes more than one hyperlink, the run at
; the start of the selection is used
;
;	Pass	dx - size of VisTextFollowHyperlinkParams (if remote call)
;		ss:bp - VisTextFollowHyperlinkParams
;

VisTextFollowHyperlinkParams	struct
    VTFHLP_range	VisTextRange		;range
VisTextFollowHyperlinkParams	ends


MSG_VIS_TEXT_GET_LINE_FROM_OFFSET	message
;
; Return the line number given an offset into the text
;
; 	PASS:	cx:dx - offset
;	RETURN: dx:ax - line number
;		cx:bp - offset of start of line (in ASM only)
;

MSG_VIS_TEXT_GET_LINE_OFFSET_AND_FLAGS	method
;
; Get the offset where a line starts and the LineFlags associated with
; that line.
;	PASS:	dx:bp	= VisTextGetLineOffsetAndFlagsParameters
;	RETURN:	Buffer filled in
;		carry set if the line does not exist
;		cx, dx, bp preserved
;
VisTextGetLineOffsetAndFlagsParameters	struct
    ;
    ; Pass the line
    ;
    VTGLOAFP_line	dword		; Line to get info for
    ;
    ; Get returned these
    ;
    VTGLOAFP_offset	dword		; Offset to line start
    VTGLOAFP_flags	LineFlags	; LineFlags
VisTextGetLineOffsetAndFlagsParameters	ends

;---

MSG_VIS_TEXT_GET_TEXT_POSITION_FROM_COORD			message
;
; Get the nearest character position to the specified coordinate.
;
;	PASS:	ss:bp - PointDWFixed to check
;	RETURN:	ss:bp - nearest valid X and Y positions replacing
;			  the position of the event
;		dx:ax - nearest character position
;

;---

MSG_VIS_TEXT_GET_NAME_LIST_NAME_TYPE	message
;
; Get and update the type for a name in a name list
;
;	PASS:	dx - size of VisTextNameCommonParams (if remote call)
;		ss:bp - VisTextNameCommonParams
;		    VTNCP_data - type and associated file
;		    VTNCP_index - index of name in list
;		    VTNCP_object - list object to update
;	RETURN:	none
;

MSG_VIS_TEXT_CROSS_SECTION_REPLACE_ABORTED	message
;
; Notification that a cross section change has been aborted (sent by the
; text object to itsself)
;
; Pass:
;	none
; Return:
;	none


MSG_VIS_TEXT_SET_SPELL_IN_PROGRESS	message private
MSG_VIS_TEXT_SET_SEARCH_IN_PROGRESS	message private
;
;	Basically just sets the "Search/Spell in progress" flag.
;
;	Pass: nothing
;	Returns: nothing
;	Destroyed: ax, cx, dx, bp

MSG_VIS_TEXT_LOAD_FROM_DB_ITEM_FORMAT	message
;
; Loads a text object with data that had been previously saved to a DB item.
; This allows things (like the help control) to compact the DB item produced
; by MSG_VIS_TEXT_SAVE_TO_DB_ITEM, then uncompact/load it.
;
; Pass: cx:dx - ptr to data to load
; Return: nothing
; Destroyed: ax, cx, dx, bp
;

MSG_VIS_TEXT_GET_RUN_BOUNDS		message
;
; Gets the bounds of the run that starts at or before the passed position
;
; Pass: ss:bp - VisTextGetRunBoundsParams
; Return: VisTextRange pointed to by ss:[bp].VTGRBP_retVal - filled in
; Destroyed: ax, cx, dx, bp
;

OFFSET_FOR_TYPE_RUNS	equ	0
OFFSET_FOR_GRAPHIC_RUNS equ	1

VisTextGetRunBoundsParams	struct
	VTGRBP_position	dword
	; Position to check for run around

	VTGRBP_type	word
	; Run offset

	VTGRBP_retVal	fptr.VisTextRange
	; Ptr to VisTextRange to fill in with the bounds of the run
VisTextGetRunBoundsParams	ends

protominor TextNewForZoomer

MSG_VIS_TEXT_FREE_ALL_STORAGE		message
;
; Superset of MSG_VIS_TEXT_FREE_STORAGE.  Also frees text storage and line
; structures storage.
;
; NOTE:  This message was added 6/17/93
;
; Pass:
;	cx - non-zero to remove element arrays also
; Return:
;	none

protoreset

MSG_VIS_TEXT_GENERATE_CURSOR_POSITION_NOTIFICATION      message
;
; Generate cursor position notification.
;
; Pass:
;       none
; Return:
;       none
;

MSG_VIS_TEXT_GET_SELECTION_START        message
;
; Get the selection start.
;
; Pass:         nothing
;
; Return:       dx:cx   = Selection start
;

MSG_VIS_TEXT_GET_GSTATE message
;
; Get the gstate of the text object's window.
;
; Pass:         nothing
;
; Return:       cx      = gstate
;
;

MSG_VIS_TEXT_GET_FEP_BOUNDS     message
;
; Get the cursor position in document coordinates.  (PIZZA only)
;
; Pass:		ss:bp	= FepTempTextBoundsInfo to fill in
;
; Return:	ss:bp	= FepTempTextBoundsInfo filled in
;		    FTTBI_bounds		;text bounds: A(x,y) to C(x,y)
;		    FTTBI_textOffset		;text offset: B(x,y)
;		    FTTBI_baselineOffset	;baseline: baseline of "The..."
;		    FTTBI_layerID		;layer ID of window
;               CF      = 1 iff bounds invalid
;

protominor TextNewForHelpEditor		; Condo related stuff

MSG_VIS_TEXT_DELETE_ALL_HYPERLINKS	message
;
; Delete all the hyperlinks in the passed text range
;
; Pass:		ss:bp - VisTextSetHyperlinkParams, with
;			VTSHLP_range holding virtual bounds of range
; Return:	VTSHLP_range holds physical bounds
;

MSG_VIS_TEXT_UNSET_ALL_CONTEXTS		message
;
; Unset all the text -> context mappings in the passed text range
;
; Pass:		ss:bp - VisTextSetContextParams, with 
;			VTSCXP_range holding virtual bounds of range
; Return:	VTSCXP_range holds physical bounds
;

VisTextConvertOffsetParams	struct
    VTCOP_offset	dword	; pass: text offset to convert
				; return: offset of returned position
    VTCOP_xPos		sdword	; return: x position of offset
    VTCOP_yPos		sdword	; return: y position of offset
VisTextConvertOffsetParams	ends

MSG_VIS_TEXT_CONVERT_OFFSET_TO_COORDINATE	message
;
; Convert an offset into the text into its document coordinate.  If the
; passed offset is beyond the end of the text, it will be updated to the
; last valid offset and the coordinate of that offset will be returned.
;
; Pass:		dx:bp - VisTextConvertOffsetParams with offset filled in
; Return: 	VisTextConvertOffsetParams filled in
; Destroyed:	ax, cx, dx
;		

protoreset

;---

protominor TextNewForCondo		; more Condo stuff

MSG_VIS_TEXT_SET_HYPERLINK_TEXT_STYLE	message
;
; Set or clear a style on all hyperlinks in a range of text.
;
; Pass:		ss:bp - VisTextSetTextStyleParams
; Return:	nothing
; Destroyed:	ax, bx, cx, dx, di
;

VisTextUpdateGraphicFlags	record
    VTUGF_RECALC:1			; recalc and redraw text after update
    VTUGF_NEW_ELEMENT:1			; If the graphic being updated has
					; multiple references, create a new
 					; element for this run instead of
					; changing the original.
	:14
VisTextUpdateGraphicFlags	end

VisTextUpdateGraphicElementParams	struct
    VTUGEP_position	dword			; graphic's position in text
    VTUGEP_graphic	VisTextGraphic		; new graphic
    VTUGEP_flags	VisTextUpdateGraphicFlags
VisTextUpdateGraphicElementParams	ends


UpdateGraphicReturnValue	etype word
;
; No errors occurred, and the element was updated
;
    UGRV_MODIFIED_ELEMENT			enum UpdateGraphicReturnValue
	; The graphic element's data was replaced with the passed data

    UGRV_CREATED_NEW_ELEMENT			enum UpdateGraphicReturnValue
	; A new graphic element was created using the passed data, and the
	; old element was left untouched
;
; Errors occurred, so the element was not updated
;
    UGRV_INVALID_GRAPHIC_TYPE			enum UpdateGraphicReturnValue
	; The passed VTG_type field contains an invalid value

    UGRV_INVALID_GRAPHIC_FLAGS			enum UpdateGraphicReturnValue
	; The passed VTG_flags field contains an invalid value

    UGRV_INVALID_GSTRING_SIZE			enum UpdateGraphicReturnValue
	; The passed VTG_size field contains an invalid value.
	; A gstring graphic cannot have zero size.

    UGRV_INVALID_GSTRING_VMCHAIN_HANDLE		enum UpdateGraphicReturnValue
	; The passed VTG_vmChain.high field contains an invalid value.
	; This field should contain the VMBlock handle for a VMChain.

    UGRV_INVALID_GSTRING_VMCHAIN		enum UpdateGraphicReturnValue
	; The passed vmChain contains invalid data

    UGRV_INVALID_VARIABLE_TYPE			enum UpdateGraphicReturnValue
	; The passed variable graphic type is invalid

    UGRV_INVALID_VARIABLE_VMCHAIN_HANDLE	enum UpdateGraphicReturnValue
	; The passed VTG_vmChain field is non-zero, but for a
	; variable graphic it should be zero.

    UGRV_INVALID_VARIABLE_MANUFACTURER_ID	enum UpdateGraphicReturnValue
	; The value in VTG_data.VTGD_variable.VTGV_manufacturerID is invalid

    UGRV_INVALID_VARIABLE_PRIVATE_DATA		enum UpdateGraphicReturnValue
	; The values in VTG_data.VTGD_variable.VTGV_privateData do not
	; match the expected data types.


MSG_VIS_TEXT_UPDATE_GRAPHIC_ELEMENT		message
;
; Updates the VisTextGraphic element for the graphic run at the passed 
; position with the new graphic data (does not copy VTG_meta).  
;
; Be careful when changing the VTG_vmChain field, or modifying the
; old VMChain.  Multiple runs may point to the same graphic element,
; and if it is modified or replaced, all of those runs will take
; on the characteristics of the new graphic, unless the VTUGF_NEW_ELEMENT 
; flag is passed.  This flag will cause a new element to be created
; for this run if the original graphic is used by more than 1 run.
;
; If the VTUGF_NEW_ELEMENT flag is passed, the VMChain in the new 
; graphic must be a new VMChain, which is in the text object's file.
; The caller should never free the old VMChain when this flag is passed.
; 
; If the VTUGF_NEW_ELEMENT flag is not passed, the caller can modify
; or replace the old VMChain.  If replacing it (if the passed VTG_vmChain
; field differs fromt the original graphic element's VTG_vmChain field),
; the new VMChain must be in the same file as the old one (the text
; object's file).  The caller should free the old VMChain if the return
; value is UGRV_MODIFIED_ELEMENT and a new VMChain was passed in VTG_data.
;
;	Pass:	ss:bp - VisTextUpdateGraphicElementParams
;	Return:	ax - UpdateGraphicReturnValue
;

protoreset

;---

protominor TextNewForPizza

MSG_VIS_TEXT_SET_TEXT_MISC_MODE			message MetaTextMessages
;
;	Set: paragraph-level text misc mode flags.
;	(currently only word- vs. character-level justification)
;	(currently only supported in DBCS)

if DBCS_PCGEOS
VisTextSetTextMiscModeParams	struct
    VTSTMMP_range		VisTextRange
    VTSTMMP_miscMode		TextMiscModeFlags
	even
VisTextSetTextMiscModeParams	ends
endif

protoreset

;---

protominor TextNewerForCondo		; yet more Condo stuff

MSG_VIS_TEXT_NAME_TOKENS_TO_LIST_INDICES	message
;
; Convert the name tokens in a VisTextType structure to their list indices.
;
; Pass: 	ss:bp - VisTextNotifyTypeChange
; 			VTNTC_type filled with name tokens
; Return:	VTNTC_index filled with corresponding indices
;

;---

MSG_META_TEXT_SET_HYPERLINK			message MetaTextMessages
;
; Context:	Sent to set a hyperlink on a range of text associated with
; 		the recipient object.
; Source:	Hyperlink controller
; Destination:	Text object or any object embedded in the text.
; Interception: Default behavior is to set a hyperlink on the currently
;		selected range of text. In order for an object embedded
;		in the text to be hyperlinkable, it must intercept

;		this message, alter the VTSHLP_range field of the
;		passed VisTextSetHyperlinkParams to specify the position
;		of its associated C_GRAPHIC character, and then pass
;		the message on to the text object.
; Pass:		ss:bp - VisTextSetHyperlinkParams
; Return:	nothing
;

MSG_META_TEXT_FOLLOW_HYPERLINK			message MetaTextMessages
;
; Context:	Sent to follow a hyperlink on a range of text associated with
; 		the recipient object.
; Source:	Hyperlink controller
; Destination:	Text object or any object embedded in the text.
; Interception: Default behavior is to follow a hyperlink on the currently
;		selected range of text. In order for a hyperlink on an
;		object embedded in the text to be followable, the object must
;		intercept this message, alter the VTFHLP_range field of the
;		passed VisTextFollowHyperlinkParams to specify the position
;		of its associated C_GRAPHIC character, and then pass
;		the message on to the text object.
; Pass:		ss:bp - VisTextFollowHyperlinkParams
; Return:	nothing
;

;---

MSG_VIS_TEXT_FIND_NAME_BY_INDEX		message
;
;	Return the data for a name token
;
;	Pass:	ss:bp - VisTextFindNameIndexParams
;	Return:	ax - token for index, or CA_NULL_ELEMENT if 
;			name was not found
;		name buffer filled
;	Compat:	This method cannot be used on a text object that does not have
;		multiple types
;
VisTextFindNameIndexParams	struct
    VTFNIP_index	word		;index of name to find
    VTFNIP_type		VisTextNameType	;type of name
    VTFNIP_file		word		;index of file, if VTNT_CONTEXT
    VTFNIP_name		fptr.char	;buffer of size NameArrayMaxElement
VisTextFindNameIndexParams	ends

protoreset

;---

protominor	TextNewFor2_1

MSG_VIS_TEXT_REGION_FROM_POINT	message
; Get the region associated with a given point.
;
; NOTE: There is a MSG_VIS_LARGE_TEXT_REGION_FROM_POINT, but this message
; will work with both VisText and VisLargeText objects.
;
; Context:	Called to determine if a point is in a region, and if so, what
;		region number it is.
; Source:	GLOBAL
; Destination:  Any VisText or VisLargeText object
; Interception: Not necessary
;
; Pass:
;	ss:bp	= PointDWFixed
;			
; Return:
;	cx	= region #
;	ax	= relative X position
;	dx	= relative y position
;
;	bp - unchanged
;	none - destroyed
;

protoreset

;---

protominor	TextEvenNewerForCondo

MSG_VIS_TEXT_GET_NAME_LIST_MONIKER_FRAME	message
;
; Gets a moniker for a name in the name list and uses a specified
; message to pass it in a ReplaceItemMonikerFrame structure to a
; specified object. Gets a text moniker for any name unless passed
; the VTNCF_COLOR_MONIKERS_FOR_UNSET_CONTEXTS flag, in which case
; gets a text moniker for everything except context names not yet
; assigned to pages - for those, gets a light green gstring moniker.
;
; Context:	Sent to get a name list moniker when the moniker should be
; 		passed with a particular message to a particular object. If
; 		one would like to get a regular text moniker and pass it
; 		with MSG_GEN_DYNAMIC_LIST_REPLACE_ITEM_TEXT to a
; 		dynamic list, one should use the simpler
;		MSG_VIS_TEXT_GET_NAME_LIST_MONIKER instead of
;		MSG_VIS_TEXT_GET_NAME_LIST_MONIKER_FRAME.
; Source:	Hyperlink controller
; Destination:	Text object
; Interception: Not generally intercepted
; Pass:		ss:bp - VisTextNameCommonParams
;			VTNCP_data	- type (context/file) &
;					   associated file
;			VTNCP_index	- index of name
;			VTNCP_object	- object to update
;			VTNCP_message	- message to send to object
;			VTNCP_flags	- color unset context names?
;		Passed to message:
;			dx	- size of ReplaceItemMonikerFrame
;			ss:bp	- ReplaceItemMonikerFrame with the
;				   RIMF_source and RIMF_item fields
;				   appropriately set and either
;
;					RIMF_sourceType	= VMST_FPTR
;					RIMF_dataType 	= VMDT_TEXT
;					RIMF_length	= 0
;					RIMF_itemFlags	= 0
;				    or
;					RIMF_sourceType	= VMST_OPTR
;					RIMF_dataType 	= VMDT_GSTRING
;					RIMF_length	= 0
;					RIMF_width	= gstring width
;					RIMF_height	= gstring height
;					RIMF_itemFlags	= 0
; Return:	nothing
;

protoreset

protominor	TextNew2ForPizza

MSG_VIS_TEXT_GET_SINGLE_CHAR_ATTR		message
;
; Get the VisTextCharAttr at the specified offset.  This is different
; than MSG_VIS_TEXT_GET_CHAR_ATTR in that it works on an offset only
; rather than a range, but on the other hand it checks for large text
; objects that happen to be in VLTDM_DRAFT_WITHOUT_STYLES mode and
; returns the appropriate character attributes.
;
;	Pass:	ss:bp - ptr to VisTextCharAttr buffer
;		dx:cx - offset in text
;	Return:	buffer - filled
;		dx:ax - # of consecutive chars (may be TEXT_ADDRESS_PAST_END)
;		cx - destroyed
;	Compat:	Can be used with all text objects
;

protoreset

protominor	TextNew4ForCondo

MSG_VIS_TEXT_SET_CONTEXT_GIVEN_NAME_TEXT	message
;
; Queries the passed object for a name, which should be a context name
; in the current file, and uses that name to set a context on the
; passed range of text. If the name is new, adds it to the name
; array before setting the context. If the name is not that of a
; context in the current file, displays an error message.
;
; Context:	Sent in place of MSG_VIS_TEXT_SET_CONTEXT when the
; 		index or token for the context is not available,
; 		possibly because the name is not yet defined.
; Source:	Hyperlink controller
; Destination:	Text object
; Interception: May be intercepted to query the passed object
; 		for the name string if necessary. For other purposes,
; 		it's probably better to intercept MSG_VIS_TEXT_SET_CONTEXT.
; Pass:		ss:bp	= VisTextSetContextParams
;			VTSCXP_range	- range over which to set context
;			VTSCXP_flags	- VTCF_REDIRECT_HYPERLINKS if desired
;			VTSCXP_object	- object holding name
; Return:	nothing
;

MSG_VIS_TEXT_REDIRECT_HYPERLINKS	message
;
; Redirects hyperlinks pointing to a particular file and context pair
; to point to another.
;
; Context:	Sent to make one file/context pair take over another's duties.
; Source:	Hyperlink controller or text object
; Destination:	Text object
; Interception:	May be intercepted.
; Pass:		ss:bp	= VisTextRedirectHyperlinksParams
; Return:	nothing
;

VisTextRedirectHyperlinksParams	struct
	VTRHP_range		VisTextRange
	VTRHP_oldFile		word		; old file (index or token)
	VTRHP_oldContext	word		; old context (index or token)
	VTRHP_newFile		word		; new file (index or token)
	VTRHP_newContext	word		; new context (index or token)
	VTRHP_flags		VisTextSetContextFlags
						; VTCF_TOKEN set if
						;  data are tokens
	even
VisTextRedirectHyperlinksParams	end

protoreset

protominor TemplateWizard

MSG_VIS_TEXT_RETURN_SELECTION_BLOCK	message
;
; Allows objects run by ui-thread to get the selected text.
; The requesting object will be called back with the passed
; message and given the selected text in a global memory
; block whose handle will be in 'cx'.
;
; Pass:	^lcx:dx	= object requesting selected text
;	bp	= message to send to requesting object
;

protoreset

protominor TextNewForGPC

MSG_VIS_TEXT_PREP_FOR_QUICK_TRANSFER	message
;
; Does common prep work for subclasses of VisText that want to specially
; handle MSG_VIS_TEXT_REPLACE_WITH_TEXT_TRANSFER_FORMAT do do interesting
; things when pasting
;
; Context:     Send to self in MSG_VIS_TEXT_REPLACE_WITH_TEXT_TRANSFER_FORMAT
; Source:      Self
; Destination: Self
; Interception: Not normally intercepted
;
; Pass:		ss:bp - ptr to CommonTransferParams
; Return:       carry - set if paste will fail
;

protoreset

;------------------------------------------------------------------------------
;	EXTERNAL state bits in the instance data
;------------------------------------------------------------------------------

; Some of these state bits can be changed at any time, others must be set
; set initially and cannot be changed.

; VisTextFeatures reflect whether various features are enabled in the text
; object

VisTextFeatures	record
    VTF_NO_WORD_WRAPPING:1		; Set: no word-wrapping is desired.
    VTF_AUTO_HYPHENATE:1		; Set: if we want to auto hyphenate.
    VTF_ALLOW_SMART_QUOTES:1		; Set: allows smart quotes if they are
    					;      enabled.
    VTF_ALLOW_UNDO:1			; Set: allows undo in this object
    VTF_SHOW_HIDDEN_TEXT:1		; Set: Show text marked as hidden
					;	*** Not implemented ***
    VTF_OUTLINE_MODE:1			; Set: show text in outline mode
					;	*** Not implemented ***
    VTF_DONT_SHOW_SOFT_PAGE_BREAKS:1	; Set: don't display soft (non
					;      C_PAGE_BREAK) page breaks in
					;      VisLargeTextDisplayModes
					;      VTLDM_GALLEY and above
    VTF_DONT_SHOW_GRAPHICS:1		; Set: draw graphics as gray rectangles
					;	*** Not implemented ***
    VTF_TRANSPARENT:1			; Set: don't use wask color on DRAW
    VTF_USE_50_PCT_TEXT_MASK:1		; Set: force 50% draw mask for drawing,
					;      regardless of char attr runs. 
					;      Used by specific GenText objects.
    :6
VisTextFeatures	end

; VisTextStates reflect various states of the text object

VisTextStates	record
    VTS_EDITABLE:1			; Set: text is editable.
    VTS_SELECTABLE:1			; Set: text is selectable.
    VTS_TARGETABLE:1			; Set: object is targetable.
    VTS_ONE_LINE:1			; Set: object is limited to one line.
    VTS_SUBCLASS_VIRT_PHYS_TRANSLATION:1 ; Set: send virtual to physical
					;       charAttr/paraAttr translation
					;	messages to self (for subclass)
    VTS_OVERSTRIKE_MODE:1		; Set: Overstrike mode (not ins mode)
    VTS_USER_MODIFIED:1			; Set: text has changed.
    :1
VisTextStates	end

;------------------------------------------------------------------------------
;	INTERNAL state bits in the instance data
;------------------------------------------------------------------------------

; The following bits reflect the internal state of the text object.  These
; bits should not be altered.

; VisTextIntSelFlags reflect the selection state of the text object.

SelectionType	etype	byte
ST_DOING_CHAR_SELECTION	enum SelectionType
ST_DOING_WORD_SELECTION	enum SelectionType
ST_DOING_LINE_SELECTION	enum SelectionType
ST_DOING_PARA_SELECTION	enum SelectionType

VisTextIntSelFlags	record
    VTISF_IS_TARGET:1			; Set if the object is the target.
    VTISF_IS_FOCUS:1			; Set if the object is the focus.
    VTISF_CURSOR_ON:1			; Set if the cursor is drawn.
    VTISF_CURSOR_ENABLED:1		; Set if the cursor is enabled.
    VTISF_DOING_SELECTION:1		; Set if we are doing some selection.
					; (Basically if the mouse is down).
    VTISF_DOING_DRAG_SELECTION:1	; Set if we have positioned the cursor.
					; (also doubles as flag that indicates
					;  we are doing quick-transfer feedback)
    VTISF_SELECTION_TYPE	SelectionType:2
VisTextIntSelFlags	end

;-

; VisTextIntFlags reflects the general internal state of the object

AdjustType	etype	byte, 0, 1
AT_NORMAL	enum	AdjustType	; Keep this one as the first one (= 0)
AT_PASTE	enum	AdjustType
AT_QUICK	enum	AdjustType

ActiveSearchSpellType	etype	byte, 0, 1
ASST_NOTHING_ACTIVE		enum	ActiveSearchSpellType ;Must be first
ASST_SPELL_ACTIVE		enum	ActiveSearchSpellType
ASST_SEARCH_ACTIVE		enum	ActiveSearchSpellType

VisTextIntFlags	record
    VTIF_HAS_LINES:1		;Set if object has valid line structures.
    VTIF_SUSPENDED:1		;Set if calculation suspended
    VTIF_UPDATE_PENDING:1	;Set if an update is about to be delivered.
    VTIF_ACTIVE_SEARCH_SPELL ActiveSearchSpellType:2
				;Set if a search/spell session is in progress.
    VTIF_HILITED:1		;Set: We have drawn the hilite.
    VTIF_ADJUST_TYPE	AdjustType:2	; How to adjust the selection.
VisTextIntFlags	end

;-

; GSRefCountAndFlags reflects the state of the cached gstate

GSRefCountAndFlags	record
    GSRCAF_USE_DOC_CLIP_REGION:1	;If set, then use GrSetDocClipRect
					;instead of GrSetClipRect
    GSRCAF_REF_COUNT:7
GSRefCountAndFlags	end

;------------------------------------------------------------------------------
;	Variable Instance data
;------------------------------------------------------------------------------

ATTR_VIS_TEXT_TYPE_RUNS		vardata	word
ATTR_VIS_TEXT_GRAPHIC_RUNS	vardata	word
ATTR_VIS_TEXT_STYLE_ARRAY	vardata	word
ATTR_VIS_TEXT_NAME_ARRAY	vardata	word

VisTextSuspendData	struct
    VTSD_count		word
    VTSD_recalcRange	VisTextRange	;range to recalculate
    VTSD_selectRange	VisTextRange	;range to select
    VTSD_showSelectionPos dword		;position to show
    VTSD_notifications	word
    VTSD_needsRecalc	BooleanByte
VisTextSuspendData	ends

ATTR_VIS_TEXT_SUSPEND_DATA	vardata VisTextSuspendData

ATTR_VIS_TEXT_NOTIFY_CONTENT		vardata

ATTR_VIS_TEXT_SELECTED_TAB	vardata word	;position of selected tab

ATTR_VIS_TEXT_DO_NOT_INTERACT_WITH_SEARCH_CONTROL	vardata
;
;	If set, these attrs keep the text object from sending 
;	GWNT_SEARCH_SPELL_ENABLE_CHANGE.

ATTR_VIS_TEXT_EXTENDED_FILTER	vardata	VisTextExtendedFilterType

ATTR_VIS_TEXT_CHAR_ATTR_INSERTION_TOKEN	vardata word
ATTR_VIS_TEXT_TYPE_INSERTION_TOKEN	vardata word

;
;	TEMPORARY VARDATA
;
;	NOTE: If you add any items here, add code in VisTextReloc to delete
;	the associated vardata, because apps like GeoWrite save the entire
;	object out (vardata and all), and reload them verbatim.
;

VisTextCachedRunInfo	struct
    VTCRI_lastCharAttrRun	dword
    VTCRI_lastParaAttrRun	dword
    VTCRI_lastTypeRun		dword
    VTCRI_lastGraphicRun	dword
VisTextCachedRunInfo	ends

TEMP_VIS_TEXT_CACHED_RUN_INFO	vardata	VisTextCachedRunInfo

TEMP_VIS_TEXT_FORCE_SEND_IS_LAST_REGION	vardata

VisTextCachedUndoInfo	struct
	VTCUI_vmChain	dword
	VTCUI_file	hptr
VisTextCachedUndoInfo	ends

TEMP_VIS_TEXT_CACHED_UNDO_INFO		vardata	VisTextCachedUndoInfo


VisTextCustomFilterData	struct
	VTCFD_startOfRange	word
	VTCFD_endOfRange	word
VisTextCustomFilterData	ends

ATTR_VIS_TEXT_CUSTOM_FILTER		vardata	lptr.VisTextCustomFilterData
;
;	This should contain the handle of a chunk containing an array of
;	VisTextCustomFilterData structures. Each structure corresponds to a
;	range of characters that the app wants to filter out.
;

ATTR_VIS_TEXT_UPDATE_VIA_PROCESS	vardata
;
;	Indicates that status updates must be sent via the process object
;	because there are targetable text objects in multiple threads
;

ATTR_VIS_TEXT_DOES_NOT_ACCEPT_INK	vardata
;
;	When present, the VisText object will not accept ink.
;

ATTR_VIS_TEXT_MINIMUM_SINGLE_LINE_HEIGHT	vardata	WBFixed
;
;	For a one-line object, lets the object override the default line
;	height, so graphics, etc can be put inside it.
;

TEMP_VIS_TEXT_SYS_TARGET	vardata

protominor TextNewForZoomer

ATTR_VIS_TEXT_SEND_CONTEXT_NOTIFICATIONS_EVEN_IF_NOT_FOCUSED	vardata
;
;	This sends out context notifications even if the object is
;	not focused. Apps should beware when using this, to make sure
;	the object that this is on does *not* get modified while another
;	text object has the focus.
;

ATTR_VIS_TEXT_DO_NOT_NOTIFY_CONTENT	vardata

protoreset




ATTR_VIS_TEXT_ADD_SPACE_ON_TOP_TO_FIRST_LINE_OF_REGION	vardata	word
;
;	This attribute causes vis-text (and gen-text) objects to add
;	additional spacing above the first line of the object.
;
;	This helps fix up accent glitch problems in Vis and Gen text
;	objects that aren't easily satisfied by the preceding ATTR_.
;
;	This attribute does not take effect if the paragraph on the
;	first line of the region contains a top-line border.
;
;	************************************************************
;	**** This ATTR may not be implemented on all systems.
;	**** It was added specifically to handle European characters
;	**** with accents. If I were to up the minor protocol for
;	**** users of this ATTR, then applications which used it might
;	**** not run on older systems, such as Zoomer-US. Therefore
;	**** the protocol does not change. This means that applications
;	**** which include this ATTR should continue to work on older
;	**** system software, though this attribute might not have any
;	**** effect
;	************************************************************
;

ATTR_VIS_TEXT_ADD_SPACE_TO_ALL_LINES		vardata	word
;
;	This attribute causes vis-text (and gen-text) objects to add
;	additional spacing above all lines of the object.
;
;	This attribute will take effect on *all* lines, including the
;	first line, and including any lines with borders on them.
;
;	This means that if you have a border around a paragraph, and
;	the object also has this hint, then the space between the
;	top/bottom border and the text will include any addition space
;	provided as part of this hint.
;
;	This attribute is intended to be added to objects where accent
;	characters are getting messed up by redraws on the previous
;	line, typically due to editing on that line. This may produce
;	funny line spacing, so use it with care.
;
;	************************************************************
;	**** This ATTR may not be implemented on all systems.
;	**** It was added specifically to handle European characters
;	**** with accents. If I were to up the minor protocol for
;	**** users of this ATTR, then applications which used it might
;	**** not run on older systems, such as Zoomer-US. Therefore
;	**** the protocol does not change. This means that applications
;	**** which include this ATTR should continue to work on older
;	**** system software, though this attribute might not have any
;	**** effect
;	************************************************************
;

ATTR_VIS_TEXT_NOTIFY_CURSOR_POSITION		vardata	word
;
;	This causes cursor position notifications to be sent out.
;	To improve proformance while quickly typing in text or quickly
;	moving the cursor through text, a threshold time is specified.
;	A new notification won't be sent out until the threshold time
;	has past since the last notification was sent.  The time is
;	specified in 1/60ths of a second.  A value of zero may be used
;	to send notification all the time.
;






TEMP_VIS_TEXT_NOTIFY_CURSOR_POSITION_TIME	vardata	dword

TVTNCPIData	struct
	TVTNCPID_handle	word
	TVTNCPID_id	word
TVTNCPIData	ends

TEMP_VIS_TEXT_NOTIFY_CURSOR_POSITION_INFO	vardata TVTNCPIData

TEMP_VIS_TEXT_FREEING_OBJECT		vardata
; This is added by the text object when it receives MSG_META_OBJ_FREE, to
; prevent it from sending out notifications while exiting.
;

TEMP_VIS_TEXT_UNDO_FOR_SUSPEND		vardata
; This is added by the text object when it receives MSG_META_SUSPEND, so it
; knows to encapsulate any subsequent undo actions in a single chain.


protominor	TextNewForQuickFax

ATTR_VIS_TEXT_DISABLE_OPTIMIZED_REDRAW	vardata
;
;	This attribute causes vis-text objects to NOT use optimized
;	redraw (ie bit-blt) when inserting text. This is useful when an
;	Ink object overlaps a VisText object (we don't want the ink to
;	be blitted down with the text).

protoreset

protominor	TextNewFor2_1

ATTR_VIS_TEXT_DONT_SHOW_POSITION_ON_GAINED_TARGET_EXCL	vardata
;
; This attribute causes the vis-text objects to NOT call
; MSG_VIS_TEXT_SHOW_POSITION whenever MSG_META_GAINED_TARGET_EXCL is
; received.  This way if the cursor is outside the visible text window
; when the target is gained the text will not automatically scroll to
; the cursor position 
;

ATTR_VIS_TEXT_SHOW_POSITION_ON_GAINED_TARGET_EXCL	vardata
;
; This attribute causes the vis-text object to call
; MSG_VIS_TEXT_SHOW_POSITION whenever MSG_META_GAINED_TARGET_EXCL is
; received.   This way if the cursor is outside the visible text window
; when the target is gained the text will automatically scroll to
; the cursor position 
;

ATTR_VIS_TEXT_DONT_BEEP_ON_INSERTION_ERROR		vardata
;
; This attribute causes the vis-text object to not call the sound
; routine with SST_ERROR, even though there was an error inserting
; the character.
;

protoreset

protominor	TextNew2ForPizza

ATTR_VIS_TEXT_NO_FEP					vardata
;
; This attribute causes the text object to not interact with the FEP,
; if any.  This is useful for numeric-only text fields, such as in
; a calculator.   Only implemented in DBCS/Pizza.
; NOTE: care should be taken in adding / removing this dynamically,
; as chaos will result if the text object already has the focus,
; and already interacted with / didn't interact with the FEP.
;

protoreset

protominor	TextNewForJedi

ATTR_VIS_TEXT_NOTIFY_EVEN_IF_NOT_TARGETED		vardata
;
; This attribute causes the vis-text object to send out notificiations
; to controllers even when it doesn't have the target.
;

protoreset

protominor	TextNewForResponder

ATTR_VIS_TEXT_XOR_SELECTION				vardata
;
; This attribute sets the text object in a state where the selected text will
; be xor'ed with some product-specific value, rather than inverted.  This
; is currently only handled in Responder, for achieving the black-text-on-
; light-grey-background effect similar to selected gadgetry in the UI.


protoreset

protominor	TextNewForLeia

VisTextCursorType	etype	word, 0, 2
	VTCT_NORMAL_CURSOR		enum	VisTextCursorType
	VTCT_CAPLOCK_CURSOR		enum	VisTextCursorType
	VTCT_NUMLOCK_CURSOR		enum	VisTextCursorType
	VTCT_EQNLOCK_CURSOR		enum	VisTextCursorType

TEMP_VIS_TEXT_CURSOR_TYPE			vardata	VisTextCursorType
;
;  This vardata is used to keep track of the current text cursor
;  so that when the HWR mode changes, it can erase the old cursor
;  before drawing the new one.  Used to index the graffitiCursorTable
;  in SpecDrawTextCursor.
;

protoreset

protominor	TextNewForDove

ATTR_VIS_TEXT_CURSOR_NO_FOCUS				vardata
;
; This attribute will cause the cursor to be drawn even though the
; text does not have the focus.

protoreset

protominor	TextNewForPenelope
		
ATTR_VIS_TEXT_NO_CURSOR				vardata
;
; This attribute will cause the cursor *not* to be drawn even though the
; text object is editable.
;

protoreset

protominor TextFullWidthFilters

ATTR_VIS_TEXT_ALLOW_FULLWIDTH_DIGITS		vardata
;
; This attribute overrides any filtering (VTI_filters) and allows full-width
; digits ('0' to '9') to be entered.  The other filter classes are obeyed
; after that.  A custom filter will be done after that.
;

protoreset

protominor TextNewForWM

ATTR_VIS_TEXT_WRAP_AFTER_OVERFLOW		vardata
;
; This hint can be used to suggest that the word wrapping functionality
; be altered so that instead of wrapping words to fit within the bounds of
; the text object, words are wrapped so that the word at the end of each
; line will be allowed to cross the left bound.  Must be used without
; VTF_NO_WORD_WRAPPING.  Also, although this is defined in VisTextClass,
; only VisLargeTextClass currently supports this.
;

ATTR_VIS_TEXT_DONT_DRAW_BREAKS			vardata
;
; This prevents drawing of column breaks and section breaks.
;

protoreset

protominor TextShowSelectionAtTop

TEMP_VIS_TEXT_SHOW_SELECTION_AT_TOP		vardata
;
; Attempt to show selection at top of window.
;

;
; Added 8/26/99 by Tony.  To allow the browser to select across
; sections and do COPY
;
ATTR_VIS_TEXT_ALLOW_CROSS_SECTION_COPY		vardata

protoreset

;------------------------------------------------------------------------------
;	Instance data
;------------------------------------------------------------------------------
	;
	; Data storage...
	;
    VTI_text		lptr.char		
		; Chunk containing text.

    VTI_charAttrRuns	word		VIS_TEXT_INITIAL_CHAR_ATTR
		; CharAttr runs or single

    VTI_paraAttrRuns	word		VIS_TEXT_INITIAL_PARA_ATTR
		; ParaAttr runs or single

    VTI_vmFile		word		0	
		; Handle of associated VM file

    VTI_lines		word		0
		; Reference to line info

	;
	; External states...
	;
    VTI_storageFlags	VisTextStorageFlags  (mask VTSF_DEFAULT_CHAR_ATTR or \
					      mask VTSF_DEFAULT_PARA_ATTR)

    VTI_features	VisTextFeatures	     0
    VTI_state		VisTextStates        0

	;
	; Internal states...
	;
    VTI_intFlags	VisTextIntFlags	     0
    VTI_intSelFlags	VisTextIntSelFlags   0

    VTI_gsRefCount	GSRefCountAndFlags   0
		; Reference count for gstate.

    VTI_gstate		hptr.GState	     0
		; Temporary gstate.
		noreloc	VTI_gstate

    VTI_gstateRegion	word		     -1 
		; Region to which gstate has been translated.

;*****************************************************************************
;			 Selection variables
;*****************************************************************************
    VTI_selectStart	dword		     0	; Offset to selection start.
    VTI_selectEnd	dword		     0	; Offset to selection end.

	;
	; Start event-pos holds the coordinate position of the original
	; mouse event.
	;
    VTI_startEventPos	PointDWord	    

	;
	; The next group of variables are used to make selection work
	; right and also for optimizations.
	;
	; minStart/End are set by the start-select handler and indicate the
	; minimum range that must remain selected during drag-selection. The
	; selection will never be smaller than this.
	;
    VTI_selectMinStart	dword
    VTI_selectMinEnd	dword

    	;
	; Last-offset holds the last character offset which the mouse was over.
	; This is used for optimizations since if the character offset of the
	; mouse event hasn't changed then the selection can't have changed.
	;
    VTI_lastOffset	dword

    	;
	; The goal-position is the current X offset of the cursor in the text
	; object. When the user moves the cursor up/down or extends the 
	; selection up or down this is used to tell where to move/extend to.
	;
    VTI_goalPosition	word

;******************************************************************************

    VTI_cursorPos	Point			; The current cursor position
    VTI_cursorRegion	word			; The region the cursor is in

    VTI_leftOffset	sword			; Offset from left edge of text
						; to left edge of vis-bounds.
						; Used for moving one line
						; text edit object left/right.

	; user set state information...

    VTI_lrMargin	byte			
    VTI_tbMargin	byte
		; Padding around text.

    VTI_washColor	ColorQuad		<C_WHITE, 0, 0, 0>
		; Background color and map mode

    VTI_maxLength	word			10000
		; Max amount of text.
	;
	; This only applies to small text objects. Large text objects can not
	; have a limit set on their size.
	;

    VTI_filters		VisTextFilters		; Pre-defined key filters.
    VTI_output		optr

	; derived state information...

    VTI_height		WBFixed <>		; height in points.

    ; Cached width, used to optimize resizing the object (via the geometry
    ; manager). For more information see VisTextCalcHeight().

    VTI_lastWidth	word		-1

	; timer state...

    VTI_timerHandle	word
    VTI_timerID		word

VisTextClass	endc

EndLibrary	text

