File: e_buffer.h

package info (click to toggle)
fte 0.50.2b6-20110708-2
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 3,768 kB
  • ctags: 6,761
  • sloc: cpp: 47,985; ansic: 2,795; sh: 112; makefile: 71; perl: 29
file content (818 lines) | stat: -rw-r--r-- 23,102 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
/*    e_buffer.h
 *
 *    Copyright (c) 1994-1996, Marko Macek
 *
 *    You may distribute under the terms of either the GNU General Public
 *    License or the Artistic License, as specified in the README file.
 *
 */

#ifndef E_BUFFER_H
#define E_BUFFER_H

#include "c_hilit.h" // hlState
#include "c_mode.h"
#include "e_regex.h"
#include "gui.h"
#include "o_model.h"

#include <sys/stat.h>

class EBuffer;
class EMode;

#define bmLine    0
#define bmStream  1
#define bmColumn  2

#define umDelete      0
#define umInsert      1
#define umSplitLine   2
#define umJoinLine    3

#define tmNone        0
#define tmLeft        1
#define tmRight       2

typedef unsigned char TransTable[256];

#ifdef DOS /* 16 bit, sometime ;-) */
#define RWBUFSIZE     8192
#else
#define RWBUFSIZE     32768
#endif

extern char FileBuffer[RWBUFSIZE];

#define ChClass(x)  (WGETBIT(Flags.WordChars, (x)) ? 1 : 0)
#define ChClassK(x) (((x) == ' ' || (x) == 9) ? 2 : ChClass(x))

#define InRange(a,x,b) (((a) <= (x)) && ((x) < (b)))
#define Min(a,b) (((a) < (b))?(a):(b))
#define Max(a,b) (((a) > (b))?(a):(b))

#define NextTab(pos,ts) (((pos) / (ts) + 1) * (ts))

// x before gap -> x
// x less than count -> after gap
// count - 1 before gap -> count - 1
// after gap -> allocated - 1
//#define GapLine(x,g,c,a) (((x) < (g)) ? (x) : (x) < (c) ? ((x) + (a) - (c)) : (c) - 1 < (g) ? (c) - 1 : (a) - 1 )
// Use inline to make it easier to read/debug
static inline int GapLine(int No, int Gap, int Count, int Allocated)
{
    int rc = -1;
    if (No < Gap)
        rc = No;
    else if (No < Count)
        rc = No + Allocated - Count;
    else if (Count - 1 < Gap)
        rc = Count - 1;
    else
        rc = Allocated - 1;
    return rc;
}


typedef class ELine* PELine;
typedef class EPoint* PEPoint;

#define CHAR_TRESHOLD  0x3U

class ELine {
public:
    size_t Count;
    char *Chars;
#ifdef CONFIG_SYNTAX_HILIT
    hlState StateE;
#endif

    ELine(size_t ACount, const char *AChars);
    ELine(char *AChars, size_t ACount);
    ~ELine();
    int Allocate(size_t Bytes);

//    int Length(EBufferFlags *CurFlags);
};

class EPoint {
public:
    int Row;
    int Col;

//    EPoint(EPoint &M) { Row = M.Row; Col = M.Col; }
    EPoint(int aRow = 0, int aCol = 0) : Row(aRow), Col(aCol) {}
};

struct UndoStack {
    int NextCmd, Record, Undo;
    int UndoPtr;
    int Num;
    void **Data;
    int *Top;
};

#ifdef CONFIG_OBJ_ROUTINE
class RoutineView;

struct RoutineList {
    int Count;
    int *Lines;
};
#endif

#ifdef CONFIG_BOOKMARKS
class EBookmark {
    StlString Name;
    EPoint BM;
public:
    EBookmark(const char* n, const EPoint& p) : Name(n), BM(p) {}
    const char* GetName() const { return Name.c_str(); }
    const EPoint& GetPoint() const { return BM; }
    EPoint& GetPoint() { return BM; }
    bool IsName(const char* n) const { return Name == n; }
    void SetPoint(const EPoint& p) { BM = p; }
};
#endif

