Mr. Edit

Mr. Edit

Mr. Edit is the Clipper library that gives you absolute control over your application's memos. To Mr. Edit, a memo is an object, built to your specifications and handed back to you to manipulate as you wish. To you, Mr. Edit is a collection of text editing tools and concepts. The functions described below are grouped according to purpose. Where that purpose might not be obvious from the group heading, or wherever we felt like telling you more, we have added extra commentary.

Download Mr. Edit Demo


Create and destroy memos. meCreate() lets you define the maximimum size of the memo, both in number of characters and number of lines. No more worries about users putting 8 lines of notes in a 4 line memo, or 600 characters of notes in one 500-character field.

meCreate() Create a memo object

meDestroy() Destroy a memo object, release allocated memory

Modify Text Buffer:

Text is added to the memo's text buffer via meApplyKey() (one key at a time), meInsertText() (insert a string or block of text at the cursor position), and meSetText() (replace the entire contents of the memo with new text).

meApplyKey() Place a key in the memo

meInsertText() Place a string into the text buffer

meSetText() Set the memo's text buffer to a new string

Deletion is accomplished in many ways; the meDelete() function takes an optional argument specifying the number of characters to the right of the cursor to be deleted; the default is one character. If text is marked (using meBlockOn() or meDropAnchor()) and meDelete() is called without specifying the number of characters to delete, the entire highlighted block will be deleted. Code samples are provided to demonstrate when this is a really handy feature, and when you might want to provide your users with a Whoops clause to undelete a block.

meBackSpace() Backspace one character

meDelete() Delete one or more characters

meDelEOL() Delete from current cursor position to end of line

meDelLine() Delete the current line

meDelWordLeft() Delete the word to the left

meDelWordRight() Delete the word to the right

Extract Text from Buffer:

Take a letter, take a line, take a block, take the whole darned thing! This is how to persuade Mr. Edit to hand over some or all of the text. These functions do not remove the text from the memo object (only the delete functions do that)+; they simply give you a copy of the requested data.

meGetChar() Get character at cursor position

meGetLine() Get the current line of text with or without expanded tabs

meGetMarkedText() Get contents of marked block

meGetText() Get a copy of the current memo text


Most of these functions require little explanation, except to say that meUp(), meDown(), meScroll(), meLeft() and meRight() take an optional argument specifying how many rows or columns to move in the designated direction. If the optional argument is not specified, they default to moving one row or column.

meBOF() Is the cursor positioned at the start of memo?

meDown() Move the cursor down

meEnd() Move the cursor to the end of the line

meEOF() Is the cursor positioned at the end of the memo?

meGoBottom() Move the cursor to the end of the memo

meGoto() Move text cursor position to nLine, nCol

meGoTop() Move the cursor to the beginning of the memo

meHome() Move the cursor to the beginning of the line

meLeft() Move the cursor to the left

mePageDown() Move cursor down one page

mePageUp() Move cursor up one page

meRight() Move the cursor to the right

meScreenGoto() Go to a screen coordinate

meScroll() Scroll the memo text up/down in the display window

meUp() Move the cursor up

meWordBegin() Move the cursor to the beginning of current word

meWordEnd() Move the cursor to the end of current word

meWordLeft() Move the cursor one word to the left

meWordRight() Move the cursor one word to the right

Memo Status:

These functions provide the vital statistics of the memo: How big is it now? How big can it get? What line is the cursor on? At what column position on that line is the cursor? Is there more text below the bottom of the window?

meBuffSize() Returns the memo object's buffer size

meColPos() Returns the column the cursor is in

meIsChanged() Were changes made to the memo?

meIsMore() Is there more text below the bottom of the window

meLineCount() Returns the number of lines in the memo

meLinePos() Returns the line containing the cursor

meMaxLines() Returns the maximum number of lines allowed

meTextLen() Returns the current length of the memo

meWinCol() Returns the current cursor column within window

meWinRow() Returns the current cursor row within window.


