home *** CD-ROM | disk | FTP | other *** search
- *****************************************************************
- FUNCTION MEMOVIEW
- *****************************************************************
-
- * Display or edit a memo in a predefined window
-
- * Copyright(c) 1991 - James Occhiogrosso
-
- #include "setcurs.ch"
-
- LOCAL infoline, old_screen, old_color, spacing
-
- PARAMETERS format, memo_name, top, left, bottom, right, update, ;
- userfunc, line_len, tab_size, start_line, start_col, ;
- init_row, init_col
-
- * If you wish to use your own control function, instead of
- * MEMOCTRL remove the EXTERNAL declaration line below.
-
- EXTERNAL MEMOCTRL
-
- IF PCOUNT() < 2
- * Not enough parameters. Give it back
- RETURN(memo_name)
-
- ELSEIF PCOUNT() >= 2 .AND. PCOUNT() < 6
- * Set up full screen MEMOEDIT with default control function
- top = 0
- left = 0
- bottom = 24
- right = 79
- update = .T.
- userfunc = "MEMOCTRL"
-
- ELSEIF PCOUNT() = 6
- * Use passed coordinates with default control function.
- update = .T.
- userfunc = "MEMOCTRL"
-
- ELSEIF PCOUNT() = 7
- * Use passed coordinates with default control function.
- userfunc = "MEMOCTRL"
- ENDIF
-
- * Define defaults for other parameters not passed
-
- line_len = IF(line_len == NIL, (right-left)-1, line_len)
- tab_size = IF(tab_size == NIL, 4, tab_size)
- start_line = IF(start_line == NIL, 1, start_line)
- start_col = IF(start_col == NIL, 0, start_col)
- init_row = IF(init_row == NIL, 0, init_row)
- init_col = IF(init_col == NIL, 0, init_col)
-
-
- * Save old color setting
- old_color = SETCOLOR()
-
- * Save current insert key setting as a block
- bInsert_key := SETKEY(22)
-
- * Clear insert key and display cursor in appropriate size
- SET KEY 22 TO
- CSRINSERT(,,, .F.)
-
- * Set up message variable
- message = ' Press F2 for edit keys '
-
- * Save the screen area to be used
- old_screen = SCRNSAVE(top,left,bottom,right)
-
- IF format
-
- * Clear memo area, draw a box, and display initial message.
- SETCOLOR(colhelp2)
- @ top, left, bottom, right BOX '┌─┐│┘─└│ '
- spacing = (((right - left)-2) - LEN(message)) / 2
- @ bottom, left + 1 SAY REPLICATE('─',spacing) + message + ;
- REPLICATE('─',spacing)
-
- * Display insert status
- IF update
- @ top, right-12 SAY " Insert " + IF(READINSERT(), ;
- "on ", "off ")
- ENDIF
-
- * Edit the memo inside boxed area
- memo_name = MEMOEDIT(memo_name, top+1, left+2, bottom-1, ;
- right-1, update, userfunc, line_len, ;
- tab_size, start_line, start_col, ;
- init_row, init_col)
-
- ELSE
- * Edit the memo without special formatting
- SETCOLOR(colmemoget)
- memo_name = MEMOEDIT(memo_name, top, left, bottom, right, ;
- update, userfunc, line_len, tab_size, ;
- start_line, start_col, init_row, ;
- init_col)
- ENDIF
-
- * Restore starting conditions
-
- SETCOLOR(old_color)
- SCRNREST(old_screen)
- SETKEY(22, bInsert_key)
- RETURN (memo_name)
-
-