struct EFold {
    int line;
    unsigned char level;
    unsigned char open;
    unsigned short flags;
};

class EEditPort: public EViewPort {
public:
    EBuffer *Buffer;
    EPoint TP, OldTP;
    EPoint CP;
    int Rows, Cols;

    EEditPort(EBuffer *B, EView *V);
    virtual ~EEditPort();

    virtual void HandleEvent(TEvent &Event);
#ifdef CONFIG_MOUSE
    virtual void HandleMouse(TEvent &Event);
#endif
    virtual void UpdateView();
    virtual void RepaintView();
    virtual void UpdateStatus();
    virtual void RepaintStatus();

    virtual void Resize(int Width, int Height);
    int SetTop(int Col, int Row);
    virtual void GetPos();
    virtual void StorePos();
    void DrawLine(int L, TDrawBuffer B);
    void ScrollY(int Delta);
    void RedrawAll();
};

class EBuffer: public EModel {
public:
    char *FileName;
    int Modified;
    EPoint TP;
    EPoint CP;
    EPoint BB;
    EPoint BE;
    EPoint PrevPos;
    EPoint SavedPos;

    EBufferFlags Flags;
    EMode *Mode;
    int BlockMode;
    int ExtendGrab;
    int AutoExtend;
    int Loaded;

#ifdef CONFIG_UNDOREDO
    UndoStack US;
#endif

    struct stat FileStatus;
    int FileOk;
    int Loading;

    int RAllocated;   // text line allocation
    int RGap;
    int RCount;
    PELine *LL;

    int VAllocated;   // visible lines
    int VGap;
    int VCount;
    int *VV;

#ifdef CONFIG_FOLDS
    int FCount;
    EFold *FF;
#endif

    EPoint Match;
    size_t MatchLen;
    int MatchCount;
    RxMatchRes MatchRes;

#ifdef CONFIG_BOOKMARKS
    StlVector<EBookmark*> BMarks;
#endif

#ifdef CONFIG_OBJ_ROUTINE
    RoutineList rlst;
    RoutineView *Routines;
#endif

    int MinRedraw, MaxRedraw;
    int RedrawToEos;

#ifdef CONFIG_WORD_HILIT
    StlVector<StlString> WordList;
    size_t GetWordCount() const { return WordList.size(); }
#endif
#ifdef CONFIG_SYNTAX_HILIT
    SyntaxProc HilitProc;
    int StartHilit, EndHilit;
#endif

    // constructors
    EBuffer(int createFlags, EModel **ARoot, const char *AName);
    virtual ~EBuffer();
    virtual void DeleteRelated();

    virtual EViewPort *CreateViewPort(EView *V);
    EEditPort *GetViewVPort(EView *V);
    EEditPort *GetVPort();

    virtual int CanQuit();
    virtual int ConfQuit(GxView *V, int multiFile = 0);

    virtual int GetContext();
    virtual EEventMap *GetEventMap();
    virtual int BeginMacro();
    virtual int ExecCommand(ExCommands Command, ExState &State);
    virtual void HandleEvent(TEvent &Event);

    virtual void GetName(char *AName, size_t MaxLen);
    virtual void GetPath(char *APath, size_t MaxLen);
    virtual void GetInfo(char *AInfo, size_t MaxLen);
    virtual void GetTitle(char *ATitle, size_t MaxLen, char *ASTitle, size_t SMaxLen);

