home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 5 Edit
/
05-Edit.zip
/
NOTEPAD2.ZIP
/
MFUNCS.H
< prev
next >
Wrap
Text File
|
1989-02-08
|
13KB
|
353 lines
/*
* mfuncs.h -- Global functions within MLE
*
* Created by Microsoft Corporation, 1989
*/
#define private // keyword for a function local to a module
#define public // keyword for a global function
/***********************************************************************
* Generally important constants
***********************************************************************/
#define QWP_PED QWL_USER
#define TID_MOUSESCROLL 1
/***********************************************************************
* Global functions
***********************************************************************/
public VOID InitInstance(HWND hwnd);
// Initializes an MLE window
MRESULT CALLBACK MleWndProc(HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2);
// Window procedure for MLE
/***********************************************************************
* Owner Notification functions
***********************************************************************/
public VOID NotifyOwner(PED ped, USHORT usENCode, MPARAM mparam);
// Notifies the ownder of some event
public VOID NotifyScroll(PED ped, SHORT usCode, BOOL fForce);
// Notifies the owner in case of scroll
/***********************************************************************
* Memory Manager functions
***********************************************************************/
public PVOID AllocStore(PED ped, USHORT size);
// Allocate size bytes
public VOID FreeStore(PED ped, PVOID p);
// Releases memory allocated by AllocStore
public BOOL InitStore(PED ped);
// Initializes memory manager; must be called before other mm ops
/***********************************************************************
* Text Manager Functions
***********************************************************************/
public BOOL TxtInit(PED ped);
// Initializes the text manager
public BOOL TxtChange(PED ped, IPT iptFrom, IPT iptTo, PCHAR pch, OFFSET cch);
// Change text in MLE
public VOID TxtReformat(PED ped, PPR ppr, BOOL fAllText);
// Reformats text with changed area starting at ppr
public IPT TxtLength(PED ped);
// Length of text in MLE
public IPT TxtLineLength(PED ped, PPR ppr);
// Return the length of line containing a piece
public IPT TxtLengthToEOL(PED ped, IPT ipt, BOOL fIncludeLBCh);
// Return the length from an ipt to the end of line
public IPT TxtLengthToEOLPPR(PED ped, PPR ppr, OFFSET off, BOOL fIncludeLBCh);
// Return the length from a ppr/offset to the end of line
public IPT TxtLengthToBOL(PED ped, IPT ipt);
// Return the length from an ipt to the beginning of line
public IPT TxtLengthToBOLPPR(PED ped, PPR ppr, OFFSET off);
// Return the length from a ppr/offset to the beginning of line
public IPT TxtCchToBegOfToken(PPR ppr, OFFSET off);
public IPT TxtCchToEndOfToken(PPR ppr, OFFSET off);
// Return the characters to the beginning (end) of a token
public BOOL TxtQueryWordWrap(PED ped);
// Return the word wrap status of a document
public BOOL TxtSetWordWrap(PED ped, BOOL fWW);
// Set the word wrap status of a document
public IPT TxtQueryAnchor(PED ped);
public IPT TxtQueryCursor(PED ped);
public IPT TxtQueryMinSel(PED ped);
public IPT TxtQueryMaxSel(PED ped);
// Query the anchor and cursor positions
public IPT TxtSetAnchorCursor(PED ped, IPT iptAnchor, IPT iptCursor);
// Set the anchor and/or cursor position
public BOOL TxtSetLimit(PED ped, IPT iptMax);
// Set the text limit
public BOOL TxtQueryChanged(PED ped);
// Returns current change status
public BOOL TxtSetChanged(PED ped, BOOL fChanged);
// Sets the change flag to a particular value; sends EN_CHANGE if needed
public PPR TxtPPROfIpt(PED ped, PIPT pipt);
// Finds the piece and offset associated with a particular offset
/***********************************************************************
* Clipboard functions
***********************************************************************/
public BOOL TxtClipCut(PED ped, IPT iptFrom, IPT iptTo);
// Cut the given range to the clipboard
public BOOL TxtClipCopy(PED ped, IPT iptFrom, IPT iptTo);
// Copy the given range to the clipboard
public BOOL TxtClipPaste(PED ped, IPT iptFrom, IPT iptTo);
// Paste from the clipboard, replacing the given range
public BOOL TxtClipClear(PED ped, IPT iptFrom, IPT iptTo);
// Clear the given range
/***********************************************************************
* Piece manager functions
***********************************************************************/
public PPR PieceInit(PED ped, OFFSET offSize);
// initializes piece manager
public IPT PieceLength(PPR ppr);
// returns length of a piece
public PPR CreateSizedPiece(PED ped, OFFSET cchMin, OFFSET cchReq);
// create a new piece of a given size
public PCHAR InsEndChars(PED ped, PPPR pppr, POFFSET pcch);
// reserve *cch characters at the end of a piece for insertion
public PMR InsEndMarker(PED ped, PPR ppr, USHORT fFlags);
// inserts a marker piece after ppr in text order
public PMR InsBeforeMarker(PED ped, PPR ppr, USHORT fFlags);
// inserts a marker piece before ppr in text order
public PPR DelStartChars(PED ped, PPR ppr, OFFSET cch);
// delete cch charactes from the beginning of a piece
public PPR DelEndChars(PED ped, PPR ppr, OFFSET cch);
// delete cch characters from the end of a piece
public PPR DelMarker(PED ped, PMR pmr);
// delete a marker piece
public PPR SplitPiece(PED ped, PPR pprLeft, OFFSET cch);
// split a piece into two pieces at a given point
public PPR ConditionalSplitPiece(PED ped, PPR pprLeft, OFFSET cch);
// split a piece into two pieces at a given point, if they aren't already
public PPR AppendSegment(PED ped, PPR ppr, SEL sel, OFFSET cch);
// appends a segment full of text in fastest possible way
public PPR PprOfOffset(PPR ppr, PIPT poffCh);
// given a ppr, finds ppr *poffCh chars later and offset into that piece
public BOOL fIsMarker(PPR ppr);
// returns whether a piece is a marker piece or not
#define fIsMarkerType(ppr, mtype) (fIsMarker(ppr) && (((PMR)ppr)->fFlags & (mtype)))
// helper macro -- whether a piece is a marker of a given type or not
public PPR SkipMarkers(PPR ppr, USHORT fMask);
// returns the first non-matching piece, searching from ppr along 'next'
public PPR SkipText(PPR ppr, USHORT fMask);
// returns the first matching marker piece, searching from ppr along next
public PPR SkipBackText(PPR ppr, USHORT fMask);
// returns the first matching marker piece, searching from ppr along prev
public BOOL LockMarker(PMR pmr, BOOL fLocked);
// locks or unlocks a marker piece (locked => no delete)
public CHAR AdvancePointer(PPPR pppr, POFFSET poff);
// moves *pppr / *poff one char further along the text chain
public CHAR RetreatPointer(PPPR pppr, POFFSET poff);
// moves *pppr / *poff one char previous along the text chain
public CHAR CharOfPointer(PPR ppr, OFFSET off);
// returns the character at a given point in text
/***********************************************************************
* Mouse manager functions
***********************************************************************/
public VOID MouseInit(PED ped);
// Initializes mouse manager
public VOID ProcessMouse (PED ped, USHORT nMessage, SHORT x, SHORT y);
// processes one mouse message
/***********************************************************************
* Keyboard manager functions
***********************************************************************/
public BOOL KbdInit(PED ped);
// initializes the Keyboard Manager
public VOID ProcessKey (PED ped, USHORT usVirtKey, USHORT usChar,
USHORT fus, SHORT cchRepeats);
// processes one keyboard message
public BOOL SetTyping(PED ped, BOOL fTyping);
// sets typing mode on or off
public BOOL QueryTyping(PED ped);
// returns the current typing mode
/***********************************************************************
* Pixel-mapping functions
***********************************************************************/
public PIX TabWidth(PED ped, PIX pix);
// returns pixel width of a tab starting at pix
public PIX PixOfChar(PED ped, PIX pix, CHAR ch);
// returns pixel width of any character, starting at pix
public PIX SetTabWidth(PED ped, PIX TabSize);
// sets tab-width
public PIX QueryTabWidth(PED ped);
// returns current tab-width setting
public PIX PixFromText(PED ped,PPPR pppr,POFFSET poff,OFFSET cch,PIX pixStart);
// returns pixel width of a run of text on one line
public IPT TextFromPix(PED ped, PPPR pppr, POFFSET poff,
PPIX ppix, USHORT usMode);
// finds the text position in a line associated with a pixel index
/***********************************************************************
* Buffer Manager functions
***********************************************************************/
public VOID BufInit(PED ped);
// initializes buffer manager
public BOOL BufSetBuf(PED ped,PCHAR pch,USHORT usLen);
// Sets the default transfer buffer and size
public PCHAR BufQueryBuf(PED ped);
// Queries the default transfer buffer
public USHORT BufQueryBufSize(PED ped);
// Queries size of the default transfer buffer
public BOOL BufSetFormat(PED ped,USHORT usFmt);
// Sets the default transfer format
public USHORT BufQueryFormat(PED ped);
// Queries the default transfer format
public IPT BufFormattedSize(PED ped, IPT iptFrom, IPT iptTo, USHORT usFormat);
// returns the number of bytes required to hold the text in usFormat
public OFFSET BufCopyOut(PED ped, IPT iptFrom, USHORT usFormat,
PSZ pszBuff, OFFSET cch);
// copies formatted text from edit control to a buffer
public BOOL BufCopyIn(PED ped, IPT iptFrom, IPT iptTo,
PSZ pszBuff, OFFSET cch);
// copies formatted text from a buffer to edit control
/***********************************************************************
* Display Manager functions
***********************************************************************/
public VOID DisplayInit(PED ped);
// initializes display manager
public VOID SetFocus(PED ped, BOOL fReceiveFocus);
// get or lose focus
public VOID DispChangeFont(PED ped, PFATTRS pfattrs);
// set the drawing font
public VOID DispChangeSize (PED ped, USHORT xWndPels, USHORT yWndPels);
// handle change in window size
public PIX DispWidth(PED ped);
// returns width of display area, in pixels
public LINE DispHeight(PED ped);
// returns number of lines displayable on screen
public VOID DispRefresh(PED ped, BOOL fForce, RECTL rcl);
// causes the display to refresh itself
public VOID DispHScroll(PED ped, PIX dx, BOOL fNotify);
// changes the horizontal scrolling by dx
public VOID DispHScrollTo(PED ped, PIX x, BOOL fNotify);
// sets the horizontal scrolling to x
public VOID DispVScroll(PED ped, LINE dy, BOOL fNotify);
// changes the vertical scrolling by dy lines
public VOID DispVScrollToIPT(PED ped, IPT ipt, BOOL fNotify);
// sets the vertical scrolling to line containing ipt
public VOID DispSetCursorXY(PED ped, PIX x, PIX y, BOOL fExtend, BOOL fWord);
// sets the cursor to an x,y position on the screen
/***********************************************************************
* Assembler utility functions
***********************************************************************/
public USHORT MultDivNR(USHORT a, USHORT b, USHORT c);
// returns (a*b)/c with long intermediates
/***********************************************************************
* Generally useful macros
***********************************************************************/
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define abs(x) ((x) >= 0 ? (x) : -(x))
#define FORCE(iMin,iMac,i) (((i)<(iMin))?(iMin):(((i)>(iMac))?(iMac):(i)))
// force i into the range [iMin, iMac]
#define LOSHORTFROMMP(mp) SHORT1FROMMP(mp) // synonyms for standard macros
#define HISHORTFROMMP(mp) SHORT2FROMMP(mp)
/* Get a pointer to the edit record associated with an MLE window. */
#define GETPED(hwnd) ((PED)WinQueryWindowPtr((hwnd),QWP_PED))
// characters considered whitespace in a line
#define fIsWhiteSpace(ch) (((ch)==' ') || ((ch)=='\t'))
// Sets a rectangle to all-zero.
#define ZeroRect(rcl) (LFillStruct((PCH)&(rcl),sizeof(RECTL),(BYTE)0))