When you are performing sleight-of-hand wizardry, or changing the memo's default display characteristics, you'll want to turn off the screen updates until the memo is all dressed up with someplace to go. Mr. Edit's display handling functions behave in the same way as Clipper's dispbegin() and dispend().

meDispBegin() Begin buffering screen output

meDispEnd() Decrement screen buffering counter, display updates

Some useful functions for detecting keystrokes: Did the user press Ctrl+X, indicating a desire to cut a block to the clipboard, or was that just the Down Arrow key? Inkey() alone won't tell you... but Mr. Edit will.

meIsAlt() Is ALT key depressed?

meIsCtrl() Is CTRL key depressed?

meIsShift() Is SHIFT key depressed?


These are some of the most powerful weapons in Mr. Edit's arsenal.

Mr. Edit implements five kinds of blocks for the editing pleasure of your users.

There are blocks that include the cursor and blocks that don't, and _those_ come in two modes:

1. Typing new characters just makes the the block bigger.

2. Borrowing from the GUI world, the first character typed (or inserted via meInsertText()) causes the block to be deleted before the new text is added.

Because you'll occasionally want it, and because we can, we give you block marking a line at a time.

Mr. Edit also offers anchors which bear a striking similarity to blocks. The difference is in the way they are implemented. Blocks are intended for manipulation by the user and there is only one. Anchors are yours, all yours, to pull off feats of magic behind the scenes without affecting your user's blocks.

Block Handling:

meBlockOff() End block/mark mode

meBlockOn() Begin block/mark mode

meBlockSize() Get the size of the highlighted block of text

meBlockSwap() Swap the start/end positions of a marked block

meBlockType() If block mode is on, what is the current type?

meGetMarkedText() Get contents of marked block

meIsBlock() Is memo in block mode?


meDropAnchor() Drop an anchor to start block mode processing

meIsAnchorBelow() Is the anchor below the cursor position?

meRaiseAnchor() Remove an anchor placed by meDropAnchor()


Oh, they're not much to look at-- in fact, they're invisible to the naked eye, but the first time they help you pull a rabbit out of a hat you'll appreciate their simple elegance. Bookmarks let you mark a spot now that you can return to in the future, without having to worry about the editing that happens in between. Mr. Edit makes sure that the bookmarks take you to the exact position in the text you marked. And to make sure you never run out, we give you 32 bookmarks for each memo.

meClearBookmarks() Clear out memo object's array of bookmarks

meFreeBookmark() Release a bookmark

meGotoBookmark() Move the cursor to the location stored in bookmark

meSetBookmark() Place a bookmark in the memo's text buffer

Save/Restore Memo:

meSaveMemo() enables you to capture the state of a memo object and store it to persistent media (e.g., write it to an ascii file on disk or store it in a memo field of a DBF file). The complementary function, meRestMemo() will take the memo object and the string returned by meSaveMemo(), and restore the memo to that captured state. The cursor will be just where the user left it, any highlighted text will still be highlighted, bookmarks will still be in place... as if the editing had]+chr(13) never been interrupted.

meRestMemo() Restore internal state of memo from a magic string

meSaveMemo() Save the memo's internals to a string


Just the thing for finding those missing words or fixing the spelling of "thigamabob".

meFindChar() Move cursor to first instance of a char in a set

meSearch() Search for a string in memo from current position

Everything you need to control the look, feel and position of the memo. It's your memo object-- have it your way!

meSetBottom() Set/Get memo object's bottom display row

meSetColor() Set/Get the memo colors

meSetColTracker() Set/Get status of memo's column tracker

meSetCRMark() Set/Get the current CR mark

meSetEOFMark() Set/Get the memo object's EOF display character

meSetInsert() Set/Get the insert mode for memo

meSetLeft() Set/Get memo object's left column

meSetLineWidth() Set/Get function for line width

meSetPanCols() Set/Get number of columns to pan

meSetRight() Set/Get memo object's right column

meSetTabMark() Set/Get the current TAB mark

meSetTabSize() Set/Get number of spaces between tab stops

meSetTop() Set/Get memo object's top row

meSetWordDelim() Set/Get the delimiters for next/previous word]

Download Mr. Edit Demo