    PELine RLine(int No) {
#ifdef DEBUG_EDITOR
        int N = GapLine(No, RGap, RCount, RAllocated);
        if (!((No < RCount) && (No >= 0) && (LL[N]))) {
            printf("Get No = %d/%d Gap=%d RAlloc = %d, VCount = %d\n", No, RCount, RGap, RAllocated, VCount);
            assert((No < RCount) && (No >= 0) && (LL[N]));
        }
#endif
        return LL[GapLine(No, RGap, RCount, RAllocated)];
    }
    void RLine(int No, PELine L) {
#ifdef DEBUG_EDITOR
        if (!((No >= 0))) printf("Set No = %d\n", No);
        assert((No >= 0));
#endif
        LL[GapLine(No, RGap, RCount, RAllocated)] = L;
    }
    int Vis(int No) {
#ifdef DEBUG_EDITOR
        if (No < 0 || No >= VCount) {
            printf("Vis get no %d of %d\n", No, VCount);
            assert (No >= 0 && No < VCount);
        }
#endif
        return VV[GapLine(No, VGap, VCount, VAllocated)];
    }
    void Vis(int No, int V) {
#ifdef DEBUG_EDITOR
        if (No < 0 || No >= VCount) {
            printf("Vis set no %d of %d to %d\n", No, VCount, V);
            assert (No >= 0 && No < VCount);
        }
#endif
        VV[GapLine(No, VGap, VCount, VAllocated)] = V;
    }
    PELine VLine(int No) {
#ifdef DEBUG_EDITOR
        if (!((No < VCount) && (No >= 0))) {
            printf("VGet No = %d\n", No);
            assert((No < VCount) && (No >= 0));
        }
        if (Vis(No) < 0)
            assert(1 == 0);
#endif
        return RLine(No + Vis(No));
    }
    void VLine(int No, PELine L) {
#ifdef DEBUG_EDITOR
        if (!((No >= 0))) {
            printf("VSet No = %d\n", No);
            assert((No >= 0));
        }
        if (VV[No] < 0)
            assert(1 == 0);
#endif
        RLine(No + Vis(No), L);
    }

    int VToR(int No) {
	if (!VCount)
            return 0;
#ifdef DEBUG_EDITOR
        if (!(No < VCount)) {
            printf("Get No = %d\n", No);
            assert((No < VCount));
        }
#endif
        return No + Vis(No);
    }

    int RToV(int No);
    int RToVN(int No);

    // allocation
    int Allocate(int ACount);
    int MoveRGap(int RPos);
    int AllocVis(int ACount);
    int MoveVGap(int VPos);

    int Modify();
    int Clear();

#ifdef CONFIG_UNDOREDO
    int FreeUndo();
#endif
    // internal primitives
    int ValidPos(EPoint W);
    int RValidPos(EPoint W);
    int LoadRegion(EPoint *A, int FH, int StripChar, int LineChar);
    int SaveRegion(EPoint *A, EPoint *Z, int FH, int AddCR, int AddLF, int Mode);

    int AssertLine(int Line);
    int InsertLine(const EPoint& Pos, size_t ACount, const char *AChars);

    int UpdateMarker(int Type, int Line, int Col, int Lines, int Cols);
    int UpdateMark(EPoint &M, int Type, int Line, int Col, int Lines, int Cols);
    void UpdateVis(EPoint &M, int Row, int Delta);
    void UpdateVisible(int Row, int Delta);
    int LoadFrom(const char *AFileName);
    int SaveTo(const char *AFileName);

    int IsBlockStart();
    int IsBlockEnd();
    int BlockType(int Mode);
    int BeginExtend();
    int EndExtend();
    int CheckBlock();
    int BlockRedraw();
    int SetBB(const EPoint& M);
    int SetBE(const EPoint& M);

    int Load();
    int Save();
    int Reload();
    int FilePrint();
    int SetFileName(const char *AFileName, const char *AMode);

