home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 2
/
ctrom_ii_b.zip
/
ctrom_ii_b
/
PROGRAM
/
FOXPRO
/
VEDIT060
/
SOURCE
/
VEDIT7.PRG
< prev
next >
Wrap
Text File
|
1992-09-25
|
3KB
|
117 lines
#INCLUDE KEYS.HDR
#INCLUDE vlist.hdr
#INCLUDE vmouse.hdr
#INCLUDE vedit.hdr
#INCLUDE STRING.HDR
#INCLUDE WARN.HDR
PROCEDURE VEdit_Word_Wrap
PARAMETERS VALUE LONG handle,;
VALUE UINT mini,;
VALUE LOGICAL blp,; && stop on first blank
VALUE UINT right_margin,;
VALUE UINT hard_margin,;
UINT current_element,;
UINT current_column
VARDEF
UINT temp_loc
UINT temp_len
CHAR temp_str, old_str
CHAR carry
LOGICAL going, first
LOGICAL altered
UINT old
ENDDEF
first = .T.
Vlist_Goto( handle, mini )
going = .T.
carry = ""
altered = .F.
DO WHILE going
temp_str = RTRIM( Vlist_Cstr( handle ) )
IF LEN( carry ) <> 0
IF ( LEN( temp_str ) = 0 ) .OR. ( LEFT( temp_str, 1 ) = CHR( 9 ) ) .OR.;
( LEFT( temp_str, 1 ) = CHR( 32 ) )
Vlist_Cinsert( handle, &jl_normal, &jl_default,;
carry+SPACE( hard_margin-LEN( carry ) ) )
temp_str = carry
carry = ""
ELSE
temp_str = carry + " " + temp_str
temp_str = RTRIM( temp_str )
carry = ""
ENDIF
altered = .T.
ELSE
altered = .F.
ENDIF
temp_len = LEN( temp_str )
IF temp_len >= right_margin
temp_loc = VEdit_Last_Space( right_margin, temp_str )
old_str = temp_str
IF ( temp_loc = 0 )
*- no spaces at all? uh oh!
carry = SUBSTR( temp_str, right_margin, 250 )
temp_str = RTRIM( LEFT( temp_str, right_margin-1 ) )
ELSE
carry = TRIM( SUBSTR( temp_str, temp_loc+1, 250 ) )
temp_str = RTRIM( LEFT( temp_str, temp_loc-1 ) )
ENDIF
IF first .AND. ( current_column > temp_loc )
IF current_column < LEN( old_str )
current_column = LEN( carry ) - ( LEN( old_str ) - current_column )
ELSE
current_column = LEN( TRIM( carry ) ) + 1
** or: current_column = LEN( carry ) + 2
** carry = carry + " "
ENDIF
current_element = current_element + 1
ENDIF
temp_str = LEFT( temp_str, hard_margin )
temp_str = temp_str + SPACE( hard_margin - LEN( temp_str ) )
Vlist_Cedit( handle, temp_str )
ELSE
IF altered
temp_str = LEFT( temp_str, hard_margin )
temp_str = temp_str + SPACE( hard_margin - LEN( temp_str ) )
Vlist_Cedit( handle, temp_str )
altered = .F.
ENDIF
IF blp
* we are done since there is no wrapping here!
going = .F.
LOOP
ENDIF
ENDIF
Vlist_Skip( handle, &jl_forward )
IF Vlist_Bol( handle )
IF LEN( carry ) > 0
carry = LEFT( carry, hard_margin )
carry = carry + SPACE( hard_margin - LEN( carry ) )
Vlist_Add( handle, carry )
ENDIF
going = .F.
ENDIF
IF first
first = .F.
ENDIF
ENDDO
Vlist_Goto( handle, mini )
ENDPRO