1 /*    e_buffer.h
2  *
3  *    Copyright (c) 1994-1996, Marko Macek
4  *
5  *    You may distribute under the terms of either the GNU General Public
6  *    License or the Artistic License, as specified in the README file.
7  *
8  */
9 
10 #ifndef E_BUFFER_H
11 #define E_BUFFER_H
12 
13 #include "c_hilit.h" // hlState
14 #include "c_mode.h"
15 #include "e_regex.h"
16 #include "gui.h"
17 #include "o_model.h"
18 
19 #include <sys/stat.h>
20 
21 class EBuffer;
22 class EMode;
23 
24 #define bmLine    0
25 #define bmStream  1
26 #define bmColumn  2
27 
28 #define umDelete      0
29 #define umInsert      1
30 #define umSplitLine   2
31 #define umJoinLine    3
32 
33 #define tmNone        0
34 #define tmLeft        1
35 #define tmRight       2
36 
37 typedef unsigned char TransTable[256];
38 
39 #ifdef DOS /* 16 bit, sometime ;-) */
40 #define RWBUFSIZE     8192
41 #else
42 #define RWBUFSIZE     32768
43 #endif
44 
45 extern char FileBuffer[RWBUFSIZE];
46 
47 #define ChClass(x)  (WGETBIT(Flags.WordChars, (x)) ? 1 : 0)
48 #define ChClassK(x) (((x) == ' ' || (x) == 9) ? 2 : ChClass(x))
49 
50 #define InRange(a,x,b) (((a) <= (x)) && ((x) < (b)))
51 #define Min(a,b) (((a) < (b))?(a):(b))
52 #define Max(a,b) (((a) > (b))?(a):(b))
53 
54 #define NextTab(pos,ts) (((pos) / (ts) + 1) * (ts))
55 
56 // x before gap -> x
57 // x less than count -> after gap
58 // count - 1 before gap -> count - 1
59 // after gap -> allocated - 1
60 //#define GapLine(x,g,c,a) (((x) < (g)) ? (x) : (x) < (c) ? ((x) + (a) - (c)) : (c) - 1 < (g) ? (c) - 1 : (a) - 1 )
61 // Use inline to make it easier to read/debug
GapLine(int No,int Gap,int Count,int Allocated)62 static inline int GapLine(int No, int Gap, int Count, int Allocated)
63 {
64     int rc = -1;
65     if (No < Gap)
66         rc = No;
67     else if (No < Count)
68         rc = No + Allocated - Count;
69     else if (Count - 1 < Gap)
70         rc = Count - 1;
71     else
72         rc = Allocated - 1;
73     return rc;
74 }
75 
76 
77 typedef class ELine* PELine;
78 typedef class EPoint* PEPoint;
79 
80 #define CHAR_TRESHOLD  0x3U
81 
82 class ELine {
83 public:
84     size_t Count;
85     char *Chars;
86 #ifdef CONFIG_SYNTAX_HILIT
87     hlState StateE;
88 #endif
89 
90     ELine(size_t ACount, const char *AChars);
91     ELine(char *AChars, size_t ACount);
92     ~ELine();
93     int Allocate(size_t Bytes);
94 
95 //    int Length(EBufferFlags *CurFlags);
96 };
97 
98 class EPoint {
99 public:
100     int Row;
101     int Col;
102 
103 //    EPoint(EPoint &M) { Row = M.Row; Col = M.Col; }
Row(aRow)104     EPoint(int aRow = 0, int aCol = 0) : Row(aRow), Col(aCol) {}
105 };
106 
107 struct UndoStack {
108     int NextCmd, Record, Undo;
109     int UndoPtr;
110     int Num;
111     void **Data;
112     int *Top;
113 };
114 
115 #ifdef CONFIG_OBJ_ROUTINE
116 class RoutineView;
117 
118 struct RoutineList {
119     int Count;
120     int *Lines;
121 };
122 #endif
123 
124 #ifdef CONFIG_BOOKMARKS
125 class EBookmark {
126     StlString Name;
127     EPoint BM;
128 public:
EBookmark(const char * n,const EPoint & p)129     EBookmark(const char* n, const EPoint& p) : Name(n), BM(p) {}
GetName()130     const char* GetName() const { return Name.c_str(); }
GetPoint()131     const EPoint& GetPoint() const { return BM; }
GetPoint()132     EPoint& GetPoint() { return BM; }
IsName(const char * n)133     bool IsName(const char* n) const { return Name == n; }
SetPoint(const EPoint & p)134     void SetPoint(const EPoint& p) { BM = p; }
135 };
136 #endif
137 
138 struct EFold {
139     int line;
140     unsigned char level;
141     unsigned char open;
142     unsigned short flags;
143 };
144 
145 class EEditPort: public EViewPort {
146 public:
147     EBuffer *Buffer;
148     EPoint TP, OldTP;
149     EPoint CP;
150     int Rows, Cols;
151 
152     EEditPort(EBuffer *B, EView *V);
153     virtual ~EEditPort();
154 
155     virtual void HandleEvent(TEvent &Event);
156 #ifdef CONFIG_MOUSE
157     virtual void HandleMouse(TEvent &Event);
158 #endif
159     virtual void UpdateView();
160     virtual void RepaintView();
161     virtual void UpdateStatus();
162     virtual void RepaintStatus();
163 
164     virtual void Resize(int Width, int Height);
165     int SetTop(int Col, int Row);
166     virtual void GetPos();
167     virtual void StorePos();
168     void DrawLine(int L, TDrawBuffer B);
169     void ScrollY(int Delta);
170     void RedrawAll();
171 };
172 
173 class EBuffer: public EModel {
174 public:
175     char *FileName;
176     int Modified;
177     EPoint TP;
178     EPoint CP;
179     EPoint BB;
180     EPoint BE;
181     EPoint PrevPos;
182     EPoint SavedPos;
183 
184     EBufferFlags Flags;
185     EMode *Mode;
186     int BlockMode;
187     int ExtendGrab;
188     int AutoExtend;
189     int Loaded;
190 
191 #ifdef CONFIG_UNDOREDO
192     UndoStack US;
193 #endif
194 
195     struct stat FileStatus;
196     int FileOk;
197     int Loading;
198 
199     int RAllocated;   // text line allocation
200     int RGap;
201     int RCount;
202     PELine *LL;
203 
204     int VAllocated;   // visible lines
205     int VGap;
206     int VCount;
207     int *VV;
208 
209 #ifdef CONFIG_FOLDS
210     int FCount;
211     EFold *FF;
212 #endif
213 
214     EPoint Match;
215     size_t MatchLen;
216     int MatchCount;
217     RxMatchRes MatchRes;
218 
219 #ifdef CONFIG_BOOKMARKS
220     StlVector<EBookmark*> BMarks;
221 #endif
222 
223 #ifdef CONFIG_OBJ_ROUTINE
224     RoutineList rlst;
225     RoutineView *Routines;
226 #endif
227 
228     int MinRedraw, MaxRedraw;
229     int RedrawToEos;
230 
231 #ifdef CONFIG_WORD_HILIT
232     StlVector<StlString> WordList;
GetWordCount()233     size_t GetWordCount() const { return WordList.size(); }
234 #endif
235 #ifdef CONFIG_SYNTAX_HILIT
236     SyntaxProc HilitProc;
237     int StartHilit, EndHilit;
238 #endif
239 
240     // constructors
241     EBuffer(int createFlags, EModel **ARoot, const char *AName);
242     virtual ~EBuffer();
243     virtual void DeleteRelated();
244 
245     virtual EViewPort *CreateViewPort(EView *V);
246     EEditPort *GetViewVPort(EView *V);
247     EEditPort *GetVPort();
248 
249     virtual int CanQuit();
250     virtual int ConfQuit(GxView *V, int multiFile = 0);
251 
252     virtual int GetContext();
253     virtual EEventMap *GetEventMap();
254     virtual int BeginMacro();
255     virtual int ExecCommand(ExCommands Command, ExState &State);
256     virtual void HandleEvent(TEvent &Event);
257 
258     virtual void GetName(char *AName, size_t MaxLen);
259     virtual void GetPath(char *APath, size_t MaxLen);
260     virtual void GetInfo(char *AInfo, size_t MaxLen);
261     virtual void GetTitle(char *ATitle, size_t MaxLen, char *ASTitle, size_t SMaxLen);
262 
RLine(int No)263     PELine RLine(int No) {
264 #ifdef DEBUG_EDITOR
265         int N = GapLine(No, RGap, RCount, RAllocated);
266         if (!((No < RCount) && (No >= 0) && (LL[N]))) {
267             printf("Get No = %d/%d Gap=%d RAlloc = %d, VCount = %d\n", No, RCount, RGap, RAllocated, VCount);
268             assert((No < RCount) && (No >= 0) && (LL[N]));
269         }
270 #endif
271         return LL[GapLine(No, RGap, RCount, RAllocated)];
272     }
RLine(int No,PELine L)273     void RLine(int No, PELine L) {
274 #ifdef DEBUG_EDITOR
275         if (!((No >= 0))) printf("Set No = %d\n", No);
276         assert((No >= 0));
277 #endif
278         LL[GapLine(No, RGap, RCount, RAllocated)] = L;
279     }
Vis(int No)280     int Vis(int No) {
281 #ifdef DEBUG_EDITOR
282         if (No < 0 || No >= VCount) {
283             printf("Vis get no %d of %d\n", No, VCount);
284             assert (No >= 0 && No < VCount);
285         }
286 #endif
287         return VV[GapLine(No, VGap, VCount, VAllocated)];
288     }
Vis(int No,int V)289     void Vis(int No, int V) {
290 #ifdef DEBUG_EDITOR
291         if (No < 0 || No >= VCount) {
292             printf("Vis set no %d of %d to %d\n", No, VCount, V);
293             assert (No >= 0 && No < VCount);
294         }
295 #endif
296         VV[GapLine(No, VGap, VCount, VAllocated)] = V;
297     }
VLine(int No)298     PELine VLine(int No) {
299 #ifdef DEBUG_EDITOR
300         if (!((No < VCount) && (No >= 0))) {
301             printf("VGet No = %d\n", No);
302             assert((No < VCount) && (No >= 0));
303         }
304         if (Vis(No) < 0)
305             assert(1 == 0);
306 #endif
307         return RLine(No + Vis(No));
308     }
VLine(int No,PELine L)309     void VLine(int No, PELine L) {
310 #ifdef DEBUG_EDITOR
311         if (!((No >= 0))) {
312             printf("VSet No = %d\n", No);
313             assert((No >= 0));
314         }
315         if (VV[No] < 0)
316             assert(1 == 0);
317 #endif
318         RLine(No + Vis(No), L);
319     }
320 
VToR(int No)321     int VToR(int No) {
322 	if (!VCount)
323             return 0;
324 #ifdef DEBUG_EDITOR
325         if (!(No < VCount)) {
326             printf("Get No = %d\n", No);
327             assert((No < VCount));
328         }
329 #endif
330         return No + Vis(No);
331     }
332 
333     int RToV(int No);
334     int RToVN(int No);
335 
336     // allocation
337     int Allocate(int ACount);
338     int MoveRGap(int RPos);
339     int AllocVis(int ACount);
340     int MoveVGap(int VPos);
341 
342     int Modify();
343     int Clear();
344 
345 #ifdef CONFIG_UNDOREDO
346     int FreeUndo();
347 #endif
348     // internal primitives
349     int ValidPos(EPoint W);
350     int RValidPos(EPoint W);
351     int LoadRegion(EPoint *A, int FH, int StripChar, int LineChar);
352     int SaveRegion(EPoint *A, EPoint *Z, int FH, int AddCR, int AddLF, int Mode);
353 
354     int AssertLine(int Line);
355     int InsertLine(const EPoint& Pos, size_t ACount, const char *AChars);
356 
357     int UpdateMarker(int Type, int Line, int Col, int Lines, int Cols);
358     int UpdateMark(EPoint &M, int Type, int Line, int Col, int Lines, int Cols);
359     void UpdateVis(EPoint &M, int Row, int Delta);
360     void UpdateVisible(int Row, int Delta);
361     int LoadFrom(const char *AFileName);
362     int SaveTo(const char *AFileName);
363 
364     int IsBlockStart();
365     int IsBlockEnd();
366     int BlockType(int Mode);
367     int BeginExtend();
368     int EndExtend();
369     int CheckBlock();
370     int BlockRedraw();
371     int SetBB(const EPoint& M);
372     int SetBE(const EPoint& M);
373 
374     int Load();
375     int Save();
376     int Reload();
377     int FilePrint();
378     int SetFileName(const char *AFileName, const char *AMode);
379 
380     int SetPos(int Col, int Row, int tabMode = tmNone);
381     int SetPosR(int Col, int Row, int tabMode = tmNone);
382     int CenterPos(int Col, int Row, int tabMode = tmNone);
383     int CenterPosR(int Col, int Row, int tabMode = tmNone);
384     int SetNearPos(int Col, int Row, int tabMode = tmNone);
385     int SetNearPosR(int Col, int Row, int tabMode = tmNone);
386     int CenterNearPos(int Col, int Row, int tabMode = tmNone);
387     int CenterNearPosR(int Col, int Row, int tabMode = tmNone);
388     int LineLen(int Row);
389     int LineChars(int Row);
390 
391 /////////////////////////////////////////////////////////////////////////////
392 // Undo/Redo Routines
393 /////////////////////////////////////////////////////////////////////////////
394 
395     int NextCommand();
396 #ifdef CONFIG_UNDOREDO
397     int PushUData(const void *data, size_t len);
398     int PushULong(unsigned long l);
399     int PushUChar(unsigned char ch);
400     int PopUData(void *data, size_t len);
401     int GetUData(int No, int pos, void **data, size_t len);
402     int Undo(int undo);
403     int Undo();
404     int Redo();
405     int BeginUndo();
406     int EndUndo();
407     int PushBlockData();
408 #endif
409 
410 /////////////////////////////////////////////////////////////////////////////
411 // Primitive Editing
412 /////////////////////////////////////////////////////////////////////////////
413 
414     //int ExpReg(int Row, int Ofs, int ACount, int &B, int &E);
415     int ScreenPos(ELine *L, int Offset);
416     int CharOffset(ELine *L, int ScreenPos);
417     int DelLine(int Row, int DoMark = 1);
418     int UnTabPoint(int Row, int Col);
419     int InsLine(int Row, int DoAppend, int DoMark = 1);
420     int DelChars(int Row, int Ofs, size_t ACount);
421     int InsChars(int Row, int Ofs, size_t ACount, const char *Buffer);
422     int ChgChars(int Row, int Ofs, size_t ACount, const char *Buffer);
423     int DelText(int Row, int Col, size_t ACount, int DoMark = 1);
424     int InsText(int Row, int Col, size_t ACount, const char *Buffer, int DoMark = 1);
425     int InsLineText(int Row, int Col, size_t ACount, int Pos, PELine Line);
426     int SplitLine(int Row, int Col);
427     int JoinLine(int Row, int Col);
428     int CanUnfold(int Row);
429     int PadLine(int Row, size_t Length);
430 
431     int ShowRow(int Row);
432     int HideRow(int Row);
433     int ExposeRow(int Row); // make row visible (open all folds containing)
434 
435 /////////////////////////////////////////////////////////////////////////////
436 // Redraw/Windowing Routines
437 /////////////////////////////////////////////////////////////////////////////
438 
439     void Draw(int Line0, int LineE);
440     void DrawLine(TDrawBuffer B, int L, int C, int W, int &HilitX);
441     void Hilit(int FromRow);
442     void Rehilit(int ToRow);
443     void Redraw();
444     void FullRedraw();
445     int  GetHilitWord(ChColor &clr, const char *str, size_t len, int IgnCase = 0);
446 
447 /////////////////////////////////////////////////////////////////////////////
448 // Utility Routines
449 /////////////////////////////////////////////////////////////////////////////
450 
451     int LineIndented(int Row, const char *indentchars = 0);
452     int LineIndentedCharCount(ELine *l, const char *indentchars);
453     int IndentLine(int Row, int Indent);
454 #ifdef CONFIG_SYNTAX_HILIT
455     int GetMap(int Row, int *StateLen, hsState **StateMap);
456 #endif
457     int FindStr(const char *Data, int Len, int Options);
458     int FindStr(const char *Data, int Len, SearchReplaceOptions &opt);
459     int FindRx(RxNode *Rx, SearchReplaceOptions &opt);
460     int Find(SearchReplaceOptions &opt);
461     int IsLineBlank(int Row);
462     int TrimLine(int Row);
463 
464 #ifdef CONFIG_OBJ_ROUTINE
465     int ScanForRoutines();
466 #endif
467 
468 /////////////////////////////////////////////////////////////////////////////
469 // Bookmark Routines
470 /////////////////////////////////////////////////////////////////////////////
471 
472 #ifdef CONFIG_BOOKMARKS
473     int PlaceBookmark(const char *Name, const EPoint &P);
474     int RemoveBookmark(const char *Name);
475     int GetBookmark(const char *Name, EPoint &P);
476     int GotoBookmark(const char *Name);
477     int GetBookmarkForLine(int searchFrom, int searchForLine, const EBookmark* &b);
478 #endif
479 
480 /////////////////////////////////////////////////////////////////////////////
481 // Editing Routines
482 /////////////////////////////////////////////////////////////////////////////
483 
484     int     MoveLeft();
485     int     MoveRight();
486     int     MoveUp();
487     int     MoveDown();
488     int     MovePrev();
489     int     MoveNext();
490     int     MoveWordLeftX(int start);
491     int     MoveWordRightX(int start);
492     int     MoveWordLeft();
493     int     MoveWordRight();
494     int     MoveWordPrev();
495     int     MoveWordNext();
496     int     MoveWordEndLeft();
497     int     MoveWordEndRight();
498     int     MoveWordEndPrev();
499     int     MoveWordEndNext();
500     int     MoveWordOrCapLeft();
501     int     MoveWordOrCapRight();
502     int     MoveWordOrCapPrev();
503     int     MoveWordOrCapNext();
504     int     MoveWordOrCapEndLeft();
505     int     MoveWordOrCapEndRight();
506     int     MoveWordOrCapEndPrev();
507     int     MoveWordOrCapEndNext();
508 //    int     MoveWordStart();
509 //    int     MoveWordEnd();
510     int     MoveLineStart();
511     int     MoveLineEnd();
512     int     MovePageUp();
513     int     MovePageDown();
514     int     MovePageLeft();
515     int     MovePageRight();
516     int     MovePageStart();
517     int     MovePageEnd();
518     int     MoveFileStart();
519     int     MoveFileEnd();
520     int     MoveBlockStart();
521     int     MoveBlockEnd();
522     int     ScrollLeft(int Cols);
523     int     ScrollRight(int Cols);
524     int     ScrollDown(int Lines);
525     int     ScrollUp(int Lines);
526     int     MoveToLine();
527     int     MoveToColumn();
528     int     MoveFirstNonWhite();
529     int     MoveLastNonWhite();
530     int     MovePrevEqualIndent();
531     int     MoveNextEqualIndent();
532     int     MovePrevTab();
533     int     MoveNextTab();
534     int     MoveLineTop();
535     int     MoveLineCenter();
536     int     MoveLineBottom();
537     int     MovePrevPos();
538     int     MoveSavedPosCol();
539     int     MoveSavedPosRow();
540     int     MoveSavedPos();
541     int     SavePos();
542     int     MoveTabStart();
543     int     MoveTabEnd();
544     int     MoveFoldTop();
545     int     MoveFoldPrev();
546     int     MoveFoldNext();
547     int     MoveBeginOrNonWhite();
548     int     MoveBeginLinePageFile();
549     int     MoveEndLinePageFile();
550 
551     int     KillLine();
552     int     KillChar();
553     int     KillCharPrev();
554     int     KillWord();
555     int     KillWordPrev();
556     int     KillWordOrCap();
557     int     KillWordOrCapPrev();
558     int     KillToLineStart();
559     int     KillToLineEnd();
560     int     KillBlock();
561     int     BackSpace();
562     int     Delete();
563     int     CompleteWord();
564     int     KillBlockOrChar();
565     int     KillBlockOrCharPrev();
566 
567 #define ccUp       0
568 #define ccDown     1
569 #define ccToggle   2
570 
571     int     CharTrans(TransTable tab);
572     int     CharCaseUp();
573     int     CharCaseDown();
574     int     CharCaseToggle();
575 
576     int     LineTrans(TransTable tab);
577     int     LineCaseUp();
578     int     LineCaseDown();
579     int     LineCaseToggle();
580 
581     int     BlockTrans(TransTable tab);
582     int     BlockCaseUp();
583     int     BlockCaseDown();
584     int     BlockCaseToggle();
585 
586     int     CharTrans(ExState &State);
587     int     LineTrans(ExState &State);
588     int     BlockTrans(ExState &State);
589     int     GetTrans(ExState &State, TransTable tab);
590 
591     int     LineInsert();
592     int     LineAdd();
593     int     LineSplit();
594     int     LineJoin();
595     int     LineNew();
596     int     LineIndent();
597     int     LineTrim();
598     int     LineCenter();
599     int     FileTrim();
600     int     BlockTrim();
601 
602 #ifdef CONFIG_UNDOREDO
603     int     CanUndo();
604     int     CanRedo();
605 #endif
606 
607     int     LineLen();
608     int     LineCount();
609     int     CLine();
610     int     CColumn();
611 
612     int     InsertChar(char aCh);
613     int     TypeChar(char aCh);
614     int     InsertString(const char *aStr, size_t aCount);
615     int     InsertSpacesToTab(int TSize);
616     int     InsertTab();
617     int     InsertSpace();
618     int     SelfInsert();
619 #ifdef CONFIG_WORDWRAP
620     int     DoWrap(int WrapAll);
621     int     WrapPara();
622 #endif
623     int     InsPrevLineChar();
624     int     InsPrevLineToEol();
625     int     LineDuplicate();
626 
627     int     GetMatchBrace(EPoint &M, int MinLine, int MaxLine, int show);
628     int     MatchBracket();
629     int     HilitMatchBracket();
630 
631     int     BlockBegin();
632     int     BlockEnd();
633     int     BlockUnmark();
634     int     BlockCut(int Append);
635     int     BlockCopy(int Append, int clipboard=0);
636     int     BlockPaste(int clipboard=0);
637     int     BlockKill();
638     int     BlockIndent();
639     int     BlockUnindent();
640     int     BlockClear();
641     int     BlockMarkStream();
642     int     BlockMarkLine();
643     int     BlockMarkColumn();
644     int     BlockReadFrom(const char *aFileName, int blockMode);
645     int     BlockWriteTo(const char *aFileName, int Append = 0);
646     int     BlockExtendBegin();
647     int     BlockExtendEnd();
648     int     BlockReIndent();
649     int     BlockIsMarked();
650     int     BlockPasteStream(int clipboard=0);
651     int     BlockPasteLine(int clipboard=0);
652     int     BlockPasteColumn(int clipboard=0);
653     int     BlockPasteOver(int clipboard=0);
654     int     BlockSelectWord();
655     int     BlockSelectLine();
656     int     BlockSelectPara();
657     int     BlockPrint();
658     int     BlockSort(int Reverse);
659     int     ClipClear(int clipboard=0);
660     int     BlockUnTab();
661     int     BlockEnTab();
662 
663     int     ToggleAutoIndent();
664     int     ToggleInsert();
665     int     ToggleExpandTabs();
666     int     ToggleShowTabs();
667     int     ToggleUndo();
668     int     ToggleReadOnly();
669     int     ToggleKeepBackups();
670     int     ToggleMatchCase();
671     int     ToggleBackSpKillTab();
672     int     ToggleDeleteKillTab();
673     int     ToggleSpaceTabs();
674     int     ToggleIndentWithTabs();
675     int     ToggleBackSpUnindents();
676     int     ToggleWordWrap();
677     int     ToggleTrim();
678     int     ToggleShowMarkers();
679     int     ToggleHilitTags();
680     int     ToggleShowBookmarks();
681     int     ToggleMakeBackups();
682     int     SetLeftMargin();
683     int     SetRightMargin();
684 
685     int     ShowPosition();
686 
687     int     Search(ExState &State, const char *aString, int Options, int CanResume = 0);
688     int     SearchAgain(ExState &State, unsigned int Options);
689     int     SearchReplace(ExState &State, const char *aString, const char *aReplaceString, int Options);
690     int     Search(ExState &State);
691     int     SearchB(ExState &State);
692     int     SearchRx(ExState &State);
693     int     SearchAgain(ExState &State);
694     int     SearchAgainB(ExState &State);
695     int     SearchReplace(ExState &State);
696     int     SearchReplaceB(ExState &State);
697     int     SearchReplaceRx(ExState &State);
698 
699 #ifdef CONFIG_WORD_HILIT
700     int     HilitAddWord(const char *Word);
701     int     HilitFindWord(const char *Word);
702     int     HilitRemoveWord(const char *Word);
703     int     HilitWord();
704 #endif
705     int     SearchWord(int Flags);
706 
707 #ifdef CONFIG_FOLDS
708     int     FindFold(int Line);
709     int     FindNearFold(int Line);
710     int     FoldCreate(int Line);
711     int     FoldCreateByRegexp(const char *Regexp);
712     int     FoldDestroy(int Line);
713     int     FoldDestroyAll();
714     int     FoldPromote(int Line);
715     int     FoldDemote(int Line);
716     int     FoldOpen(int Line);
717     int     FoldOpenAll();
718     int     FoldOpenNested();
719     int     FoldClose(int Line);
720     int     FoldCloseAll();
721     int     FoldToggleOpenClose();
722 #endif
723 
724     int     ChangeMode(const char *Mode);
725     int     ChangeKeys(const char *Mode);
726     int     ChangeFlags(const char *Mode);
727 
728     int ScrollLeft(ExState &State);
729     int ScrollRight(ExState &State);
730     int ScrollDown(ExState &State);
731     int ScrollUp(ExState &State);
732 
733     /* editor functions with user interface */
734 
735     int MoveToColumn(ExState &State);
736     int MoveToLine(ExState &State);
737     int FoldCreateByRegexp(ExState &State);
738 #ifdef CONFIG_BOOKMARKS
739     int PlaceUserBookmark(const char *n,EPoint P);
740     int RemoveUserBookmark(const char *n);
741     int GotoUserBookmark(const char *n);
742     int GetUserBookmarkForLine(int searchFrom, int searchForLine, const EBookmark* &b);
743     int PlaceBookmark(ExState &State);
744     int RemoveBookmark(ExState &State);
745     int GotoBookmark(ExState &State);
746 #endif
747     int InsertString(ExState &State);
748     int SelfInsert(ExState &State);
749     int FileReload(ExState &State);
750     int FileSaveAs(const char *FileName);
751     int FileSaveAs(ExState &State);
752     int FileWriteTo(const char *FileName);
753     int FileWriteTo(ExState &State);
754     int BlockReadX(ExState &State, int BlockMode);
755     int BlockRead(ExState &State);
756     int BlockReadStream(ExState &State);
757     int BlockReadLine(ExState &State);
758     int BlockReadColumn(ExState &State);
759     int BlockWrite(ExState &State);
760     int Find(ExState &State);
761     int FindReplace(ExState &State);
762     int FindRepeat(ExState &State);
763     int FindRepeatOnce(ExState &State);
764     int FindRepeatReverse(ExState &State);
765     int InsertChar(ExState &State);
766     int TypeChar(ExState &State);
767     int ChangeMode(ExState &State);
768     int ChangeKeys(ExState &State);
769     int ChangeFlags(ExState &State);
770     int ChangeTabSize(ExState &State);
771     int ChangeRightMargin(ExState &State);
772     int ChangeLeftMargin(ExState &State);
773 
774 #ifdef CONFIG_I_ASCII
775     int ASCIITable(ExState &State);
776 #endif
777 
778 #ifdef CONFIG_TAGS
779     int FindTag(ExState &State);
780     int FindTagWord(ExState &State);
781 #endif
782 
783     int SetCIndentStyle(ExState &State);
784 
785     int FindFunction(int delta, int way);
786     int BlockMarkFunction();
787     int IndentFunction();
788     int MoveFunctionPrev();
789     int MoveFunctionNext();
790     int InsertDate(ExState& state);
791     int InsertUid();
792 
793     int ShowHelpWord(ExState &State);
794 
795     int PlaceGlobalBookmark(ExState &State);
796     int PushGlobalBookmark();
797 
798     virtual int GetStrVar(int var, char *str, size_t buflen);
799     virtual int GetIntVar(int var, int *value);
800 
801     int SetIndentWithTabs(ExState &State);
802     int FoldCreateAtRoutines();
803 };
804 
805 extern EBuffer *SSBuffer;
806 extern SearchReplaceOptions LSearch;
807 
808 extern int suspendLoads;
809 
810 int DoneEditor();
811 
812 EBuffer *FindFile(const char *FileName);
813 
814 int ParseSearchOption(int replace, char c, unsigned long &opt);
815 int ParseSearchOptions(int replace, const char *str, unsigned long &Options);
816 int ParseSearchReplace(EBuffer *B, const char *str, int replace, SearchReplaceOptions &opt);
817 
818 #endif // E_BUFFER_H
819