    int SetPos(int Col, int Row, int tabMode = tmNone);
    int SetPosR(int Col, int Row, int tabMode = tmNone);
    int CenterPos(int Col, int Row, int tabMode = tmNone);
    int CenterPosR(int Col, int Row, int tabMode = tmNone);
    int SetNearPos(int Col, int Row, int tabMode = tmNone);
    int SetNearPosR(int Col, int Row, int tabMode = tmNone);
    int CenterNearPos(int Col, int Row, int tabMode = tmNone);
    int CenterNearPosR(int Col, int Row, int tabMode = tmNone);
    int LineLen(int Row);
    int LineChars(int Row);

/////////////////////////////////////////////////////////////////////////////
// Undo/Redo Routines
/////////////////////////////////////////////////////////////////////////////

    int NextCommand();
#ifdef CONFIG_UNDOREDO
    int PushUData(const void *data, size_t len);
    int PushULong(unsigned long l);
    int PushUChar(unsigned char ch);
    int PopUData(void *data, size_t len);
    int GetUData(int No, int pos, void **data, size_t len);
    int Undo(int undo);
    int Undo();
    int Redo();
    int BeginUndo();
    int EndUndo();
    int PushBlockData();
#endif

/////////////////////////////////////////////////////////////////////////////
// Primitive Editing
/////////////////////////////////////////////////////////////////////////////

    //int ExpReg(int Row, int Ofs, int ACount, int &B, int &E);
    int ScreenPos(ELine *L, int Offset);
    int CharOffset(ELine *L, int ScreenPos);
    int DelLine(int Row, int DoMark = 1);
    int UnTabPoint(int Row, int Col);
    int InsLine(int Row, int DoAppend, int DoMark = 1);
    int DelChars(int Row, int Ofs, size_t ACount);
    int InsChars(int Row, int Ofs, size_t ACount, const char *Buffer);
    int ChgChars(int Row, int Ofs, size_t ACount, const char *Buffer);
    int DelText(int Row, int Col, size_t ACount, int DoMark = 1);
    int InsText(int Row, int Col, size_t ACount, const char *Buffer, int DoMark = 1);
    int InsLineText(int Row, int Col, size_t ACount, int Pos, PELine Line);
    int SplitLine(int Row, int Col);
    int JoinLine(int Row, int Col);
    int CanUnfold(int Row);
    int PadLine(int Row, size_t Length);

    int ShowRow(int Row);
    int HideRow(int Row);
    int ExposeRow(int Row); // make row visible (open all folds containing)

/////////////////////////////////////////////////////////////////////////////
// Redraw/Windowing Routines
/////////////////////////////////////////////////////////////////////////////

    void Draw(int Line0, int LineE);
    void DrawLine(TDrawBuffer B, int L, int C, int W, int &HilitX);
    void Hilit(int FromRow);
    void Rehilit(int ToRow);
    void Redraw();
    void FullRedraw();
    int  GetHilitWord(ChColor &clr, const char *str, size_t len, int IgnCase = 0);

/////////////////////////////////////////////////////////////////////////////
// Utility Routines
/////////////////////////////////////////////////////////////////////////////

    int LineIndented(int Row, const char *indentchars = 0);
    int LineIndentedCharCount(ELine *l, const char *indentchars);
    int IndentLine(int Row, int Indent);
#ifdef CONFIG_SYNTAX_HILIT
    int GetMap(int Row, int *StateLen, hsState **StateMap);
#endif
    int FindStr(const char *Data, int Len, int Options);
    int FindStr(const char *Data, int Len, SearchReplaceOptions &opt);
    int FindRx(RxNode *Rx, SearchReplaceOptions &opt);
    int Find(SearchReplaceOptions &opt);
    int IsLineBlank(int Row);
    int TrimLine(int Row);

#ifdef CONFIG_OBJ_ROUTINE
    int ScanForRoutines();
#endif

/////////////////////////////////////////////////////////////////////////////
// Bookmark Routines
/////////////////////////////////////////////////////////////////////////////

#ifdef CONFIG_BOOKMARKS
    int PlaceBookmark(const char *Name, const EPoint &P);
    int RemoveBookmark(const char *Name);
    int GetBookmark(const char *Name, EPoint &P);
    int GotoBookmark(const char *Name);
    int GetBookmarkForLine(int searchFrom, int searchForLine, const EBookmark* &b);
#endif

/////////////////////////////////////////////////////////////////////////////
// Editing Routines
/////////////////////////////////////////////////////////////////////////////

