home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 2
/
ctrom_ii_b.zip
/
ctrom_ii_b
/
PROGRAM
/
FOXPRO
/
VEDIT060
/
README.1ST
< prev
next >
Wrap
Text File
|
1992-09-25
|
28KB
|
711 lines
VEDITOR
BETA VERSION 0.60
(c) 1992 -- Jayson R. Minard
=============================================================================
VEDIT is a free product BUT donations are accepted so that I have
motivation to continue developing products such as these. This is
therefore similar to ShareWare. Hopefully the time saved by using
this product is worth a donation <g>...
Jayson R. Minard
P.O. Box 1306
Westminster, CO 80030-1306
You will also notice that full source code is included with this release.
JMAKE or Borland's make utility can be used to compile the libraries. You
will need a librarian manager and an assembler to complete the library.
=============================================================================
Welcome to BETA 6 of the new FORCE memo and text editors.
Coming in BETA 7:
- CUA looking support like in ForCIS
Changes in BETA 6:
- If a complete line of text with no spaces was wider than the right
margin then a runtime error would occur... This is fixed.
- a FLASH parameter added to the internal editor (see bottom of file)
which allows displaying of the text with immediate exit.
Changes in BETA 5:
- UnDelete parameter added to editor. This allows you to specify the
number of lines kept when using ALT-D to delete. Then use ALT-U
to bring them back in the reverse order they were deleted.
I've decided to throw in the kitchen sink, then if you don't want stuff
you can register and change the source code to get rid of the un-wanted
items. This means Search and Replace is back in and will be there
for the next BETA.
Changes in BETA 4:
- NOTE!!!! all of the function names have been changed, sorry but I want
them to be VEDIT_???? not VLIST_???. The macros are the same since
JL stands for a J-Library not for J-List. Therefore I keep them the
same.
- Filename is now a passed-by-reference parameter for VEDIT_TEXT_EDITOR()
in case the user changes the filename.
- save as new filename (but leave original parameter intact for normal save)
was added as ALT-S. This requires the window to be at least around 40
characters so that it has room to ask for the filename.
- save as new filename and change original parameter so that ALT-W now saves
to this filename is ALT-N. This also requires a window of at least 40
characters wide.
- search and replace will NOT be added to the library.
- save/read scrap CTRL-W/CTRL-R
- fixed a bug with CTRL-LEFT and CTRL-RIGHT that messed up the screen.
- you will have to compile NEWMEMO.PRG since the files are getting
larger and I wanted to keep d/l time lower. You will need VLIST.ZIP
from the FORCE BBS if you don't already have it.
Some of these changes add BULK to the final EXE since I now have GETs within
the library code. If you already use GETs then you are fine and this bulk
won't be added. The FORCE GET code is decently large. If you do not want
some of these extra features, then just register the library (when it
becomes available) and when you get the source code, change it.
The ACTUAL SIZE of bytes that the VEDIT_TEXT_EDITOR() adds to your code
at this time is right around 40k. If you use at least 1 GET in your
program. Basically, take the NEWEDIT.PRG, comment out the call to
the editor and recompile. Look at the difference in size...
Changes in BETA 3:
- Display only works (it did in BETA 2, by the way)
- The ALT- ALT+ ALT* ALT/ problem is fixed so that it also works
for the -,+,*, and / keys anywhere on the keyboard. For example
the ALT* is actually ALT-8, just press the key that has that symbol
on it somewhere. This can be changed in the keyboard handler, look
at the last part of the case statement.
- The ALT-<DEL> needs to be the one without the . if num-lock is on!
- Basically all of these scrap things are designed to work on the
keypad part of the extended keyboard. I guess I shouldn't say
keypad since it is that middle part with just the arrows and the
INSERT/HOME/PGUP/DEL/END/PGDOWN keys. NOT THE NUMERIC KEYPAD.
So if you are having problems getting this to work, try the other
pad. It works on my machine for ATL+, ALT-, ATL*, ATL/ on either
keypad, but ALT-<DEL> must be the middle one.
- The <ENTER> when insert is off bug is fixed. It used to not scroll
the window correctly.
CHECK THE IMPLEMENTED section for what is different. There are different
parameters since BETA 1 and also between BETA 4 and this one, so watch out!!!
Also added to the DOC section is the return code list for the keyboard handler.
There are also new functions in the HDR file that you can access.
With this BETA, you can EDIT files that are shorter than 80 lines
and if they are longer then only VIEW them.
These were written in FORCE using the VList library extensively.
The following text contains important information on what the editor
can and can't do. From BETA to BETA, this text will change in
different places throughout, so please re-read it for each BETA
you down/load.
When the final version arrives, it will include a registration
form/file that will give details on registration. You will also
need VLIST library in order to compile any application using this
library (VEDIT.LIB). Some functions in VLIST.LIB have been changed
to work better with VEDIT.LIB, so please register VLIST.LIB or you
most likely will not have the correct version. One of the changes
stops the program from locking up when out of memory. Source code
will also be made available at a cost in the future. Therefore you
can use this as a base to write a full text editor, or modify
it to suite your needs.
THINGS WILL CHANGE BETWEEN HERE AND THE FINAL VERSION so do not
get too comfortable with the parameters. I am not sure whether
I will make the colors sent through parameter or leave them as is.
GENERAL INFORMATION:
The editor can be configured for almost any size (please don't try
to make a 4x4 editor, it probablty won't work). The status line
(LINE/ROW/INSERT/SCRAP) can be positioned at any row,col. It is
around 40 characters, so it may not always fit at the bottom of your
editor window.
The VEditor (I guess we could call it) is based upon a two part
system. The first part loads a VList with lines of text. The
lines must ALL be the same length, padded out to whatever the
'hard-margin' is set to. This hard-margin is the maximum width
the text may be (132 max). The list is actually initialized to
'hard-margin + hard-margin/2' to give room for word wrapping and
a some work space when combining lines and such. This part is
also responsible for saving the list. The second part is the
actual editor and does all editing until the user wants to
save or quit, then control is returned to the first part with
a return code.
The seperation of VEditor in two parts makes it easy to use this
as either a TEXT or MEMO editor. Just replace part one's F_?????
calls with M_???? calls. I already did this for you. There are
two main functions, VEDIT_TEXT_EDITOR and VEDIT_MEMO_EDITOR. The
only parameter difference is the first, either file-name or
the memo name. For the memo name you must include the database
alias...
DBF_TEST->NOTES
The VEditor will add some 40K+ to your program, but this is actually
less when you consider some of that contains routines your program
will also use. Therefore it should be somewhat less. For example
the @SAY, FILL, F_????, M_????, VLIST_???? functions will not be
added twice, just once. So if you use VLIST menus already, then
the objects are already included in your program. If you don't
use any of these then I guess you have a 40k larger program...
The 2 functions are covered in the DOC section at the end of this
file. These are the only two that you will have direct access to
until registering, then there are others such as the word_wrap proc.
There is no text marking, YET you can accomplish most of the same
features through the use of the 'scrap'. This is covered below.
The VEditor uses a set line length method of storing the text. This
means that every line that you type, even if it is empty, will take
up the same space in memory. When saved, it will be trimmed of all
trailing spaces. I wrote the editor this way so that it would get
done. I figured you would live with an editor that could do 2000 line
text files rather than not having one at all. Its the best I can do
for now. Whatever you pass as the hard-margin will be the set line
length (actually a little longer). If you are reading a text file
that has lines out to 132 columns, and hard-margin is set to 90 then
they will be truncated to 90 and THEN word-wrapped. The max is 132.
Some of the items that are mentioned to be implemented may never make
it into V1.0 of VEditor, some will. This basically means I am not
guaranteeing (SP?) ANYTHING right now.
NOTEs about the MOUSE SCROLLBAR:
The scroll bar is an indicator that shows a relative position within
the file graphically. This can be displayed with or without mouse
usage. If a mouse is present, you can scroll the window by pressing
the left button on the top or bottom borders. By pressing the
buttom within the text area, the cursor moves to that location.
If you press the up-tab or down-tab on the scroll-bar, then the
line moves up or down one at a time. If you press the button
ON the scroll-bar, the current line will move towards your cursor
1 page at a time. There is NO SLIDING thing to grab such as in
windows. This acts the same as VLIST picklist/menu functions. Maybe
another day will I make it exactly like CUA but not for now.
COLOR USAGE:
To define which colors the VEditor will use, just set the normal
VList and FORCE colors. The following shows which colors are
used in which part of the editor. If this does not work well
for programming, then let me know and I will break them into
more colors and pass them all as parameters (except the main
text color, __color_std, the current line color, __color_enhcd,
and the scroll bar colors). In other words, you will send the
edit procedure the color values for the status line (hi/lo) and
also for any pop-up windows. Pop-up windows now use the same
colors as the scroll bar. Marked-text color is not implemented
since no text marking is in the VEditor.
Colors:
__color_std = main text color
__color_enhcd = current line text color
__color_tab = scroll bar tab AND bright status color AND pop-up
window text color
__color_bar = scroll bar AND dim status color AND pop-up window
border color
IMPLEMENTED FEATURES:
- WORD WRAPPING!! ( on file-read and during editting )
- Insert/Overwrite mode (press the insert key)
- Pg-Up / Pg-Down = move up and down one page height
- Ctrl-Pg-Up / Ctrl-Pg-Down = go to top or end of file
- Home = go to beginning of line
- End = go to end of text on line
- Ctrl-End = go to end of line (132th column)
this will be changed to only go to the right margin. Right now
the margin is the word wrap point, not the actual text limitation.
- Ctrl-Up / Ctrl-Down = move the window up or down 1 line
- MOUSE works to point to a part of text and to move the text using
the scroll-bar
- Ctrl-Right / Ctrl-Left = move word right/left
- Ctrl-Y / Alt-D = delete line
- ALT (keypad) - = delete line and place at end of scrap
- ALT (keypad) + = insert line from end of scrap (delete from scrap)
- ALT (keypad) * = insert all of scrap at current line (keep scrap)
- ALT (keypad) / = insert all of scrap at current line (delete
scrap)
- ALT - <DEL> = clear scrap buffer
- Right-Mouse-Button = while mouse cursor is in edit window, delete
CURRENT line and place at end of scrap
- Right-Mouse-Button = while cursor is positioned on the <SCRAP> status
line indicator, insert line from end of scrap
(delete from scrap)
- ALT-X = exit
- ALT-W = write file
- ALT-T = Toggle word wrap on/off
- The keyboard handler is now a function that is passed as a parameter,
therefore you can replace it with your own. From the keyboard
handler, you can change the window size and any of the other
parameters passed by reference. Just read the notes in KEYBOARD.PRG
(which is the default key handler) about how to do this. You
must set REFRESH=.T. before exitting.
- TAB now works as: When in overwrite, moves the cursor forward the
defined tab-stop. When in insert, adds the 'tab-stop' number of
spaces to the text. There are no TRUE tabs here. The tab-stop
value is passed as a parameter.
- ALT-S = save to new filename but ALT-W still saves to the old one.
- ALT-N = save to new filename and ALT-W will now use this filename.
- CTRL-W = write scrap to filename
- CTRL-R = read filename and append to scrap
- ALT-U = undelete last line deleted.
NON-IMPLEMENTED FEATURES (those not done yet):
- search and replace
REPORTING BUGS:
If you find any major bugs, please leave a message on the FORCE BBS or CI$
ID 71333,12 or 71740,1606 and let me know EXACTLY what happened.
DOCS: --------------------------------------------------------------------
The following lists the ProtoTypes for the two main edit functions.
FUNCTION UINT VEdit_Text_Editor PROTOTYPE
PARAMETERS CHAR filename,;
VALUE INT upper_row,;
VALUE INT upper_col,;
VALUE INT lower_row,;
VALUE INT lower_col,;
VALUE UINT start_line,;
VALUE UINT start_col,;
VALUE UINT right_margin,;
VALUE UINT hard_margin,;
VALUE BYTE m_text_color,;
VALUE LOGICAL word_wrap,;
VALUE LOGICAL disp_only,;
VALUE LOGICAL scroll_bar,;
VALUE LOGICAL stat_line,;
VALUE UINT stat_row,;
VALUE UINT stat_col,;
VALUE LOGICAL is_mouse,;
VALUE LOGICAL a_embedded,;
VALUE UINT tab_stop,;
VALUE UINT undelete_lines,;
UNTYPED key_handler
The return values are as follows:
0 - no errors
3 - error reading file
4 - error during edit of file (allows user to save anyway)
5 - error allocating memory (might just lock up for now)
6 - cannot open file when trying to save
The parameters are:
filename - PATH+NAME of file to load. This must be valid. No checking
is done other that making sure it exists, if not then it
comes up as a new file.
upper_row - upper left row coordinate for edit area
upper_col - upper left column coordinate for edit area
lower_row - lower right row coordinate for edit area
lower_col - lower right column coordinate for edit area
start_line - starting line number in the file to start editting at
start_col - starting column on 'start_line' to start editting at
right_margin - margin to start word wrapping at
hard_margin - margin to limit actual text to
m_text_color - ** NOT USED **
word_wrap - logical of whether editor starts in word wrap mode
disp_only - logical of whether the file is display only, or can be
altered and saved.
scroll_bar - do you want the scroll bar displayed? It is displayed at
'lower_col + __scroll_offset' just like normal VList stuff.
stat_line - do you want status line displayed?
stat_row - row to display status line if 'stat_line' is TRUE
stat_col - column to display status line if 'stat_line' is TRUE
is_mouse - is mouse present and driver initialized?
a_embedded - allow embedded color characters in text. This slows things
down. The __embed_char is the character used to change
the color to __color_hi_std or __color_hi_enhcd for the
character immediately following it.
tab_stop - the number of spaces that one tab is equal to.
undelete_lines - number of lines allowed to un-delete
key_handler - the UDF function to handle key-strokes and mouse movements.
The default that you can use is VEDIT_KEY_HANDLER.
---- AND FOR THE VEDIT_MEMO_EDITOR, just change the first parameter to:
MEMO memoname
This should be the database alias followed by the name of the field.
ex. dbf->memo
test->notes
mia_mya->tag
COMPILING/LINKING:
Your program must include VLIST.HDR and VEDIT.HDR, also the VMOUSE.HDR
is you are using mouse support. Other mouse libraries will 'probably'
work since I just go directly to the interrupt. Then compile:
FORCE /ci /v65000 <filename>
If you want to reduce the code a little more, just compile with
FORCE /n /ci /v65000 <filename>
to remove stack checking. I hope your stack is correct, else you may get
lock-ups. If your program works fine with no run-time errors and it has
been thouroughly tested then use this.
Then you must link:
LINK <filename>,,,VEDIT+VLIST+FORCE
or
BLINKER FI <filename> SEARCH VEDIT+VLIST+FORCE
...AND YOU ARE ON YOUR WAY...
*******************************************************************************
* return codes for MEMO editor *
* 0 - no errors *
* *
* 3 - error reading memo *
* 4 - error editting memo *
* 5 - error allocating memory *
* 6 - cannot open memo to save *
*******************************************************************************
FUNCTION UINT VEdit_Memo_Editor PROTOTYPE
PARAMETERS MEMO memoname,;
VALUE INT upper_row,;
VALUE INT upper_col,;
VALUE INT lower_row,;
VALUE INT lower_col,;
VALUE UINT start_line,;
VALUE UINT start_col,;
VALUE UINT right_margin,;
VALUE UINT hard_margin,;
VALUE BYTE m_text_color,;
VALUE LOGICAL word_wrap,;
VALUE LOGICAL disp_only,;
VALUE LOGICAL scroll_bar,;
VALUE LOGICAL stat_line,;
VALUE UINT stat_row,;
VALUE UINT stat_col,;
VALUE LOGICAL is_mouse,;
VALUE LOGICAL a_embedded,;
VALUE UINT tab_stop,;
VALUE UINT undelete_lines,;
UNTYPED key_handler
KEYBOARD HANDLER -------------------------------------------------------------
The keyboard handler is passed as a parameter to the edit routine and it will
be called everytime a mouse button is pressed or a key-stroke is done. The
resulting code can be altered or changed to cause the editor to react
differently to each action.
An easy way to change this is to create your own keyboard handler that uses
the same PROTOTYPE as the VEDIT_KEY_HANDLER and have it filter key-strokes
and then call the VEDIT_KEY_HANDLER and then filter actions before
returning to the editor. OR you can copy the file KEYBOARD.PRG and
make your own. I would rename the file AND the function name to
something different to preseve the old one since you might want something
different for each program.
The key handler works very similar to the VLIST key handlers. Read the
VLIST key handlers for information on how the mouse works and for the
normal keyboard activities. These DOCs come with the registered version
of VLIST.
The following is a list of NEW macros beyond the VLIST macros that
have an effect on the editor. Some ARE NOT implemented yet but have
a value. These have an (*) in the left column.
&JL_SAVE_EXIT - exit the editor but ask to save first
&JL_SAVE_CONTINUE - save the file and continue editting
* &JL_START_MARK - start marking at the current line
* &JL_END_MARK - end marking at the current line
&JL_TOGGLE_WRAP - turn word wrap on/off
* &JL_MARK_LINE - mark this one line
* &JL_UNMARK_ALL - unmark all marked text
* &JL_DELETE_MARKED - delete marked text
* &JL_SAVE_MARKED - save marked text
* &JL_COPY_MARKED - copy marked text to current location
* &JL_MOVE_MARKED - move marked text to current location
* &JL_IMPORT - import a file to the current location
&JL_SAVE_AS - save the file to a new filename, same as &JL_SAVE_AS_NEW
&JL_DELETE_LINE - delete current line
&JL_DELETE_TO_SCRAP - delete current line and place at end of scrap
&JL_SAVE_SCRAP - save scrap to disk
&JL_READ_SCRAP - read file and append to scrap
&JL_DELETE_SCRAP - delete all of scrap
&JL_COPY_ALL_SCRAP - copy all of scrap to current location and retain scrap
&JL_COPY_TOP_SCRAP - copy the top line of the scrap and delete it
&JL_COPY_BOTTOM_SCRAP - copy the bottom line of the scrap and delete it
&JL_COPY_ALL_SCRAP_DELETE - copy all of the scrap to the current location
and delete the whole scrap.
&JL_SAVE_AS_NEW - save file as a new filename, the old filename is retained
for a normal save.
&JL_SAVE_RENAME - save file as a new filename, all saves will now use this
filename.
&JL_UNDELETE_LINE - undelete last line deleted
The prototype for the edit handler is:
FUNCTION INT VEdit_Key_Handler PROTOTYPE
PARAMETERS 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
OTHER FUNCTIONS --------------------------------------------------------------
PROCEDURE VEdit_Change_Byte PROTOTYPE
PARAMETERS VALUE UINT position,;
VALUE INT new_byte,;
CHAR full_str
Changes one bye within a passed string.
*****
FUNCTION UINT VEdit_Forward_Space PROTOTYPE
PARAMETERS CHAR temp_str,;
UINT current_col
Returns the position of the next space in a string starting at the
'current_col'. If there are no more spaces, it returns a 0. If
current_col is not at the end of the line, and there are no more
spaces then the cursor is moved to the position after the last letter
on the line. If the cursor is already past the last letter, then a
0 is returned.
*****
FUNCTION UINT VEdit_Backward_Space PROTOTYPE
PARAMETERS CHAR temp_str,;
UINT current_col
Returns the position of the last space in a string starting at the
'current_col'. If there are no more spaces, it returns a 0. It will
return 1 if current_col is > 1 and there are no spaces to the left. If
current_col = 1, then it will return 0. This was designed for the
CTRL-LEFT movement.
*****
FUNCTION UINT VEdit_Last_Space PROTOTYPE
PARAMETERS VALUE UINT right_margin,;
CHAR temp_str
Returns the last space in a string starting at the right margin and
working its way backwards. Designed for the word wrapping.
*****
PROCEDURE VEdit_Word_Wrap PROTOTYPE
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
This word wraps lines in the list starting at 'mini' and going forward.
'BLP' means to stop after what it considers a paragraph OR if it finds
the first line that does not need wrapping. If BLP is .T., then the
'current_element' and 'current_column' are updated to move the cursor
to the line that they should be on in case the text to the left of
the current position is wrapped to the next line. If BLP is .F. then
the complete list from 'mini' to the end is checked.
Right_margin is the word-wrap margin, while hard-margin is the actual
text limit.
*****
The following #DEFINES are returned from the VEDIT_INTERNAL_EDITOR
to either VEDIT_TEXT_EDITOR or VEDIT_MEMO_EDITOR as the current state.
#DEFINE edit_error
an error occured during editting.
#DEFINE edit_none
nothing significant happened, just exit.
#DEFINE edit_save_exit
ask to save, then exit.
#DEFINE edit_save_continue
save and then continue editting.
#DEFINE edit_continue
just continue editting in case someone resized the window and I want
to run through the VEDIT_INTERNAL_EDITOR initialization which
does all of the boundary checking and so on...
#DEFINE edit_save_as_new
save file to new filename, retain old filename for saving to later,
go back and continue editting.
#DEFINE edit_save_rename
save file to new filename and use this filename from now on for future
saves. Go back and continue editting.
#DEFINE edit_save_scrap
save scrap to filename and continue editting
#DEFINE edit_read_scrap
read a file and append to end of scrap
*****
FUNCTION UINT VEdit_Internal_Editor PROTOTYPE
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_width,;
VALUE UINT undelete_lines,;
UNTYPED key_handler
This is the internal version of the editor which just edits a VLIST. The
parameters are similar to VLIST_TEXT_EDIT and VLIST_MEMO_EDIT except
for the parameter FLASH which will cause the text to be displayed and
then the editor immediately exitted.