home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 2
/
ctrom_ii_b.zip
/
ctrom_ii_b
/
PROGRAM
/
FOXPRO
/
VEDIT060
/
SOURCE
/
VEDIT1.PRG
< prev
next >
Wrap
Text File
|
1992-04-16
|
48KB
|
1,572 lines
*******************************************************************************
* *
* (c) 1992, Jayson R. Minard *
* *
*******************************************************************************
*DEFINE demo
VARDEF EXTERN
BYTE __color_std, __color_enhcd
ENDDEF
#INCLUDE WARN.HDR
#INCLUDE vlist.hdr
#INCLUDE vedit.hdr
#INCLUDE vmouse.hdr
#INCLUDE STRING.HDR
#INCLUDE IO.HDR
#INCLUDE KEYS.HDR
#INCLUDE MATH.HDR
FUNCTION INT VEdit_Call_Handler PROTOTYPE
PARAMETERS UNTYPED handler,;
VALUE LONG list_handle,;
UINT list_element,;
UINT list_column,;
UINT mouse_stat,;
VALUE UINT mrow,;
VALUE UINT mcol,;
INT pick_key,;
UINT top_element,;
VALUE UINT last_element,;
UINT ur,;
UINT uc,;
UINT lr,;
UINT lc,;
UINT stat_row,;
UINT stat_col,;
VALUE LOGICAL display_only,;
LOGICAL refresh
** returns a code to inform VEdit_Text_Editor what to do
**
** 0 - error
* 1 - do nothing (quit)
** 2 - save and exit
** 3 - save and continue
** 4 - just continue
** 5 - save as new filename
** 6 - save and rename
**
FUNCTION UINT VEdit_Internal_Editor
PARAMETERS VALUE LONG handle,;
VALUE LONG scrap,;
VALUE LONG undelete,;
VALUE INT upper_row,;
VALUE INT upper_col,;
VALUE INT lower_row,;
VALUE INT lower_col,;
UINT top_element,;
UINT initial_element,;
UINT left_col,;
UINT initial_col,;
UINT right_margin,; && max 132
VALUE UINT hard_margin,;
VALUE BYTE marked_text_color,;
LOGICAL word_wrap,;
VALUE LOGICAL display_only,;
VALUE LOGICAL flash,;
VALUE LOGICAL scroll_bar,;
VALUE LOGICAL stat_line,;
VALUE UINT stat_row,;
VALUE UINT stat_col,;
VALUE LOGICAL is_mouse,;
VALUE LOGICAL allow_embedded,;
VALUE UINT tab_stop,;
VALUE UINT undelete_lines,;
UNTYPED key_handler
VARDEF
UINT ret_val
UINT last_element && last total element
UINT height && height of pick window
UINT temp_mark
LOGICAL refresh
LOGICAL mini_refresh
LOGICAL list_loop
LOGICAL resize
BYTE old_std, old_enhcd, o_std
UINT scroll_col, scroll_top, scroll_bottom, scroll_row
LOGICAL scroll_refresh
LOGICAL abort
UINT current_x
UINT current_y
UINT old_y, old_x
UINT current_wide
UINT current_over
LOGICAL check_wrap, do_it
INT pick_key
UINT temp_row
CHAR temp_str, full_str, temp_str2
UINT mouse_stat
LOGICAL mouse_search
UINT mouse_found
UINT mouse_last
INT user_proc
UINT last_displayed
UINT old_element, old_ele
UINT mrow, mcol
LOGICAL mouse_set
LOGICAL ml, mr
UINT temp_number
INT temp_int1, temp_int4, temp_int5
DBL temp_dbl1, temp_dbl2, temp_dbl3, temp_dbl
UINT counter
LOGICAL inner
LOGICAL changed
LOGICAL insert
UINT saved_stat
UINT saved_scroll
ENDDEF
IF flash
scroll_bar = .F.
stat_line = .F.
display_only = .T.
ENDIF
insert = insert_key()
mouse_set = .T.
old_std = __color_std
old_enhcd = __color_enhcd
IF initial_element = 0
initial_element = 1
top_element = 1
ENDIF
IF top_element = 0
top_element = 1
ENDIF
*- Check for valid picklist
IF .NOT. Vlist_Is_Init( handle )
RETURN &edit_error
ENDIF
last_element = Vlist_Max( handle )
IF last_element = 0
IF .NOT. Vlist_Add( handle, SPACE( hard_margin ) )
RETURN &edit_error
ENDIF
last_element = 1
top_element = 1
initial_col = 1
left_col = 1
ENDIF
#ifdef demo
IF last_element > 85
display_only = .T.
ENDIF
#ENDIF
*- check starting conditions
height = lower_row - upper_row + 1
IF top_element > initial_element
top_element = initial_element
ENDIF
IF ( ( initial_element - top_element ) + 1 ) > height
top_element = initial_element - height + 1
ENDIF
current_y = upper_row + ( initial_element - top_element )
* HEY, if we are using a scroll bar, set up its info
IF scroll_bar
scroll_refresh = .T.
scroll_col = lower_col + __scroll_offset
scroll_top = upper_row + 1
scroll_row = 0
scroll_bottom = lower_row - 1
__color_std = __color_bar
saved_scroll = SAVESCRN( scroll_top-1, scroll_col,;
scroll_bottom+1, scroll_col )
FOR temp_int1 = scroll_top TO scroll_bottom
@temp_int1, scroll_col SAY "░"
NEXT
__color_std = __color_tab
@scroll_top-1, scroll_col SAY CHR( 24 )
@scroll_bottom+1, scroll_col SAY CHR( 25 )
__color_std = old_std
ENDIF
current_x = upper_col
current_wide = lower_col - upper_col + 1
IF initial_col = 0
initial_col = 1
ENDIF
IF initial_col > hard_margin
initial_col = hard_margin
ENDIF
IF left_col = 0
left_col = 1
ENDIF
IF ( ( initial_col - left_col ) + 1 ) > current_wide
left_col = initial_col - current_wide + 1
ENDIF
IF is_mouse
ml = Vmouse_Left_Button()
mr = Vmouse_Right_Button()
Vmouse_Cursor( .T. )
ENDIF
*** start the stupid thing!
refresh = .T. && start by drawing the screen
list_loop = .T.
abort = .F.
check_wrap = .F.
mouse_search = .F.
mouse_last = initial_element
user_proc = 999
IF stat_line
saved_stat = SAVESCRN( stat_row, stat_col, stat_row, stat_col + 41 )
o_std = __color_std
__color_std = __color_tab
IF .NOT. display_only
@stat_row, stat_col SAY " Line: Col: "
ELSE
@stat_row, stat_col SAY " Line: Col: DISPLAY ONLY! "
ENDIF
__color_std = o_std
ENDIF
DO WHILE list_loop
IF is_mouse
Vmouse_Cursor( .F. )
ENDIF
IF refresh
last_element = Vlist_Max( handle )
IF last_element <= height
top_element = 1
ENDIF
IF .NOT. Vlist_Goto( handle, top_element )
list_loop = .F.
abort = .T.
ret_val = &edit_error
LOOP
ENDIF
mouse_found = 0
temp_row = upper_row
temp_number = Vlist_Number( handle )
DO WHILE ( temp_row <= lower_row ) .AND.;
( temp_number <= last_element ) .AND.;
( .NOT. Vlist_Bol( handle ) )
IF temp_number = initial_element
current_y = temp_row
ENDIF
IF mouse_search .AND. is_mouse
IF ( temp_row = mrow ) .AND.;
( ( mcol>= current_x ) .AND.;
( mcol<=( current_x+current_wide-1 ) ) )
initial_element = temp_number
current_y = temp_row
mouse_found = initial_element
initial_col = mcol - upper_col + 1
ENDIF
ELSE
full_str = Vlist_Cstr( handle )
temp_str = full_str
Vlist_What_Color( handle, old_std )
IF left_col > 0
temp_str = SUBSTR( temp_str, left_col, current_wide )
ELSE
temp_str = LEFT( temp_str, current_wide )
ENDIF
IF allow_embedded
Vlist_Say( temp_row, current_x, current_wide, temp_str, .F. )
ELSE
@temp_row, current_x SAY temp_str:current_wide
ENDIF
ENDIF
last_displayed = temp_number
Vlist_Skip( handle, &jl_forward )
temp_row = temp_row + 1
temp_number = Vlist_Number( handle )
ENDDO
IF .NOT. mouse_search
IF temp_row <= lower_row
@temp_row, upper_col CLEAR TO lower_row, lower_col
ENDIF
ENDIF
scroll_refresh = .T.
refresh = .F.
ENDIF
IF flash
IF is_mouse
vmouse_cursor(.T.)
ENDIF
list_loop = .F.
LOOP
ENDIF
IF Vlist_Number( handle ) <> initial_element
Vlist_Goto( handle, initial_element )
ENDIF
IF scroll_refresh .AND. scroll_bar
*- length of scroll bar
temp_int4 = scroll_bottom - scroll_top + 1
*- percentage
temp_dbl1 = last_element
temp_dbl2 = initial_element
IF initial_element >= last_element
temp_int5 = scroll_bottom
ELSE
IF initial_element = 1
temp_int5 = scroll_top
ELSE
temp_dbl3 = temp_int4
temp_dbl = ( temp_dbl2 / temp_dbl1 ) * temp_dbl3
*- now figure row offset
temp_int5 = ROUND( temp_dbl, 0 )
IF temp_int5 > temp_int4
temp_int5 = temp_int4
ENDIF
temp_int5 = temp_int5 + scroll_top - 1
IF temp_int5 < scroll_top
temp_int5 = scroll_top
ENDIF
ENDIF
ENDIF
IF scroll_row <> temp_int5
__color_std = __color_bar
IF scroll_row <> 0
@scroll_row, scroll_col SAY "░"
ENDIF
scroll_row = temp_int5
@scroll_row, scroll_col SAY "▒"
__color_std = old_std
ENDIF
scroll_refresh = .F.
ENDIF
full_str = Vlist_Cstr( handle )
temp_str = full_str
IF left_col > 0
temp_str = SUBSTR( temp_str, left_col, current_wide )
ELSE
temp_str = LEFT( temp_str, current_wide )
ENDIF
__color_std = old_enhcd
current_over = current_x + ( initial_col - left_col )
IF user_proc <> &jl_ignore
IF allow_embedded
Vlist_Say( current_y, current_x, current_wide, temp_str, .T. )
ELSE
@current_y, current_x SAY temp_str:current_wide
ENDIF
ENDIF
* turn cursor on to current location...
IF mouse_search .AND. is_mouse
mouse_search = .F.
mouse_last = mouse_found
ENDIF
inner = .T.
changed = .F.
scroll_refresh = .T.
DO WHILE inner
IF stat_line
CURSOR_OFF()
o_std = __color_std
__color_std = __color_bar
@stat_row, stat_col+7 SAY initial_element PICTURE "99999"
@stat_row, stat_col+19 SAY initial_col PICTURE "999"
insert = insert_key()
IF .NOT. display_only
IF insert
__color_std = __color_tab
@stat_row, stat_col+23 SAY "INSERT"
__color_std = __color_bar
ELSE
@stat_row, stat_col+23 SAY "insert"
ENDIF
IF Vlist_Max( scrap ) > 0
__color_std = __color_tab
@stat_row, stat_col+30 SAY "SCRAP"
__color_std = __color_bar
ELSE
@stat_row, stat_col+30 SAY "scrap"
ENDIF
IF word_wrap
__color_std = __color_tab
@stat_row, stat_col+36 SAY "WRAP"
ELSE
@stat_row, stat_col+36 SAY "wrap"
ENDIF
ENDIF
__color_std = o_std
#ifdef fuck
@22, 0 SAY " ignore the following, it is for my debugging..."
@23, 0 SAY "top: " + I_STR( top_element ) + " "
@23, 20 SAY "current: " + I_STR( initial_element ) + " "
@23, 40 SAY "left: " + I_STR( left_col ) + " "
@23, 60 SAY "current: " + I_STR( initial_col ) + " "
@24, 0 SAY "last: " + I_STR( last_element ) + " "
@24, 20 SAY "Cur_Y: " + I_STR( current_y ) + " "
#ENDIF
ENDIF
mouse_stat = 0
mouse_set = .F.
IF is_mouse
Vmouse_Cursor( .T. )
ENDIF
current_over = current_x + ( initial_col - left_col )
@ current_y, current_over
CURSOR_ON()
DO WHILE IS_KEY() = 0 .AND. mouse_stat = &jl_mouse_ignore
IF insert_key() <> insert
insert = insert_key()
IF stat_line
o_std = __color_std
IF insert .AND. ( .NOT. display_only )
__color_std = __color_tab
@stat_row, stat_col+23 SAY "INSERT"
ELSE
__color_std = __color_bar
@stat_row, stat_col+23 SAY "insert"
ENDIF
__color_std = o_std
ENDIF
ENDIF
IF is_mouse
IF Vmouse_Left_Button() .AND. Vmouse_Right_Button()
mrow = Vmouse_Row()
mcol = Vmouse_Col()
mouse_stat = &jl_mouse_both
ELSE
IF ml
IF .NOT. Vmouse_Left_Button() && find release point
ml = .F.
mrow = Vmouse_Row()
mcol = Vmouse_Col()
IF mcol = scroll_col .AND. scroll_bar
DO CASE
CASE mrow = scroll_top - 1
mouse_stat = &jl_mouse_xup
mouse_set = .T.
CASE mrow = scroll_bottom + 1
mouse_stat = &jl_mouse_xdown
mouse_set = .T.
CASE mrow >= scroll_top .AND. mrow <= scroll_bottom
mouse_stat = &jl_mouse_xscroll
mouse_set = .T.
OTHERWISE && other location
mouse_stat = &jl_mouse_xleft
ENDCASE
ELSE
IF ( mrow >= upper_row ) .AND. ( mrow <= lower_row ) .AND.;
( mcol >= upper_col ) .AND. ( mcol <= lower_col )
IF ( mrow = current_y ) .AND.;
( mcol >= current_x ) .AND.;
( mcol <= current_x + current_wide - 1 )
mouse_stat = &jl_mouse_xselect
ELSE
mouse_stat = &jl_mouse_xnew
ENDIF
ELSE
mouse_stat = &jl_mouse_xleft
ENDIF
ENDIF
ENDIF
ENDIF
IF Vmouse_Left_Button()
ml = .T.
mrow = Vmouse_Row()
mcol = Vmouse_Col()
IF mcol = scroll_col .AND. scroll_bar
DO CASE
CASE mrow = scroll_top - 1
mouse_stat = &jl_mouse_up && scroll up
mouse_set = .T.
CASE mrow = scroll_bottom + 1
mouse_stat = &jl_mouse_down && scroll down
mouse_set = .T.
CASE mrow >= scroll_top .AND. mrow <= scroll_bottom
mouse_stat = &jl_mouse_scroll
mouse_set = .T.
OTHERWISE && other location
mouse_stat = &jl_mouse_left
ENDCASE
ELSE
IF ( mrow >= upper_row ) .AND. ( mrow <= lower_row ) .AND.;
( mcol >= upper_col ) .AND. ( mcol <= lower_col )
IF ( mrow = current_y ) .AND.;
( mcol >= current_x ) .AND.;
( mcol <= current_x + current_wide - 1 )
mouse_stat = &jl_mouse_select
ELSE
mouse_stat = &jl_mouse_new
ENDIF
ELSE
mouse_stat = &jl_mouse_left
ENDIF
ENDIF
ENDIF
IF mr
IF .NOT. Vmouse_Right_Button()
mr = .F.
mrow = Vmouse_Row()
mcol = Vmouse_Col()
mouse_stat = &jl_mouse_xright
ENDIF
ELSE
IF Vmouse_Right_Button()
mr = .T.
mrow = Vmouse_Row()
mcol = Vmouse_Col()
mouse_stat = &jl_mouse_right
ENDIF
ENDIF
ENDIF
ENDIF
ENDDO
IF mouse_stat = &jl_mouse_ignore
pick_key = GET_KEY()
mouse_last = 0
ELSE
IF mouse_stat = &jl_mouse_scroll .OR. mouse_stat = &jl_mouse_xscroll
DO CASE
CASE mrow = scroll_bottom
pick_key = &k_pg_down
CASE mrow = scroll_top
pick_key = &k_pg_up
CASE mrow > scroll_row
pick_key = &k_pg_down
CASE mrow < scroll_row
pick_key = &k_pg_up
OTHERWISE
pick_key = 0
ENDCASE
ELSE
pick_key = 0
ENDIF
ENDIF
IF is_mouse
Vmouse_Cursor( .F. )
ENDIF
resize = .F.
old_element = initial_element
user_proc = VEdit_Call_Handler( key_handler,;
handle, initial_element, initial_col,;
mouse_stat, mrow, mcol, pick_key,;
top_element, last_displayed,;
upper_row, upper_col, lower_row, lower_col,;
stat_row, stat_col,;
display_only, resize )
old_y = current_y
old_x = current_x
mini_refresh = .F.
Vlist_Goto( handle, old_element )
IF resize
IF changed .AND. ( .NOT. display_only )
** comit line
Vlist_Cedit( handle, full_str )
ENDIF
inner = .F.
refresh = .F.
list_loop = .F.
ret_val = &edit_continue
LOOP
ENDIF
IF is_mouse
Vmouse_Cursor( .T. )
IF user_proc = &jl_goto_mouse
mouse_search = .T.
refresh = .T.
inner = .F.
IF changed .AND. ( .NOT. display_only )
** comit line
Vlist_Cedit( handle, full_str )
ENDIF
LOOP
ENDIF
ENDIF
IF user_proc = &jl_paint_key
refresh = .T.
inner = .F.
user_proc = &jl_continue
ENDIF
DO CASE
CASE user_proc = &jl_continue && evaluate keystroke
DO CASE
CASE pick_key = &k_c_right
old_ele = initial_element
temp_str = RTRIM( full_str )
do_it = .T.
DO WHILE do_it
IF initial_col >= LEN( temp_str )
* move to next line
IF initial_element = last_element
* we are done
do_it = .F.
LOOP
ELSE
IF initial_element = top_element + height - 1
top_element = top_element + 1
ENDIF
initial_element = initial_element + 1
Vlist_Skip( handle, &jl_forward )
temp_str = RTRIM( Vlist_Cstr( handle ) )
initial_col = 1
left_col = 1
* now we are on the next line
IF LEN( temp_str ) > 0 .AND. LEFT( temp_str, 1 ) <> " "
* we are done.
do_it = .F.
LOOP
ENDIF
ENDIF
ELSE
* move to next word on this line
IF VEdit_Forward_Space( temp_str, initial_col ) <> 0
do_it = .F.
LOOP
ENDIF
ENDIF
ENDDO
Vlist_Goto( handle, old_ele )
IF initial_element = old_ele
mini_refresh = .T.
ELSE
Vlist_Cedit( handle, full_str )
changed = .F.
Vlist_Goto( handle, initial_element )
refresh = .T.
inner = .F.
ENDIF
CASE pick_key = &k_c_left
old_ele = initial_element
temp_str = RTRIM( full_str )
do_it = .T.
DO WHILE do_it
IF initial_col = 1 .OR. LEN( temp_str ) = 0
* move to previous line
IF initial_element = 1
* we are done
do_it = .F.
LOOP
ELSE
IF initial_element = top_element
top_element = top_element - 1
ENDIF
initial_element = initial_element - 1
Vlist_Skip( handle, &jl_backward )
temp_str = RTRIM( Vlist_Cstr( handle ) )
initial_col = LEN( temp_str ) + 1
IF initial_col > current_wide
left_col = initial_col - current_wide + 1
ELSE
left_col = 1
ENDIF
* now we are on the previous line
* we are done.
do_it = .F.
LOOP
ENDIF
ELSE
* move to previous word on this line
IF VEdit_Backward_Space( temp_str, initial_col ) <> 0
do_it = .F.
LOOP
ENDIF
ENDIF
ENDDO
Vlist_Goto( handle, old_ele )
IF initial_element = old_ele
mini_refresh = .T.
ELSE
Vlist_Cedit( handle, full_str )
changed = .F.
Vlist_Goto( handle, initial_element )
refresh = .T.
inner = .F.
ENDIF
CASE pick_key = &k_esc
list_loop = .F.
inner = .F.
ret_val = &edit_none
LOOP
CASE pick_key = &k_c_end
initial_col = hard_margin
IF initial_col > current_wide
left_col = initial_col - current_wide + 1
ELSE
left_col = 1
ENDIF
refresh = .T.
inner = .F.
CASE pick_key = 32913 && k_c_down
IF last_displayed < last_element
top_element = top_element + 1
initial_element = initial_element + 1
refresh = .T.
ENDIF
inner = .F.
CASE pick_key = 32909 && k_c_up
IF top_element > 1
top_element = top_element - 1
initial_element = initial_element - 1
refresh = .T.
ENDIF
inner = .F.
CASE pick_key = &k_down
IF initial_element < last_element
initial_element = initial_element + 1
IF initial_element > last_displayed
top_element = top_element + 1
refresh = .T.
ELSE
current_y = current_y + 1
ENDIF
ENDIF
inner = .F.
CASE pick_key = &k_pg_down
counter = initial_element - top_element
IF ( initial_element + height ) <= last_element
initial_element = initial_element + height
IF initial_element > counter
top_element = initial_element - counter
ELSE
top_element = 1
ENDIF
ELSE
initial_element = last_element
IF initial_element <= height
top_element = 1
ELSE
top_element = initial_element - height + 1
ENDIF
ENDIF
refresh = .T.
inner = .F.
CASE pick_key = &k_end
initial_col = LEN( RTRIM( full_str ) ) + 1
IF initial_col = 0
initial_col = 1
ENDIF
IF initial_col > current_wide
left_col = initial_col - current_wide + 1
ELSE
left_col = 1
ENDIF
refresh = .T.
inner = .F.
CASE pick_key = &k_c_pg_down
initial_element = last_element
IF initial_element > height
top_element = initial_element - height + 1
ELSE
top_element = 1
ENDIF
refresh = .T.
inner = .F.
CASE pick_key = &k_right
IF initial_col < hard_margin
initial_col = initial_col + 1
IF ( initial_col - left_col + 1 ) >= current_wide
left_col = initial_col - current_wide + 1
refresh = .T.
inner = .F.
ENDIF
ENDIF
CASE pick_key = &k_up
IF initial_element > 1
IF initial_element = top_element
top_element = top_element - 1
refresh = .T.
ELSE
current_y = current_y - 1
ENDIF
initial_element = initial_element - 1
ENDIF
inner = .F.
CASE pick_key = &k_pg_up
counter = initial_element - top_element
IF initial_element > height
initial_element = initial_element - height
IF initial_element > counter
top_element = initial_element - counter
ELSE
top_element = 1
ENDIF
ELSE
initial_element = 1
top_element = 1
ENDIF
refresh = .T.
inner = .F.
CASE pick_key = &k_home
IF left_col > 1
refresh = .T.
inner = .F.
ELSE
refresh = .F.
ENDIF
left_col = 1
initial_col = 1
CASE pick_key = &k_c_pg_up
top_element = 1
initial_element = 1
refresh = .T.
inner = .F.
CASE pick_key = &k_left
IF initial_col > 1
IF initial_col = left_col
left_col = left_col - 1
refresh = .T.
inner = .F.
ENDIF
initial_col = initial_col - 1
ENDIF
OTHERWISE
IF .NOT. display_only
changed = .T.
DO CASE
CASE pick_key = &k_enter
IF insert
IF initial_col > LEN( RTRIM( full_str ) )
temp_str = SPACE( hard_margin )
ELSE
temp_str = SUBSTR( full_str, initial_col, 250 )
temp_str = LEFT( temp_str, hard_margin )
temp_str = temp_str + SPACE( hard_margin -;
LEN( temp_str ) )
full_str = LEFT( full_str, initial_col - 1 )
ENDIF
**** full_str = old line to commit
**** temp_str = new line to create
IF initial_element = last_element
IF .NOT. Vlist_Add( handle, temp_str )
list_loop = .F.
inner = .F.
ret_val = &edit_error
LOOP
ENDIF
ELSE
IF .NOT. Vlist_Insert( handle, initial_element + 1,;
&jl_normal, &jl_default, temp_str )
list_loop = .F.
inner = .F.
ret_val = &edit_error
LOOP
ENDIF
ENDIF
last_element = Vlist_Max( handle )
Vlist_Goto( handle, initial_element )
* now move down to the beginning of the new line
IF initial_element < last_element
initial_element = initial_element + 1
IF initial_element > last_displayed
top_element = top_element + 1
ELSE
current_y = current_y + 1
ENDIF
ENDIF
left_col = 1
initial_col = 1
inner = .F.
refresh = .T.
ELSE
refresh = .F.
IF initial_element < last_element
initial_element = initial_element + 1
IF initial_element > last_displayed
top_element = top_element + 1
refresh = .T.
ELSE
current_y = current_y + 1
ENDIF
ENDIF
IF left_col > 1
refresh = .T.
ENDIF
left_col = 1
initial_col = 1
inner = .F.
ENDIF
CASE pick_key = 32851 && del
IF initial_col = hard_margin
ELSE
IF initial_col > LEN( RTRIM( full_str ) )
IF initial_element < last_element
* bring the next line up
temp_str = full_str
Vlist_Skip( handle, &jl_forward )
temp_str2 = RTRIM( Vlist_Cstr( handle ) )
IF initial_col + LEN( temp_str2 ) > hard_margin
temp_str = LEFT( temp_str, initial_col ) +;
LEFT( temp_str2,;
hard_margin-initial_col )
temp_str2 = SUBSTR( temp_str2,;
hard_margin-initial_col+1,;
hard_margin )
temp_str2 = temp_str2 + SPACE( hard_margin-;
LEN( temp_str2 ) )
Vlist_Cedit( handle, temp_str2 )
ELSE
temp_str = LEFT( temp_str, initial_col ) +;
temp_str2
Vlist_Cdelete( handle )
ENDIF
Vlist_Goto( handle, initial_element )
full_str = temp_str
* check word wrap
last_element = Vlist_Max( handle )
IF word_wrap
check_wrap = .T.
ENDIF
refresh = .T.
changed = .T.
inner = .F.
ENDIF
ELSE
* delete a normal character
temp_str = LEFT( full_str, initial_col - 1 )
temp_str = temp_str + SUBSTR( full_str, initial_col +;
1, 250 )
full_str = temp_str
mini_refresh = .T.
ENDIF
ENDIF
CASE pick_key = 8
IF initial_col = 1
IF initial_element > 1
* bring this line up to the end of the previous
temp_str2 = RTRIM( full_str )
Vlist_Skip( handle, &jl_backward )
temp_str = RTRIM( Vlist_Cstr( handle ) )
initial_element = VList_Number( handle )
Vlist_Skip( handle, &jl_forward )
initial_col = LEN( temp_str ) + 1
IF initial_col > current_wide
left_col = initial_col - current_wide + 1
ELSE
left_col = 1
ENDIF
IF LEN( temp_str ) + LEN( temp_str2 ) > hard_margin
temp_int1 = LEN( temp_str )
temp_str = temp_str +;
LEFT( temp_str2,;
hard_margin-temp_int1 )
temp_str2 = SUBSTR( temp_str2,;
hard_margin-temp_int1+1,;
hard_margin )
temp_str2 = temp_str2 + SPACE( hard_margin-;
LEN( temp_str2 ) )
Vlist_Cedit( handle, temp_str2 )
ELSE
temp_str = temp_str + temp_str2
Vlist_Cdelete( handle )
ENDIF
VList_Goto( handle, initial_element )
temp_str = temp_str + SPACE( hard_margin -;
LEN( temp_str ) )
Vlist_Cedit( handle, temp_str )
IF initial_element < top_element
top_element = initial_element
ENDIF
full_str = temp_str
* check word wrap
last_element = Vlist_Max( handle )
IF word_wrap
check_wrap = .T.
ENDIF
refresh = .T.
changed = .F.
inner = .F.
ENDIF
ELSE
IF initial_col = 2
temp_str = SUBSTR( full_str, initial_col, 250 )
ELSE
temp_str = LEFT( full_str, initial_col - 2 )
temp_str = temp_str + SUBSTR( full_str, initial_col,;
250 )
ENDIF
full_str = temp_str
mini_refresh = .T.
* now move left one
IF initial_col > 1
IF initial_col = left_col
left_col = left_col - 1
refresh = .T.
inner = .F.
ENDIF
initial_col = initial_col - 1
ENDIF
ENDIF
CASE ( pick_key >= 32 .AND. pick_key <= 255 ) .OR.;
( pick_key = 9 )
mini_refresh = .T.
changed = .T.
IF pick_key = 9
temp_int1 = tab_stop
IF insert
pick_key = 32
ENDIF
ELSE
temp_int1 = 1
ENDIF
FOR temp_int4 = 1 TO temp_int1
IF insert
* insert character here
temp_str = LEFT( full_str, initial_col - 1 ) +;
CHR( pick_key )
temp_str = temp_str + SUBSTR( full_str, initial_col,;
250 )
full_str = temp_str
ELSE
IF pick_key <> 9
VEdit_Change_Byte( initial_col, pick_key, full_str )
ENDIF
ENDIF
* IF LEN( full_str ) < hard_margin
* @23,0 say "length is screwed!"
* ENDIF
* now move right one
IF initial_col < hard_margin
initial_col = initial_col + 1
IF ( initial_col - left_col + 1 ) >= current_wide
left_col = initial_col - current_wide + 1
refresh = .T.
inner = .F.
ENDIF
ELSE
EXIT
ENDIF
NEXT
IF word_wrap
IF LEN( RTRIM( full_str ) ) >= right_margin
check_wrap = .T.
ENDIF
ENDIF
ENDCASE
ENDIF
ENDCASE
CASE user_proc = &jl_ignore
CASE user_proc = &jl_repaint
refresh = .T.
CASE user_proc = &jl_delete_line .OR.;
user_proc = &jl_delete_to_scrap
IF .NOT. display_only
temp_str = full_str
IF initial_element = 1 .AND. last_element = 1
Vlist_Cedit( handle, SPACE( hard_margin ) )
ELSE
Vlist_Cdelete( handle )
last_element = Vlist_Max( handle )
IF initial_element > last_element
initial_element = last_element
ENDIF
Vlist_Goto( handle, initial_element )
ENDIF
refresh = .T.
inner = .F.
changed = .F.
IF (user_proc = &jl_delete_to_scrap)
temp_str = left( temp_str, hard_margin )
temp_str = temp_str + SPACE( hard_margin - LEN( temp_str ) )
IF .NOT. Vlist_Add( scrap, temp_str )
list_loop = .F.
inner = .F.
ret_val = &edit_error
LOOP
ENDIF
ELSE
IF undelete_lines > 0
temp_str = left( temp_str, hard_margin )
temp_str = temp_str + SPACE( hard_margin - LEN( temp_str ) )
IF vlist_max( undelete ) >= undelete_lines
vlist_top( undelete )
vlist_cdelete( undelete )
ENDIF
IF .NOT. VList_Add( undelete, temp_str )
list_loop = .F.
inner = .F.
ret_val = &edit_error
LOOP
ENDIF
ENDIF
ENDIF
ENDIF
CASE user_proc = &jl_toggle_wrap
word_wrap = .NOT. word_wrap
CASE user_proc = &jl_delete_scrap
IF .NOT. display_only
DO WHILE Vlist_Max( scrap ) > 0
Vlist_Top( scrap )
Vlist_Cdelete( scrap )
ENDDO
ENDIF
CASE user_proc = &jl_copy_bottom_scrap .OR.;
user_proc = &jl_copy_all_scrap .OR.;
user_proc = &jl_copy_all_scrap_delete .OR.;
user_proc = &jl_copy_top_scrap
IF .NOT. display_only
IF Vlist_Max( scrap ) > 0
* commit current line
Vlist_Cedit( handle, full_str )
changed = .F.
refresh = .T.
inner = .F.
IF user_proc = &jl_copy_all_scrap .OR.;
user_proc = &jl_copy_all_scrap_delete
Vlist_Bottom( scrap )
do_it = .T.
DO WHILE do_it
IF .NOT. Vlist_Cinsert( handle, &jl_normal, &jl_default,;
Vlist_Cstr( scrap ) )
list_loop = .F.
inner = .F.
ret_val = &edit_error
LOOP
ENDIF
IF user_proc = &jl_copy_all_scrap
IF Vlist_Number( scrap ) = 1
do_it = .F.
LOOP
ELSE
Vlist_Skip( scrap, &jl_backward )
ENDIF
ELSE
Vlist_Cdelete( scrap )
IF Vlist_Max( scrap ) = 0
do_it = .F.
LOOP
ELSE
Vlist_Bottom( scrap )
ENDIF
ENDIF
ENDDO
ELSE
IF user_proc = &jl_copy_top_scrap
Vlist_Top( scrap )
ELSE
Vlist_Bottom( scrap )
ENDIF
temp_str = VList_CStr( scrap )
IF .NOT. Vlist_Cinsert( handle, &jl_normal, &jl_default,;
temp_str )
list_loop = .F.
inner = .F.
ret_val = &edit_error
LOOP
ENDIF
Vlist_Cdelete( scrap )
ENDIF
initial_element = Vlist_Number( handle )
last_element = Vlist_Max( handle )
IF initial_element > ( top_element + height - 1 )
top_element = initial_element - height + 1
ENDIF
ENDIF
ENDIF
CASE user_proc = &jl_undelete_line .and.;
( .not. display_only ) .and.;
( undelete_lines > 0 )
IF vlist_max( undelete ) > 0
*- commit line
Vlist_Cedit( handle, full_str )
changed = .F.
Vlist_Bottom( undelete )
temp_str = VList_Cstr( undelete )
VList_Cdelete( undelete )
IF .NOT. Vlist_Cinsert( handle, &jl_normal, &jl_default,;
temp_str )
list_loop = .F.
inner = .F.
ret_val = &edit_error
LOOP
ENDIF
initial_element = Vlist_Number( handle )
last_element = Vlist_Max( handle )
IF initial_element > ( top_element + height - 1 )
top_element = initial_element - height + 1
ENDIF
refresh = .T.
inner = .F.
ENDIF
CASE user_proc = &jl_save_continue .OR.;
user_proc = &jl_save_as_new .OR.;
user_proc = &jl_save_rename .OR.;
user_proc = &jl_save_scrap .OR.;
user_proc = &jl_read_scrap
IF .NOT. display_only
* commit line
Vlist_Cedit( handle, full_str )
list_loop = .F.
inner = .F.
ret_val = user_proc
LOOP
ENDIF
CASE user_proc = &jl_save_exit
* commit line
Vlist_Cedit( handle, full_str )
list_loop = .F.
inner = .F.
IF display_only
ret_val = &edit_none
ELSE
ret_val = &edit_save_exit
ENDIF
LOOP
CASE user_proc = &jl_abort
IF .not. display_only
vlist_cedit( handle, full_str )
ENDIF
list_loop = .F.
inner = .F.
ret_val = &edit_none
LOOP
ENDCASE
IF ( .NOT. inner ) .OR. ( check_wrap )
IF ( changed .AND. ( .NOT. display_only ) ) .OR. check_wrap
Vlist_Cedit( handle, full_str )
ENDIF
IF check_wrap
check_wrap = .F.
inner = .F.
old_ele = initial_element
VEdit_Word_Wrap( handle, initial_element,;
.T., right_margin, hard_margin,;
initial_element, initial_col )
IF initial_element <> old_ele
left_col = 1
ENDIF
IF initial_col > current_wide
left_col = initial_col - current_wide + 1
ENDIF
IF ( initial_element - top_element + 1 ) > height
top_element = initial_element - height + 1
ENDIF
Vlist_Goto( handle, initial_element )
last_element = Vlist_Max( handle )
refresh = .T.
ENDIF
ELSE
IF mini_refresh
temp_str = full_str
IF left_col > 0
temp_str = SUBSTR( temp_str, left_col, current_wide )
ELSE
temp_str = LEFT( temp_str, current_wide )
ENDIF
IF is_mouse
Vmouse_Cursor( .F. )
ENDIF
CURSOR_OFF()
IF allow_embedded
Vlist_Say( current_y, current_x, current_wide, temp_str, .F. )
ELSE
@current_y, current_x SAY temp_str:current_wide
ENDIF
mini_refresh = .F.
IF is_mouse
Vmouse_Cursor( .T. )
ENDIF
ENDIF
ENDIF
ENDDO && innner loop
CURSOR_OFF()
** leave element
IF ( .NOT. refresh ) .OR. ( mouse_search )
Vlist_What_Color( handle, old_std )
temp_str = full_str
IF left_col > 0
temp_str = SUBSTR( temp_str, left_col, current_wide )
ELSE
temp_str = LEFT( temp_str, current_wide )
ENDIF
IF user_proc <> &jl_ignore
IF is_mouse
Vmouse_Cursor( .F. )
ENDIF
IF allow_embedded
Vlist_Say( old_y, old_x, current_wide, temp_str, .F. )
ELSE
@old_y, old_x SAY temp_str:current_wide
ENDIF
IF is_mouse
Vmouse_Cursor( .T. )
ENDIF
ENDIF
ENDIF
IF mouse_set .AND. is_mouse
mouse_set = .F.
mouse_last = initial_element
ENDIF
ENDDO
IF is_mouse
Vmouse_Cursor( .F. )
* Vmouse_restore( Vmouse_buffer[] )
ENDIF
IF stat_line
RESTORESCRN( saved_stat )
ENDIF
IF scroll_bar
RESTORESCRN( saved_scroll )
ENDIF
__color_std = old_std
__color_enhcd = old_enhcd
RETURN ret_val
ENDPRO