    int     MoveLeft();
    int     MoveRight();
    int     MoveUp();
    int     MoveDown();
    int     MovePrev();
    int     MoveNext();
    int     MoveWordLeftX(int start);
    int     MoveWordRightX(int start);
    int     MoveWordLeft();
    int     MoveWordRight();
    int     MoveWordPrev();
    int     MoveWordNext();
    int     MoveWordEndLeft();
    int     MoveWordEndRight();
    int     MoveWordEndPrev();
    int     MoveWordEndNext();
    int     MoveWordOrCapLeft();
    int     MoveWordOrCapRight();
    int     MoveWordOrCapPrev();
    int     MoveWordOrCapNext();
    int     MoveWordOrCapEndLeft();
    int     MoveWordOrCapEndRight();
    int     MoveWordOrCapEndPrev();
    int     MoveWordOrCapEndNext();
//    int     MoveWordStart();
//    int     MoveWordEnd();
    int     MoveLineStart();
    int     MoveLineEnd();
    int     MovePageUp();
    int     MovePageDown();
    int     MovePageLeft();
    int     MovePageRight();
    int     MovePageStart();
    int     MovePageEnd();
    int     MoveFileStart();
    int     MoveFileEnd();
    int     MoveBlockStart();
    int     MoveBlockEnd();
    int     ScrollLeft(int Cols);
    int     ScrollRight(int Cols);
    int     ScrollDown(int Lines);
    int     ScrollUp(int Lines);
    int     MoveToLine();
    int     MoveToColumn();
    int     MoveFirstNonWhite();
    int     MoveLastNonWhite();
    int     MovePrevEqualIndent();
    int     MoveNextEqualIndent();
    int     MovePrevTab();
    int     MoveNextTab();
    int     MoveLineTop();
    int     MoveLineCenter();
    int     MoveLineBottom();
    int     MovePrevPos();
    int     MoveSavedPosCol();
    int     MoveSavedPosRow();
    int     MoveSavedPos();
    int     SavePos();
    int     MoveTabStart();
    int     MoveTabEnd();
    int     MoveFoldTop();
    int     MoveFoldPrev();
    int     MoveFoldNext();
    int     MoveBeginOrNonWhite();
    int     MoveBeginLinePageFile();
    int     MoveEndLinePageFile();

    int     KillLine();
    int     KillChar();
    int     KillCharPrev();
    int     KillWord();
    int     KillWordPrev();
    int     KillWordOrCap();
    int     KillWordOrCapPrev();
    int     KillToLineStart();
    int     KillToLineEnd();
    int     KillBlock();
    int     BackSpace();
    int     Delete();
    int     CompleteWord();
    int     KillBlockOrChar();
    int     KillBlockOrCharPrev();

#define ccUp       0
#define ccDown     1
#define ccToggle   2

    int     CharTrans(TransTable tab);
    int     CharCaseUp();
    int     CharCaseDown();
    int     CharCaseToggle();

    int     LineTrans(TransTable tab);
    int     LineCaseUp();
    int     LineCaseDown();
    int     LineCaseToggle();

    int     BlockTrans(TransTable tab);
    int     BlockCaseUp();
    int     BlockCaseDown();
    int     BlockCaseToggle();

    int     CharTrans(ExState &State);
    int     LineTrans(ExState &State);
    int     BlockTrans(ExState &State);
    int     GetTrans(ExState &State, TransTable tab);

