00001 #ifndef __SCINTILLAIF_H__
00002 #define __SCINTILLAIF_H__
00003
00004 #include "scintilla.h"
00005
00007 const int blockSize = 131072;
00008
00010 typedef long(__cdecl* scmsgfn)(void *ptr, long Msg, WPARAM wParam, LPARAM lParam);
00011
00012 typedef enum {efsVSNet, efsVSNetR, efsPlus, efsArrow} EFoldStyle;
00013
00019 class CScintilla
00020 {
00021 public:
00023 CScintilla();
00024
00026 ~CScintilla();
00027
00029 HWND Create(HWND hParent, HINSTANCE hInst);
00030
00032 bool OpenFile(LPCTSTR filename);
00033
00035 bool SaveFile(LPCTSTR filename);
00036
00043 bool IsScintillaNotify(LPARAM lParam);
00048 void HandleNotify(LPARAM lParam);
00049
00051 bool GetModified();
00052
00057 virtual inline long SPerform(long Msg, WPARAM wParam=0, LPARAM lParam=0)
00058 {
00059 if (Perform)
00060 return Perform(m_Pointer, Msg, wParam, lParam);
00061 else
00062 return ::SendMessage(hWnd, Msg, wParam, lParam);
00063 }
00064
00065 void DefineMarker(int marker, int markerType, COLORREF fore, COLORREF back);
00066
00067
00069
00071
00073
00075
00077
00078
00079 protected:
00080
00081
00082
00084 static HMODULE scidll;
00086 static int refs;
00087
00089 HWND hWnd;
00091 void *m_Pointer;
00093 scmsgfn Perform;
00094
00096 bool m_Modified;
00098 void GetRange(int start, int end, char *text);
00099
00100
00101 public:
00109
00110
00114 void AddText(int length, const char* text);
00118 void AddStyledText(int length, char* c);
00122 void InsertText(long pos, const char* text);
00126 void ClearAll();
00130 void ClearDocumentStyle();
00134 int GetLength();
00138 int GetCharAt(long pos);
00142 long GetCurrentPos();
00146 long GetAnchor();
00150 int GetStyleAt(long pos);
00154 void Redo();
00159 void SetUndoCollection(bool collectUndo);
00163 void SelectAll();
00168 void SetSavePoint();
00173 int GetStyledText(TextRange* tr);
00177 bool CanRedo();
00181 int MarkerLineFromHandle(int handle);
00185 void MarkerDeleteHandle(int handle);
00189 bool GetUndoCollection();
00194 int GetViewWS();
00198 void SetViewWS(int viewWS);
00202 int PositionFromPoint(int x, int y);
00207 int PositionFromPointClose(int x, int y);
00211 void GotoLine(int line);
00215 void GotoPos(long pos);
00220 void SetAnchor(long posAnchor);
00225 int GetCurLine(int length, char* text);
00229 long GetEndStyled();
00233 void ConvertEOLs(int eolMode);
00237 int GetEOLMode();
00241 void SetEOLMode(int eolMode);
00247 void StartStyling(long pos, int mask);
00252 void SetStyling(int length, int style);
00256 bool GetBufferedDraw();
00261 void SetBufferedDraw(bool buffered);
00266 void SetTabWidth(int tabWidth);
00270 int GetTabWidth();
00275 void SetCodePage(int codePage);
00280 void SetUsePalette(bool usePalette);
00284 void MarkerDefine(int markerNumber, int markerSymbol);
00288 void MarkerSetFore(int markerNumber, COLORREF fore);
00292 void MarkerSetBack(int markerNumber, COLORREF back);
00296 void MarkerAdd(int line, int markerNumber);
00300 void MarkerDelete(int line, int markerNumber);
00304 void MarkerDeleteAll(int markerNumber);
00308 int MarkerGet(int line);
00312 int MarkerNext(int lineStart, int markerMask);
00316 int MarkerPrevious(int lineStart, int markerMask);
00320 void SetMarginTypeN(int margin, int marginType);
00324 int GetMarginTypeN(int margin);
00328 void SetMarginWidthN(int margin, int pixelWidth);
00332 int GetMarginWidthN(int margin);
00336 void SetMarginMaskN(int margin, int mask);
00340 int GetMarginMaskN(int margin);
00344 void SetMarginSensitiveN(int margin, bool sensitive);
00348 bool GetMarginSensitiveN(int margin);
00352 void StyleClearAll();
00356 void StyleSetFore(int style, COLORREF fore);
00360 void StyleSetBack(int style, COLORREF back);
00364 void StyleSetBold(int style, bool bold);
00368 void StyleSetItalic(int style, bool italic);
00372 void StyleSetSize(int style, int sizePoints);
00376 void StyleSetFont(int style, const char* fontName);
00380 void StyleSetEOLFilled(int style, bool filled);
00384 void StyleResetDefault();
00388 void StyleSetUnderline(int style, bool underline);
00392 void StyleSetCase(int style, int caseForce);
00396 void StyleSetCharacterSet(int style, int characterSet);
00400 void SetSelFore(bool useSetting, COLORREF fore);
00404 void SetSelBack(bool useSetting, COLORREF back);
00408 void SetCaretFore(COLORREF fore);
00412 void AssignCmdKey(DWORD km, int msg);
00416 void ClearCmdKey(DWORD km);
00420 void ClearAllCmdKeys();
00424 void SetStylingEx(int length, const char* styles);
00428 void StyleSetVisible(int style, bool visible);
00432 int GetCaretPeriod();
00436 void SetCaretPeriod(int periodMilliseconds);
00441 void SetWordChars(const char* characters);
00446 void BeginUndoAction();
00450 void EndUndoAction();
00454 void IndicSetStyle(int indic, int style);
00458 int IndicGetStyle(int indic);
00462 void IndicSetFore(int indic, COLORREF fore);
00466 COLORREF IndicGetFore(int indic);
00472 void SetStyleBits(int bits);
00476 int GetStyleBits();
00480 void SetLineState(int line, int state);
00484 int GetLineState(int line);
00488 int GetMaxLineState();
00492 bool GetCaretLineVisible();
00496 void SetCaretLineVisible(bool show);
00500 COLORREF GetCaretLineBack();
00504 void SetCaretLineBack(COLORREF back);
00510 void AutoCShow(int lenEntered, const char* itemList);
00514 void AutoCCancel();
00518 bool AutoCActive();
00523 long AutoCPosStart();
00527 void AutoCComplete();
00531 void AutoCStops(const char* characterSet);
00536 void AutoCSetSeparator(int separatorCharacter);
00540 int AutoCGetSeparator();
00544 void AutoCSelect(const char* text);
00549 void AutoCSetCancelAtStart(bool cancel);
00553 bool AutoCGetCancelAtStart();
00557 void AutoCSetFillUps(const char* characterSet);
00561 void AutoCSetChooseSingle(bool chooseSingle);
00565 bool AutoCGetChooseSingle();
00569 void AutoCSetIgnoreCase(bool ignoreCase);
00573 bool AutoCGetIgnoreCase();
00577 void UserListShow(int listType, const char* itemList);
00581 void AutoCSetAutoHide(bool autoHide);
00585 bool AutoCGetAutoHide();
00589 void SetIndent(int indentSize);
00593 int GetIndent();
00598 void SetUseTabs(bool useTabs);
00602 bool GetUseTabs();
00606 void SetLineIndentation(int line, int indentSize);
00610 int GetLineIndentation(int line);
00614 long GetLineIndentPosition(int line);
00618 int GetColumn(long pos);
00622 void SetHScrollBar(bool show);
00626 bool GetHScrollBar();
00630 void SetIndentationGuides(bool show);
00634 bool GetIndentationGuides();
00639 void SetHighlightGuide(int column);
00643 int GetHighlightGuide();
00647 int GetLineEndPosition(int line);
00651 int GetCodePage();
00655 COLORREF GetCaretFore();
00659 bool GetUsePalette();
00663 bool GetReadOnly();
00667 void SetCurrentPos(long pos);
00671 void SetSelectionStart(long pos);
00675 long GetSelectionStart();
00679 void SetSelectionEnd(long pos);
00683 long GetSelectionEnd();
00687 void SetPrintMagnification(int magnification);
00691 int GetPrintMagnification();
00695 void SetPrintColourMode(int mode);
00699 int GetPrintColourMode();
00703 long FindText(int flags, TextToFind* ft);
00707 void FormatRange(bool draw, long fr);
00711 int GetFirstVisibleLine();
00716 int GetLine(int line, char* text);
00720 int GetLineCount();
00724 void SetMarginLeft(int pixelWidth);
00728 int GetMarginLeft();
00732 void SetMarginRight(int pixelWidth);
00736 int GetMarginRight();
00740 bool GetModify();
00744 void SetSel(long start, long end);
00749 int GetSelText(char* text);
00754 int GetTextRange(TextRange* tr);
00758 void HideSelection(bool normal);
00762 int PointXFromPosition(long pos);
00766 int PointYFromPosition(long pos);
00770 int LineFromPosition(long pos);
00774 int PositionFromLine(int line);
00778 void LineScroll(int columns, int lines);
00782 void ScrollCaret();
00786 void ReplaceSel(const char* text);
00790 void SetReadOnly(bool readOnly);
00794 void Null();
00798 bool CanPaste();
00802 bool CanUndo();
00806 void EmptyUndoBuffer();
00810 void Undo();
00814 void Cut();
00818 void Copy();
00822 void Paste();
00826 void Clear();
00830 void SetText(const char* text);
00835 int GetText(int length, char* text);
00839 int GetTextLength();
00843 int GetDirectFunction();
00848 int GetDirectPointer();
00852 void SetOvertype(bool overtype);
00856 bool GetOvertype();
00860 void SetCaretWidth(int pixelWidth);
00864 int GetCaretWidth();
00869 void SetTargetStart(long pos);
00873 long GetTargetStart();
00878 void SetTargetEnd(long pos);
00882 long GetTargetEnd();
00888 int ReplaceTarget(int length, const char* text);
00897 int ReplaceTargetRE(int length, const char* text);
00903 int SearchInTarget(int length, const char* text);
00907 void SetSearchFlags(int flags);
00911 int GetSearchFlags();
00915 void CallTipShow(long pos, const char* definition);
00919 void CallTipCancel();
00923 bool CallTipActive();
00927 long CallTipPosStart();
00931 void CallTipSetHlt(int start, int end);
00935 void CallTipSetBack(COLORREF back);
00939 int VisibleFromDocLine(int line);
00943 int DocLineFromVisible(int lineDisplay);
00949 void SetFoldLevel(int line, int level);
00953 int GetFoldLevel(int line);
00957 int GetLastChild(int line, int level);
00961 int GetFoldParent(int line);
00965 void ShowLines(int lineStart, int lineEnd);
00969 void HideLines(int lineStart, int lineEnd);
00973 bool GetLineVisible(int line);
00977 void SetFoldExpanded(int line, bool expanded);
00981 bool GetFoldExpanded(int line);
00985 void ToggleFold(int line);
00989 void EnsureVisible(int line);
00993 void SetFoldFlags(int flags);
00998 void EnsureVisibleEnforcePolicy(int line);
01002 void SetTabIndents(bool tabIndents);
01006 bool GetTabIndents();
01010 void SetBackSpaceUnIndents(bool bsUnIndents);
01014 bool GetBackSpaceUnIndents();
01018 void SetMouseDwellTime(int periodMilliseconds);
01022 int GetMouseDwellTime();
01026 void LineDown();
01030 void LineDownExtend();
01034 void LineUp();
01038 void LineUpExtend();
01042 void CharLeft();
01046 void CharLeftExtend();
01050 void CharRight();
01054 void CharRightExtend();
01058 void WordLeft();
01062 void WordLeftExtend();
01066 void WordRight();
01070 void WordRightExtend();
01074 void Home();
01078 void HomeExtend();
01082 void LineEnd();
01086 void LineEndExtend();
01090 void DocumentStart();
01094 void DocumentStartExtend();
01098 void DocumentEnd();
01102 void DocumentEndExtend();
01106 void PageUp();
01110 void PageUpExtend();
01114 void PageDown();
01118 void PageDownExtend();
01122 void EditToggleOvertype();
01126 void Cancel();
01130 void DeleteBack();
01136 void Tab();
01140 void BackTab();
01144 void NewLine();
01148 void FormFeed();
01153 void VCHome();
01157 void VCHomeExtend();
01161 void ZoomIn();
01165 void ZoomOut();
01169 void DelWordLeft();
01173 void DelWordRight();
01177 void LineCut();
01181 void LineDelete();
01185 void LineTranspose();
01189 void LowerCase();
01193 void UpperCase();
01197 void LineScrollDown();
01201 void LineScrollUp();
01205 void MoveCaretInsideView();
01209 int LineLength(int line);
01213 void BraceHighlight(long pos1, long pos2);
01217 void BraceBadLight(long pos);
01221 long BraceMatch(long pos);
01225 bool GetViewEOL();
01229 void SetViewEOL(bool visible);
01233 int GetDocPointer();
01237 void SetDocPointer(int pointer);
01241 void SetModEventMask(int mask);
01245 int GetEdgeColumn();
01250 void SetEdgeColumn(int column);
01254 int GetEdgeMode();
01259 void SetEdgeMode(int mode);
01263 COLORREF GetEdgeColour();
01267 void SetEdgeColour(COLORREF edgeColour);
01271 void SearchAnchor();
01276 int SearchNext(int flags, const char* text);
01281 int SearchPrev(int flags, const char* text);
01285 void SetCaretPolicy(int caretPolicy, int caretSlop);
01289 int LinesOnScreen();
01294 void UsePopUp(bool allowPopUp);
01298 bool SelectionIsRectangle();
01303 void SetZoom(int zoom);
01307 int GetZoom();
01312 int CreateDocument();
01316 void AddRefDocument(int doc);
01320 void ReleaseDocument(int doc);
01324 int GetModEventMask();
01328 void SetFocus(bool focus);
01332 bool GetFocus();
01336 void SetStatus(int statusCode);
01340 int GetStatus();
01344 void SetMouseDownCaptures(bool captures);
01348 bool GetMouseDownCaptures();
01352 void SetCursor(int cursorType);
01356 int GetCursor();
01360 void WordPartLeft();
01364 void WordPartLeftExtend();
01368 void WordPartRight();
01372 void WordPartRightExtend();
01376 void SetVisiblePolicy(int visiblePolicy, int visibleSlop);
01380 void DelLineLeft();
01384 void DelLineRight();
01389 void GrabFocus();
01393 void StartRecord();
01397 void StopRecord();
01401 void SetLexer(int lexer);
01405 int GetLexer();
01409 void Colourise(long start, long end);
01413 void SetProperty(const char* key, const char* value);
01417 void SetKeyWords(int keywordSet, const char* keyWords);
01421 void SetLexerLanguage(const char* language);
01422
01424
01425
01431 class CRecordingScintilla : public CScintilla
01432 {
01433 protected:
01434 virtual void Record(long Msg, WPARAM wParam, LPARAM lParam) = 0;
01435 public:
01436 inline long SPerform(long Msg, WPARAM wParam=0, LPARAM lParam=0)
01437 {
01438
01439 Record(Msg, wParam, lParam);
01440 return 0;
01441 }
01442 };
01443
01444 #endif