    int     LineInsert();
    int     LineAdd();
    int     LineSplit();
    int     LineJoin();
    int     LineNew();
    int     LineIndent();
    int     LineTrim();
    int     LineCenter();
    int     FileTrim();
    int     BlockTrim();

#ifdef CONFIG_UNDOREDO
    int     CanUndo();
    int     CanRedo();
#endif

    int     LineLen();
    int     LineCount();
    int     CLine();
    int     CColumn();

    int     InsertChar(char aCh);
    int     TypeChar(char aCh);
    int     InsertString(const char *aStr, size_t aCount);
    int     InsertSpacesToTab(int TSize);
    int     InsertTab();
    int     InsertSpace();
    int     SelfInsert();
#ifdef CONFIG_WORDWRAP
    int     DoWrap(int WrapAll);
    int     WrapPara();
#endif
    int     InsPrevLineChar();
    int     InsPrevLineToEol();
    int     LineDuplicate();

    int     GetMatchBrace(EPoint &M, int MinLine, int MaxLine, int show);
    int     MatchBracket();
    int     HilitMatchBracket();

    int     BlockBegin();
    int     BlockEnd();
    int     BlockUnmark();
    int     BlockCut(int Append);
    int     BlockCopy(int Append, int clipboard=0);
    int     BlockPaste(int clipboard=0);
    int     BlockKill();
    int     BlockIndent();
    int     BlockUnindent();
    int     BlockClear();
    int     BlockMarkStream();
    int     BlockMarkLine();
    int     BlockMarkColumn();
    int     BlockReadFrom(const char *aFileName, int blockMode);
    int     BlockWriteTo(const char *aFileName, int Append = 0);
    int     BlockExtendBegin();
    int     BlockExtendEnd();
    int     BlockReIndent();
    int     BlockIsMarked();
    int     BlockPasteStream(int clipboard=0);
    int     BlockPasteLine(int clipboard=0);
    int     BlockPasteColumn(int clipboard=0);
    int     BlockPasteOver(int clipboard=0);
    int     BlockSelectWord();
    int     BlockSelectLine();
    int     BlockSelectPara();
    int     BlockPrint();
    int     BlockSort(int Reverse);
    int     ClipClear(int clipboard=0);
    int     BlockUnTab();
    int     BlockEnTab();

    int     ToggleAutoIndent();
    int     ToggleInsert();
    int     ToggleExpandTabs();
    int     ToggleShowTabs();
    int     ToggleUndo();
    int     ToggleReadOnly();
    int     ToggleKeepBackups();
    int     ToggleMatchCase();
    int     ToggleBackSpKillTab();
    int     ToggleDeleteKillTab();
    int     ToggleSpaceTabs();
    int     ToggleIndentWithTabs();
    int     ToggleBackSpUnindents();
    int     ToggleWordWrap();
    int     ToggleTrim();
    int     ToggleShowMarkers();
    int     ToggleHilitTags();
    int     ToggleShowBookmarks();
    int     ToggleMakeBackups();
    int     SetLeftMargin();
    int     SetRightMargin();

    int     ShowPosition();

    int     Search(ExState &State, const char *aString, int Options, int CanResume = 0);
    int     SearchAgain(ExState &State, unsigned int Options);
    int     SearchReplace(ExState &State, const char *aString, const char *aReplaceString, int Options);
    int     Search(ExState &State);
    int     SearchB(ExState &State);
    int     SearchRx(ExState &State);
    int     SearchAgain(ExState &State);
    int     SearchAgainB(ExState &State);
    int     SearchReplace(ExState &State);
    int     SearchReplaceB(ExState &State);
    int     SearchReplaceRx(ExState &State);

#ifdef CONFIG_WORD_HILIT
    int     HilitAddWord(const char *Word);
    int     HilitFindWord(const char *Word);
    int     HilitRemoveWord(const char *Word);
    int     HilitWord();
#endif
    int     SearchWord(int Flags);

#ifdef CONFIG_FOLDS
    int     FindFold(int Line);
    int     FindNearFold(int Line);
    int     FoldCreate(int Line);
    int     FoldCreateByRegexp(const char *Regexp);
    int     FoldDestroy(int Line);
    int     FoldDestroyAll();
    int     FoldPromote(int Line);
    int     FoldDemote(int Line);
    int     FoldOpen(int Line);
    int     FoldOpenAll();
    int     FoldOpenNested();
    int     FoldClose(int Line);
    int     FoldCloseAll();
    int     FoldToggleOpenClose();
#endif

    int     ChangeMode(const char *Mode);
    int     ChangeKeys(const char *Mode);
    int     ChangeFlags(const char *Mode);

    int ScrollLeft(ExState &State);
    int ScrollRight(ExState &State);
    int ScrollDown(ExState &State);
    int ScrollUp(ExState &State);

    /* editor functions with user interface */

    int MoveToColumn(ExState &State);
    int MoveToLine(ExState &State);
    int FoldCreateByRegexp(ExState &State);
#ifdef CONFIG_BOOKMARKS
    int PlaceUserBookmark(const char *n,EPoint P);
    int RemoveUserBookmark(const char *n);
    int GotoUserBookmark(const char *n);
    int GetUserBookmarkForLine(int searchFrom, int searchForLine, const EBookmark* &b);
    int PlaceBookmark(ExState &State);
    int RemoveBookmark(ExState &State);
    int GotoBookmark(ExState &State);
#endif
    int InsertString(ExState &State);
    int SelfInsert(ExState &State);
    int FileReload(ExState &State);
    int FileSaveAs(const char *FileName);
    int FileSaveAs(ExState &State);
    int FileWriteTo(const char *FileName);
    int FileWriteTo(ExState &State);
    int BlockReadX(ExState &State, int BlockMode);
    int BlockRead(ExState &State);
    int BlockReadStream(ExState &State);
    int BlockReadLine(ExState &State);
    int BlockReadColumn(ExState &State);
    int BlockWrite(ExState &State);
    int Find(ExState &State);
    int FindReplace(ExState &State);
    int FindRepeat(ExState &State);
    int FindRepeatOnce(ExState &State);
    int FindRepeatReverse(ExState &State);
    int InsertChar(ExState &State);
    int TypeChar(ExState &State);
    int ChangeMode(ExState &State);
    int ChangeKeys(ExState &State);
    int ChangeFlags(ExState &State);
    int ChangeTabSize(ExState &State);
    int ChangeRightMargin(ExState &State);
    int ChangeLeftMargin(ExState &State);

#ifdef CONFIG_I_ASCII
    int ASCIITable(ExState &State);
#endif

#ifdef CONFIG_TAGS
    int FindTag(ExState &State);
    int FindTagWord(ExState &State);
#endif

    int SetCIndentStyle(ExState &State);

    int FindFunction(int delta, int way);
    int BlockMarkFunction();
    int IndentFunction();
    int MoveFunctionPrev();
    int MoveFunctionNext();
    int InsertDate(ExState& state);
    int InsertUid();

    int ShowHelpWord(ExState &State);

    int PlaceGlobalBookmark(ExState &State);
    int PushGlobalBookmark();

    virtual int GetStrVar(int var, char *str, size_t buflen);
    virtual int GetIntVar(int var, int *value);

    int SetIndentWithTabs(ExState &State);
    int FoldCreateAtRoutines();
};

extern EBuffer *SSBuffer;
extern SearchReplaceOptions LSearch;

extern int suspendLoads;

int DoneEditor();

EBuffer *FindFile(const char *FileName);

int ParseSearchOption(int replace, char c, unsigned long &opt);
int ParseSearchOptions(int replace, const char *str, unsigned long &Options);
int ParseSearchReplace(EBuffer *B, const char *str, int replace, SearchReplaceOptions &opt);

#endif // E_BUFFER_H