Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGTextEdit.cxx
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2// Author: Fons Rademakers 3/7/2000
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11/**************************************************************************
12
13 This source is based on Xclass95, a Win95-looking GUI toolkit.
14 Copyright (C) 1996, 1997 David Barth, Ricky Ralston, Hector Peraza.
15
16 Xclass95 is free software; you can redistribute it and/or
17 modify it under the terms of the GNU Library General Public
18 License as published by the Free Software Foundation; either
19 version 2 of the License, or (at your option) any later version.
20
21**************************************************************************/
22
23
24/** \class TGTextEdit
25 \ingroup guiwidgets
26
27A TGTextEdit is a specialization of TGTextView. It provides the
28text edit functionality to the static text viewing widget.
29For the messages supported by this widget see the TGView class.
30
31*/
32
33
34#include "TGTextEdit.h"
35#include "TGTextEditDialogs.h"
36#include "TGResourcePool.h"
37#include "TSystem.h"
38#include "TTimer.h"
39#include "TGMenu.h"
40#include "TGMsgBox.h"
41#include "TGFileDialog.h"
42#include "TGScrollBar.h"
43#include "KeySymbols.h"
44#include "RConfigure.h"
45#include "TVirtualX.h"
46
47#include <iostream>
48
49static const char *gFiletypes[] = { "All files", "*",
50 "Text files", "*.txt",
51 "ROOT macros", "*.C",
52 0, 0 };
53static char *gPrinter = nullptr;
54static char *gPrintCommand = nullptr;
55
56
59
60
61///////////////////////////////////////////////////////////////////////////////
62class TGTextEditHist : public TList {
63
64public:
66 ~TGTextEditHist() override { Delete(); }
67
68 Bool_t Notify() override
69 { //
70 TObject *obj = Last();
71 if (!obj) return kFALSE;
72
73 obj->Notify(); // execute undo action
74 RemoveLast();
75 delete obj;
76 return kTRUE;
77 }
78};
79
80///////////////////////////////////////////////////////////////////////////////
81class TGTextEditCommand : public TObject {
82protected:
85
86public:
91 void SetPos(TGLongPosition pos) { fPos = pos; }
92};
93
94///////////////////////////////////////////////////////////////////////////////
96
97public:
99 fEdit->InsChar(ch);
100 }
101 Bool_t Notify() override
102 { //
104 fEdit->NextChar();
105 fEdit->DelChar();
106 return kTRUE;
107 }
108};
109
110///////////////////////////////////////////////////////////////////////////////
112
113private:
114 char fChar;
115
116public:
122 Bool_t Notify() override
123 { //
124 if (fChar > 0) {
127 } else {
128 fPos.fY--;
129 fEdit->BreakLine();
130 }
131 return kTRUE;
132 }
133};
134
135///////////////////////////////////////////////////////////////////////////////
137
138public:
144
145 Bool_t Notify() override
146 { //
148 fEdit->DelChar();
149 return kTRUE;
150 }
151};
152
153///////////////////////////////////////////////////////////////////////////////
155private:
157
158public:
159 char fChar;
160
163
165 fEndPos = end;
166 }
167
168 Bool_t Notify() override
169 { //
171
172 if (fChar > 0) {
174 } else if (fPos.fY != fEndPos.fY) {
176 }
178 fEdit->Update();
179 return kTRUE;
180 }
181};
182
183///////////////////////////////////////////////////////////////////////////////
185
186private:
190
191public:
197 fText = new TGText(dtc.fText);
198 fBreakLine = dtc.fBreakLine;
199 }
200 ~TDelTextCom() override { delete fText; }
201
203 if (this != &dtc) {
204 if (fText) delete fText;
205 fText = new TGText(dtc.fText);
206 fBreakLine = dtc.fBreakLine;
207 }
208 return *this;
209 }
210
212 fEndPos = end;
213 }
214
216
217 Bool_t Notify() override
218 { //
220 start_src.fX = start_src.fY = 0;
221 end_src.fY = fText->RowCount() - 1;
222 end_src.fX = fText->GetLineLength(end_src.fY) - 1;
223
225
226 if (fBreakLine) {
227 fEndPos.fY++;
230 } else {
231 fEndPos.fX++;
232 }
233
235 fEdit->Update();
236 return kTRUE;
237 }
238};
239
240
241
242
243////////////////////////////////////////////////////////////////////////////////
244/// Create a text edit widget.
245
247 UInt_t sboptions, Pixel_t back) :
248 TGTextView(parent, w, h, id, sboptions, back)
249{
250 Init();
251}
252
253////////////////////////////////////////////////////////////////////////////////
254/// Create a text edit widget. Initialize it with the specified text buffer.
255
257 Int_t id, UInt_t sboptions, Pixel_t back) :
258 TGTextView(parent, w, h, text, id, sboptions, back)
259{
260 Init();
261}
262
263////////////////////////////////////////////////////////////////////////////////
264/// Create a text edit widget. Initialize it with the specified string.
265
267 const char *string, Int_t id, UInt_t sboptions,
268 Pixel_t back) :
269 TGTextView(parent, w, h, string, id, sboptions, back)
270{
271 Init();
272}
273
274////////////////////////////////////////////////////////////////////////////////
275/// Cleanup text edit widget.
276
278{
281 }
282 delete fCurBlink;
283 delete fMenu;
284 delete fHistory;
285}
286
287////////////////////////////////////////////////////////////////////////////////
288/// Initialize a text edit widget.
289
291{
294 fCursorState = 1;
295 fCurrent.fY = fCurrent.fX = 0;
297 fCurBlink = 0;
298 fSearch = 0;
301
302 gVirtualX->SetCursor(fCanvas->GetId(), fClient->GetResourcePool()->GetTextCursor());
303
304 // create popup menu with default editor actions
306 fMenu->AddEntry("New", kM_FILE_NEW);
307 fMenu->AddEntry("Open...", kM_FILE_OPEN);
309 fMenu->AddEntry("Close", kM_FILE_CLOSE);
310 fMenu->AddEntry("Save", kM_FILE_SAVE);
311 fMenu->AddEntry("Save As...", kM_FILE_SAVEAS);
313 fMenu->AddEntry("Print...", kM_FILE_PRINT);
315 fMenu->AddEntry("Cut", kM_EDIT_CUT);
316 fMenu->AddEntry("Copy", kM_EDIT_COPY);
317 fMenu->AddEntry("Paste", kM_EDIT_PASTE);
318 fMenu->AddEntry("Select All", kM_EDIT_SELECTALL);
320 fMenu->AddEntry("Find...", kM_SEARCH_FIND);
321 fMenu->AddEntry("Find Again", kM_SEARCH_FINDAGAIN);
322 fMenu->AddEntry("Goto...", kM_SEARCH_GOTO);
323
324 fMenu->Associate(this);
325
326 fHistory = new TGTextEditHist();
327}
328
329////////////////////////////////////////////////////////////////////////////////
330/// Enable/disable menu items in function of what is possible.
331
367
368////////////////////////////////////////////////////////////////////////////////
369/// Return width of longest line in widget.
370
377
378////////////////////////////////////////////////////////////////////////////////
379/// Clear text edit widget.
380
382{
383 fCursorState = 1;
384 fCurrent.fY = fCurrent.fX = 0;
386}
387
388////////////////////////////////////////////////////////////////////////////////
389/// Save file. If filename==0 ask user via dialog for a filename, if in
390/// addition saveas==kTRUE always ask for new filename. Returns
391/// kTRUE if file was correctly saved, kFALSE otherwise.
392
394{
395 if (!filename) {
397 if (untitled || saveas) {
398 static TString dir(".");
399 static Bool_t overwr = kFALSE;
401 fi.fFileTypes = gFiletypes;
402 fi.SetIniDir(dir);
403 fi.fOverwrite = overwr;
405 overwr = fi.fOverwrite;
406 if (fi.fFilename && strlen(fi.fFilename)) {
407 dir = fi.fIniDir;
408 return fText->Save(fi.fFilename);
409 }
410 return kFALSE;
411 }
412 return fText->Save(fText->GetFileName());
413 }
414
415 return fText->Save(filename);
416}
417
418////////////////////////////////////////////////////////////////////////////////
419/// Copy text.
420
422{
423 if (!fIsMarked || ((fMarkedStart.fX == fMarkedEnd.fX) &&
425 return kFALSE;
426 }
427
429
431 del = del || (!fMarkedEnd.fX && (fCurrent.fY != fMarkedEnd.fY));
432 del = del && fClipText->AsString().Length() > 0;
433
434 if (del) {
435 TGLongPosition pos;
436 pos.fY = fClipText->RowCount();
437 pos.fX = 0;
438 fClipText->InsText(pos, 0);
439 }
440
441 return kTRUE;
442}
443
444////////////////////////////////////////////////////////////////////////////////
445/// Cut text.
446
448{
449 if (!Copy()) {
450 return kFALSE;
451 }
452 Delete();
453
454 return kTRUE;
455}
456
457////////////////////////////////////////////////////////////////////////////////
458/// Paste text into widget.
459
461{
462 if (fReadOnly) {
463 return kFALSE;
464 }
465
466 if (fIsMarked) {
469 Delete();
470 fClipText->Clear();
471 fClipText->LoadBuffer(sav.Data());
472 }
473
474 gVirtualX->ConvertPrimarySelection(fId, fClipboard, 0);
475
476 return kTRUE;
477}
478
479////////////////////////////////////////////////////////////////////////////////
480/// Send current buffer to printer.
481
483{
484 TString msg;
485
486 msg.Form("%s -P%s\n", gPrintCommand, gPrinter);
487 FILE *p = gSystem->OpenPipe(msg.Data(), "w");
488 if (p) {
489 char *buf1, *buf2;
490 Long_t len;
491 ULong_t i = 0;
492 TGLongPosition pos;
493
494 pos.fX = pos.fY = 0;
495 while (pos.fY < fText->RowCount()) {
496 len = fText->GetLineLength(pos.fY);
497 if (len < 0) len = 0;
498 buf1 = fText->GetLine(pos, len);
499 buf2 = new char[len + 2];
501 buf2[len] = '\n';
502 buf2[len+1] = '\0';
503 while (buf2[i] != '\0') {
504 if (buf2[i] == '\t') {
505 ULong_t j = i+1;
506 while (buf2[j] == 16)
507 j++;
508 // coverity[secure_coding]
509 strcpy(buf2+i+1, buf2+j);
510 }
511 i++;
512 }
513 fwrite(buf2, sizeof(char), strlen(buf2)+1, p);
514
515 delete [] buf1;
516 delete [] buf2;
517 pos.fY++;
518 }
520
522 msg.Form("Printed: %s\nLines: %ld\nUsing: %s -P%s",
523 untitled ? "Untitled" : fText->GetFileName(),
525 new TGMsgBox(fClient->GetDefaultRoot(), this, "Editor", msg.Data(),
527 } else {
528 msg.Form("Could not execute: %s -P%s\n", gPrintCommand, gPrinter);
529 new TGMsgBox(fClient->GetDefaultRoot(), this, "Editor", msg.Data(),
531 }
532}
533
534////////////////////////////////////////////////////////////////////////////////
535/// Delete selection.
536
538{
539 if (!fIsMarked || fReadOnly) {
540 return;
541 }
542
543 if (fMarkedStart.fX == fMarkedEnd.fX &&
546
547 if (fCurrent.fY == fText->RowCount()-1 && fCurrent.fX == len) {
548 gVirtualX->Bell(0);
549 return;
550 }
551
552 new TDelCharCom(this);
553 return;
554 }
555
558
559 endPos.fX = fMarkedEnd.fX - 1;
560 endPos.fY = fMarkedEnd.fY;
561
562 if (endPos.fX == -1) {
563 pos = fCurrent;
564 if (endPos.fY > 0) {
566 DelChar();
567 endPos.fY--;
568 SetCurrent(pos);
569 }
571 if (endPos.fX < 0) {
572 endPos.fX = 0;
573 }
574 delast = kTRUE;
575 }
576
577 // delete command for undo
579 dcom->SetPos(fMarkedStart);
580 dcom->SetEndPos(endPos);
581
582 if (delast || ((fText->GetLineLength(endPos.fY) == endPos.fX+1) &&
583 (fClipText->RowCount() > 1))) {
585
586 p.fY--;
587 if (!delast) p.fX++;
588 dcom->SetEndPos(p);
589 dcom->SetBreakLine(kTRUE);
590 }
591
593
594 pos.fY = ToObjYCoord(fVisible.fY);
595
596 if (fMarkedStart.fY < pos.fY) {
597 pos.fY = fMarkedStart.fY;
598 }
599 pos.fX = ToObjXCoord(fVisible.fX, pos.fY);
600 if (fMarkedStart.fX < pos.fX) {
601 pos.fX = fMarkedStart.fX;
602 }
603
606 th = th < 0 ? 0 : th;
607 ys = ys < 0 ? 0 : ys;
608
609 // clear
610 if ((th < 0) || (th < (Int_t)fCanvas->GetHeight())) {
611 gVirtualX->ClearArea(fCanvas->GetId(), 0, ys,
613 }
614
616
622
624 UnMark();
625
626 // only to make sure that IsSaved() returns true in case everything has
627 // been deleted
628 if (fText->RowCount() == 1 && fText->GetLineLength(0) == 0) {
629 delete fText;
630 fText = new TGText();
631 fText->Clear();
632 }
633}
634
635////////////////////////////////////////////////////////////////////////////////
636/// Search for string in the specified direction. If direction is true
637/// the search will be in forward direction.
638
641{
642 if (!IsMapped()) return kFALSE;
643
645 caseSensitive = TGSearchDialog::SearchDialog()->GetType()->fCaseSensitive;
646 direction = TGSearchDialog::SearchDialog()->GetType()->fDirection;
648 }
649
650 TGLongPosition pos;
651 if (!fText->Search(&pos, fCurrent, string, direction, caseSensitive)) {
652 fCurrent.fX = 1;
653 fCurrent.fY = 1;
654
655 if (!fText->Search(&pos, fCurrent, string, direction, caseSensitive)) { //try again
656 TString msg;
657 msg.Form("Couldn't find \"%s\"", string);
658 gVirtualX->Bell(20);
659 new TGMsgBox(fClient->GetDefaultRoot(), fCanvas, "TextEdit",
660 msg.Data(), kMBIconExclamation, kMBOk, 0);
661 return kFALSE;
662 }
663 return kTRUE;
664 }
665 UnMark();
668 fMarkedStart.fX = pos.fX;
669 fMarkedEnd.fX = fMarkedStart.fX + strlen(string);
670
671 if (direction) {
673 } else {
675 }
676
677 pos.fY = ToObjYCoord(fVisible.fY);
678 if (fCurrent.fY < pos.fY ||
680 pos.fY = fMarkedStart.fY;
681 }
682 pos.fX = ToObjXCoord(fVisible.fX, pos.fY);
683
684 if (fCurrent.fX < pos.fX ||
686 pos.fX = fMarkedStart.fX;
687 }
688
691
694
695 return kTRUE;
696}
697
698////////////////////////////////////////////////////////////////////////////////
699/// Replace text starting at textPos.
700
703{
704 TGLongPosition pos;
706 return kFALSE;
707 }
708 UnMark();
713
714 if (direction) {
716 } else {
718 }
719
720 pos.fY = ToObjYCoord(fVisible.fY);
721 if (fCurrent.fY < pos.fY ||
723 pos.fY = fMarkedStart.fY;
724 }
725 pos.fX = ToObjXCoord(fVisible.fX, pos.fY);
726 if (fCurrent.fX < pos.fX ||
728 pos.fX = fMarkedStart.fX;
729 }
730
733
736
737 return kTRUE;
738}
739
740////////////////////////////////////////////////////////////////////////////////
741/// Goto the specified line.
742
744{
745 if (line < 0)
746 line = 0;
747 if (line >= fText->RowCount())
748 line = fText->RowCount() - 1;
749 if (column < 0)
750 column = 0;
751 if (column > fText->GetLineLength(line))
752 column = fText->GetLineLength(line);
753
755 gotopos.fY = line;
756 gotopos.fX = column;
758
759 pos.fY = ToObjYCoord(fVisible.fY);
760 if (fCurrent.fY < pos.fY ||
762 pos.fY = gotopos.fY;
763
766
767 UnMark();
770 fMarkedStart.fX = 0;
772
773 return kTRUE;
774}
775
776////////////////////////////////////////////////////////////////////////////////
777/// Sets the mode how characters are entered.
778
780{
781 if (fInsertMode == mode) return;
782
784}
785
786////////////////////////////////////////////////////////////////////////////////
787/// If cursor if on, turn it off.
788
790{
791 if (fCursorState == 1) {
792 DrawCursor(2);
793 }
794 fCursorState = 2;
795}
796
797////////////////////////////////////////////////////////////////////////////////
798/// Turn cursor on.
799
801{
802 DrawCursor(1);
803 fCursorState = 1;
804
805 if (fCurBlink) {
806 fCurBlink->Reset();
807 }
808}
809
810////////////////////////////////////////////////////////////////////////////////
811/// Make the specified position the current position.
812
825
826////////////////////////////////////////////////////////////////////////////////
827/// Draw cursor. If mode = 1 draw cursor, if mode = 2 erase cursor.
828
830{
831 char count = -1;
832 char cursor = ' ';
834 return;
835 }
836
841 if (fCurrent.fY < fText->RowCount()) {
842 count = fText->GetChar(fCurrent);
843 }
844 if (count == -1 || count == '\t') {
845 cursor = ' ';
846 } else {
847 cursor = count;
848 }
849
850 if (mode == 2) {
851 if (fIsMarked && count != -1) {
860 // back ground fillrectangle
861 gVirtualX->FillRectangle(fCanvas->GetId(), fSelbackGC(),
867 if (count != -1)
870 } else {
871 gVirtualX->ClearArea(fCanvas->GetId(),
877 if (count != -1)
880 }
881 } else {
882 gVirtualX->ClearArea(fCanvas->GetId(),
890 }
891 } else {
892 if (mode == 1) {
893 gVirtualX->FillRectangle(fCanvas->GetId(), fCursor1GC,
896 2,
898 }
899 }
900 }
901}
902
903////////////////////////////////////////////////////////////////////////////////
904/// Adjust current position.
905
907{
908 TGLongPosition pos;
909 pos.fY = fCurrent.fY;
910 pos.fX = fCurrent.fX;
911
912 if (pos.fY < ToObjYCoord(fVisible.fY)) {
913 pos.fY = ToObjYCoord(fVisible.fY);
914 } else if (ToScrYCoord(pos.fY+1) >= (Int_t) fCanvas->GetHeight()) {
916 }
917 if (pos.fX < ToObjXCoord(fVisible.fX, pos.fY)) {
918 pos.fX = ToObjXCoord(fVisible.fX, pos.fY);
919 } else if (ToScrXCoord(pos.fX, pos.fY) >= (Int_t) fCanvas->GetWidth()) {
920 pos.fX = ToObjXCoord(fVisible.fX + fCanvas->GetWidth(), pos.fY)-1;
921 }
922 if (pos.fY != fCurrent.fY || pos.fX != fCurrent.fX) {
923 SetCurrent(pos);
924 }
925}
926
927////////////////////////////////////////////////////////////////////////////////
928/// Handle timer cursor blink timer.
929
931{
932 if (t != fCurBlink) {
934 return kTRUE;
935 }
936
937 if (fCursorState == 1) {
938 fCursorState = 2;
939 } else {
940 fCursorState = 1;
941 }
942
944
945 return kTRUE;
946}
947
948////////////////////////////////////////////////////////////////////////////////
949/// Handle selection notify event.
950
952{
954 Int_t nchar;
955
956 gVirtualX->GetPasteBuffer((Window_t)event->fUser[0], (Atom_t)event->fUser[3],
957 data, nchar, kFALSE);
958
959 if (!nchar) return kTRUE;
960
961 delete fClipText;
962
963 fClipText = new TGText;
964 fClipText->LoadBuffer(data.Data());
965
967
968 pos.fX = pos.fY = 0;
969 start_src.fY = start_src.fX = 0;
970 end_src.fY = fClipText->RowCount()-1;
972
973 if (end_src.fX < 0) {
974 end_src.fX = 0;
975 }
976
977 // undo command
978 TInsTextCom *icom = new TInsTextCom(this);
979 icom->fChar = fText->GetChar(fCurrent);
981
983
984 fExposedRegion.fX = 0;
986
987 pos.fY = fCurrent.fY + fClipText->RowCount()-1;
989
990 if (start_src.fY == end_src.fY) {
991 pos.fX = pos.fX + fCurrent.fX;
992 }
993
994 icom->SetEndPos(pos);
995
996 // calculate exposed region
999
1000 SetCurrent(pos);
1001
1002 if (ToScrYCoord(pos.fY) >= (Int_t)fCanvas->GetHeight()) {
1003 pos.fY = ToScrYCoord(pos.fY) + fVisible.fY - fCanvas->GetHeight()/2;
1006 } else {
1007 pos.fY = fVisible.fY;
1008 }
1009 if (ToScrXCoord(pos.fX, fCurrent.fY) >= (Int_t) fCanvas->GetWidth()) {
1010 pos.fX = ToScrXCoord(pos.fX, fCurrent.fY) + fVisible.fX + fCanvas->GetWidth()/2;
1011 } else if (ToScrXCoord(pos.fX, fCurrent.fY < 0) && pos.fX != 0) {
1012 if (fVisible.fX - (Int_t)fCanvas->GetWidth()/2 > 0) {
1013 pos.fX = fVisible.fX - fCanvas->GetWidth()/2;
1014 } else {
1015 pos.fX = 0;
1016 }
1017 } else {
1018 pos.fX = fVisible.fX;
1019 }
1020
1025
1026 fClient->NeedRedraw(this);
1027
1028 return kTRUE;
1029}
1030
1033
1034////////////////////////////////////////////////////////////////////////////////
1035/// Handle mouse button event in text edit widget.
1036
1038{
1039 if (event->fWindow != fCanvas->GetId()) {
1040 return kFALSE;
1041 }
1042
1043 TGLongPosition pos;
1044
1046
1047 if (event->fType == kButtonPress) {
1048 SetFocus();
1049 //Update();
1050
1051 if (event->fCode == kButton1 || event->fCode == kButton2) {
1052 pos.fY = ToObjYCoord(fVisible.fY + event->fY);
1053 if (pos.fY >= fText->RowCount()) {
1054 pos.fY = fText->RowCount()-1;
1055 }
1056 pos.fX = ToObjXCoord(fVisible.fX+event->fX, pos.fY);
1057 if (pos.fX >= fText->GetLineLength(pos.fY)) {
1058 pos.fX = fText->GetLineLength(pos.fY);
1059 }
1060 while (fText->GetChar(pos) == 16) {
1061 pos.fX++;
1062 }
1063
1064 SetCurrent(pos);
1065
1067 char *word = line->GetWord(pos.fX);
1068 Clicked((const char*)word); // emit signal
1069 delete [] word;
1070 }
1071 if (event->fCode == kButton2) {
1072 if (gVirtualX->GetPrimarySelectionOwner() != kNone) {
1073 gVirtualX->ConvertPrimarySelection(fId, fClipboard, event->fTime);
1074 Update();
1075 return kTRUE;
1076 }
1077 }
1078 if (event->fCode == kButton3) {
1079 // do not handle during guibuilding
1080 if (fClient->IsEditable() || !fEnableMenu) {
1081 return kTRUE;
1082 }
1083 SetMenuState();
1084 fMenu->PlaceMenu(event->fXRoot, event->fYRoot, kTRUE, kTRUE);
1085 }
1086 gDbl_clk = kFALSE;
1087 gTrpl_clk = kFALSE;
1088 }
1089
1090 return kTRUE;
1091}
1092
1093////////////////////////////////////////////////////////////////////////////////
1094/// Handle double click event.
1095
1097{
1098 if (event->fWindow != fCanvas->GetId()) {
1099 return kFALSE;
1100 }
1101
1102 if (event->fCode != kButton1) {
1103 return kFALSE;
1104 }
1105 if (!fText->GetCurrentLine()->GetText()) {// empty line
1106 return kFALSE;
1107 }
1108
1109 SetFocus();
1110 TGLongPosition pos;
1111 pos.fY = ToObjYCoord(fVisible.fY + event->fY);
1112
1113 if (gDbl_clk && (event->fTime - fgLastClick < 350)) { // triple click
1114 fgLastClick = event->fTime;
1115 gDbl_clk = kFALSE;
1116 gTrpl_clk = kTRUE;
1117 fMarkedStart.fY = fMarkedEnd.fY = pos.fY;
1118 fIsMarked = kTRUE;
1119 fMarkedStart.fX = 0;
1121 Marked(kTRUE);
1124 return kTRUE;
1125 }
1126
1127 if (gTrpl_clk && (event->fTime - fgLastClick < 350)) { // 4 click
1128 fgLastClick = event->fTime;
1129 gTrpl_clk = kFALSE;
1130 fIsMarked = kTRUE;
1131 fMarkedStart.fY = 0;
1132 fMarkedStart.fX = 0;
1133 fMarkedEnd.fY = fText->RowCount()-1;
1135 if (fMarkedEnd.fX < 0) {
1136 fMarkedEnd.fX = 0;
1137 }
1139 return kTRUE;
1140 }
1141
1142 gDbl_clk = kTRUE;
1143 gTrpl_clk = kFALSE;
1144
1145 if (pos.fY >= fText->RowCount()) {
1146 pos.fY = fText->RowCount() - 1;
1147 }
1148 pos.fX = ToObjXCoord(fVisible.fX + event->fX, pos.fY);
1149
1150 if (pos.fX >= fText->GetLineLength(pos.fY)) {
1151 pos.fX = fText->GetLineLength(pos.fY);
1152 }
1153 while (fText->GetChar(pos) == 16) {
1154 pos.fX++;
1155 }
1156
1157 SetCurrent(pos);
1158
1159 fMarkedStart.fY = fMarkedEnd.fY = pos.fY;
1160 char *line = fText->GetCurrentLine()->GetText();
1162 Int_t start = pos.fX;
1163 Int_t end = pos.fX;
1164 Int_t i = pos.fX;
1165
1166 if (line[i] == ' ' || line[i] == '\t') {
1167 while (start >= 0) {
1168 if (line[start] == ' ' || line[start] == '\t') --start;
1169 else break;
1170 }
1171 ++start;
1172 while (end < (Int_t)len) {
1173 if (line[end] == ' ' || line[end] == '\t') ++end;
1174 else break;
1175 }
1176 } else if (isalnum(line[i])) {
1177 while (start >= 0) {
1178 if (isalnum(line[start])) --start;
1179 else break;
1180 }
1181 ++start;
1182 while (end < (Int_t)len) {
1183 if (isalnum(line[end])) ++end;
1184 else break;
1185 }
1186 } else {
1187 while (start >= 0) {
1188 if (isalnum(line[start]) || line[start] == ' ' || line[start] == '\t') {
1189 break;
1190 } else {
1191 --start;
1192 }
1193 }
1194 ++start;
1195 while (end < (Int_t)len) {
1196 if (isalnum(line[end]) || line[end] == ' ' || line[end] == '\t') {
1197 break;
1198 } else {
1199 ++end;
1200 }
1201 }
1202 }
1203
1204 fMarkedStart.fX = start;
1205 fIsMarked = kTRUE;
1206 fMarkedEnd.fX = end;
1207 Marked(kTRUE);
1208
1209 len = end - start; //length
1210 char *word = new char[len + 1];
1211 word[len] = '\0';
1212 strncpy(word, line+start, (UInt_t)len);
1213 DoubleClicked((const char *)word); // emit signal
1214
1215 delete [] word;
1216// delete [] line;
1217
1220
1221 return kTRUE;
1222}
1223
1224////////////////////////////////////////////////////////////////////////////////
1225/// Handle mouse motion event in text edit widget.
1226
1228{
1229 TGLongPosition pos;
1230 if (event->fWindow != fCanvas->GetId()) {
1231 return kTRUE;
1232 }
1233
1234 if (fScrolling == -1) {
1235 pos.fY = ToObjYCoord(fVisible.fY+event->fY);
1236 if (pos.fY >= fText->RowCount()) {
1237 pos.fY = fText->RowCount()-1;
1238 }
1239 pos.fX = ToObjXCoord(fVisible.fX+event->fX, pos.fY);
1240 if (pos.fX > fText->GetLineLength(pos.fY)) {
1241 pos.fX = fText->GetLineLength(pos.fY);
1242 }
1243 if (fText->GetChar(pos) == 16) {
1244 if (pos.fX < fCurrent.fX) {
1245 pos.fX = fCurrent.fX;
1246 }
1247 if (pos.fX > fCurrent.fX) {
1248 do {
1249 pos.fX++;
1250 } while (fText->GetChar(pos) == 16);
1251 }
1252 }
1253 event->fY = (Int_t)ToScrYCoord(pos.fY);
1254 event->fX = (Int_t)ToScrXCoord(pos.fX, pos.fY);
1255 if (pos.fY != fCurrent.fY || pos.fX != fCurrent.fX) {
1257 SetCurrent(pos);
1258 }
1259 }
1260 return kTRUE;
1261}
1262
1263////////////////////////////////////////////////////////////////////////////////
1264/// The key press event handler converts a key press to some line editor
1265/// action.
1266
1268{
1270 char input[10];
1271 Int_t n;
1272 UInt_t keysym;
1273
1274 if (event->fType == kGKeyPress) {
1275 gVirtualX->LookupString(event, input, sizeof(input), keysym);
1276 n = strlen(input);
1277
1278 AdjustPos();
1279
1280 switch ((EKeySym)keysym) { // ignore these keys
1281 case kKey_Shift:
1282 case kKey_Control:
1283 case kKey_Meta:
1284 case kKey_Alt:
1285 case kKey_CapsLock:
1286 case kKey_NumLock:
1287 case kKey_ScrollLock:
1288 return kTRUE;
1289 default:
1290 break;
1291 }
1292 if (event->fState & kKeyControlMask) { // Cntrl key modifier pressed
1293 switch((EKeySym)keysym & ~0x20) { // treat upper and lower the same
1294 case kKey_A:
1295 SelectAll();
1296 return kTRUE;
1297 case kKey_B:
1298 mark_ok = kTRUE;
1299 PrevChar();
1300 break;
1301 case kKey_C:
1302 Copy();
1303 return kTRUE;
1304 case kKey_D:
1305 if (fIsMarked) {
1306 Cut();
1307 } else {
1309 if (fCurrent.fY == fText->RowCount()-1 && fCurrent.fX == len) {
1310 gVirtualX->Bell(0);
1311 return kTRUE;
1312 }
1313 NextChar();
1314 new TDelCharCom(this);
1315 }
1316 break;
1317 case kKey_E:
1318 mark_ok = kTRUE;
1319 End();
1320 break;
1321 case kKey_H:
1322 if (fCurrent.fX || fCurrent.fY) new TDelCharCom(this);
1323 else gVirtualX->Bell(0);
1324 break;
1325 case kKey_K:
1326 End();
1327 fIsMarked = kTRUE;
1329 Cut();
1330 break;
1331 case kKey_U:
1332 Home();
1333 UnMark();
1336 End();
1337 fIsMarked = kTRUE;
1339 Cut();
1340 break;
1341 case kKey_V:
1342 case kKey_Y:
1343 Paste();
1344 return kTRUE;
1345 case kKey_X:
1346 Cut();
1347 return kTRUE;
1348 case kKey_Z:
1349 fHistory->Notify(); // undo action
1350 return kTRUE;
1351 case kKey_F:
1352 Search(kFALSE);
1353 return kTRUE;
1354 case kKey_L:
1355 {
1356 Long_t ret = fCurrent.fY+1;
1357 new TGGotoDialog(fClient->GetDefaultRoot(), this, 400, 150, &ret);
1358 if (ret > -1) {
1359 ret--; // user specifies lines starting at 1
1360 Goto(ret);
1361 }
1362 return kTRUE;
1363 }
1364 case kKey_Home:
1365 {
1366 TGLongPosition pos;
1367 pos.fY = 0;
1368 pos.fX = 0;
1369 SetHsbPosition(0);
1370 SetVsbPosition(0);
1371 SetCurrent(pos);
1372 }
1373 break;
1374 case kKey_End:
1375 {
1376 TGLongPosition pos;
1377 pos.fY = fText->RowCount()-1;
1378 pos.fX = fText->GetLineLength(pos.fY);
1379 if (fVsb && fVsb->IsMapped())
1381 SetCurrent(pos);
1382 }
1383 break;
1384 default:
1385 return kTRUE;
1386 }
1387 }
1388 if (n && keysym >= 32 && keysym < 127 && // printable keys
1389 !(event->fState & kKeyControlMask) &&
1392
1393 if (fIsMarked) {
1394 Cut();
1395 }
1396 new TInsCharCom(this, input[0]);
1397
1398 } else {
1399
1400 switch ((EKeySym)keysym) {
1401 case kKey_F3:
1402 // typically FindAgain action
1404 kTRUE);
1405 SetMenuState();
1409 FindAgain();
1410 }
1411 break;
1412 case kKey_Delete:
1413 if (fIsMarked) {
1414 Cut();
1415 } else {
1417 if (fCurrent.fY == fText->RowCount()-1 && fCurrent.fX == len) {
1418 gVirtualX->Bell(0);
1419 return kTRUE;
1420 }
1421 NextChar();
1422 new TDelCharCom(this);
1423 }
1424 break;
1425 case kKey_Return:
1426 case kKey_Enter:
1427 new TBreakLineCom(this);
1428 break;
1429 case kKey_Tab:
1430 new TInsCharCom(this, '\t');
1431 break;
1432 case kKey_Backspace:
1433 if (fIsMarked) {
1434 Cut();
1435 } else {
1436 if (fCurrent.fX || fCurrent.fY) {
1437 new TDelCharCom(this);
1438 } else {
1439 gVirtualX->Bell(0);
1440 }
1441 }
1442 break;
1443 case kKey_Left:
1444 mark_ok = kTRUE;
1445 PrevChar();
1446 break;
1447 case kKey_Right:
1448 mark_ok = kTRUE;
1449 NextChar();
1450 break;
1451 case kKey_Up:
1452 mark_ok = kTRUE;
1453 LineUp();
1454 break;
1455 case kKey_Down:
1456 mark_ok = kTRUE;
1457 LineDown();
1458 break;
1459 case kKey_PageUp:
1460 mark_ok = kTRUE;
1461 ScreenUp();
1462 break;
1463 case kKey_PageDown:
1464 mark_ok = kTRUE;
1465 ScreenDown();
1466 break;
1467 case kKey_Home:
1468 mark_ok = kTRUE;
1469 Home();
1470 break;
1471 case kKey_End:
1472 mark_ok = kTRUE;
1473 End();
1474 break;
1475 case kKey_Insert: // switch on/off insert mode
1477 break;
1478 default:
1479 break;
1480 }
1481 }
1482 if ((event->fState & kKeyShiftMask) && mark_ok) {
1483 fIsMarked = kTRUE;
1485 Copy();
1487 kTRUE);
1488 Marked(kTRUE);
1489 } else {
1490 UnMark();
1492 fWidgetId, kFALSE);
1495 }
1496 }
1497 return kTRUE;
1498}
1499
1500////////////////////////////////////////////////////////////////////////////////
1501/// Handle mouse crossing event.
1502
1504{
1505 if (event->fWindow != fCanvas->GetId()) {
1506 return kTRUE;
1507 }
1508 if (gVirtualX->GetInputFocus() != fCanvas->GetId()) {
1509 if (event->fType == kEnterNotify) {
1510 if (!fCurBlink) {
1511 fCurBlink = new TViewTimer(this, 500);
1512 }
1513 fCurBlink->Reset();
1515 } else {
1516 if (fCurBlink) fCurBlink->Remove();
1517 if (!fEnableCursorWithoutFocus && (fCursorState == 1)) {
1518 DrawCursor(2);
1519 fCursorState = 2;
1520 } else if (fCursorState == 2) {
1521 DrawCursor(1);
1522 fCursorState = 1;
1523 }
1524 }
1525 }
1526
1528
1529 return kTRUE;
1530}
1531
1532////////////////////////////////////////////////////////////////////////////////
1533/// Handle focus change event in text edit widget.
1534
1536{
1537 if (event->fWindow != fCanvas->GetId()) {
1538 return kTRUE;
1539 }
1540
1541 // check this when porting to Win32
1542 if ((event->fCode == kNotifyNormal) && (event->fState != kNotifyPointer)) {
1543 if (event->fType == kFocusIn) {
1544 if (!fCurBlink) {
1545 fCurBlink = new TViewTimer(this, 500);
1546 }
1547 fCurBlink->Reset();
1549 } else {
1550 if (fCurBlink) fCurBlink->Remove();
1551 if (fCursorState == 2) {
1552 DrawCursor(1);
1553 fCursorState = 1;
1554 }
1555 }
1556 fClient->NeedRedraw(this);
1557 }
1558 return kTRUE;
1559}
1560
1561////////////////////////////////////////////////////////////////////////////////
1562/// Invokes search dialog.
1563
1565{
1566 static TGSearchType *srch = 0;
1567 Int_t ret = 0;
1568
1569 if (!srch) srch = new TGSearchType;
1570 srch->fClose = close;
1571
1572 if (!close) {
1575 fCanvas, 400, 150, srch, &ret);
1576 }
1577 TGSearchDialog::SearchDialog()->Connect("TextEntered(char *)", "TGTextEdit",
1578 this, "Search(char *,Bool_t,Bool_t)");
1579 TGSearchDialog::SearchDialog()->MapRaised();
1580 } else {
1581 new TGSearchDialog(fClient->GetDefaultRoot(), fCanvas, 400, 150, srch, &ret);
1582 if (ret) {
1583 Search(srch->fBuffer);
1584 }
1585 }
1586}
1587
1588////////////////////////////////////////////////////////////////////////////////
1589/// Process context menu messages.
1590
1592{
1593 TString msg2;
1595
1596 switch(GET_MSG(msg)) {
1597 case kC_COMMAND:
1598 switch(GET_SUBMSG(msg)) {
1599 case kCM_MENU:
1600 switch (parm1) {
1601 case kM_FILE_NEW:
1602 case kM_FILE_CLOSE:
1603 case kM_FILE_OPEN:
1604 if (!IsSaved()) {
1605 Int_t retval;
1607
1608 msg2.Form("Save \"%s\"?",
1609 untitled ? "Untitled" : fText->GetFileName());
1610 new TGMsgBox(fClient->GetDefaultRoot(), this, "Editor",
1611 msg2.Data(), kMBIconExclamation,
1613
1614 if (retval == kMBCancel)
1615 return kTRUE;
1616 if (retval == kMBYes)
1617 if (!SaveFile(0))
1618 return kTRUE;
1619 }
1620 Clear();
1621 if (parm1 == kM_FILE_CLOSE) {
1623 fWidgetId, 0);
1624 Closed();
1625 }
1626 if (parm1 == kM_FILE_OPEN) {
1627 TGFileInfo fi;
1628 fi.fFileTypes = gFiletypes;
1629 new TGFileDialog(fClient->GetDefaultRoot(), this, kFDOpen, &fi);
1630 if (fi.fFilename && strlen(fi.fFilename)) {
1631 LoadFile(fi.fFilename);
1633 fWidgetId, 0);
1634 Opened();
1635 }
1636 }
1637 break;
1638 case kM_FILE_SAVE:
1639 if (SaveFile(0)) {
1641 fWidgetId, 0);
1642 Saved();
1643 }
1644 break;
1645 case kM_FILE_SAVEAS:
1646 if (SaveFile(0, kTRUE)) {
1648 fWidgetId, 0);
1649 SavedAs();
1650 }
1651 break;
1652 case kM_FILE_PRINT:
1653 {
1654 Int_t ret = 0;
1655 if (!gPrinter) {
1656 gPrinter = StrDup("892_2_cor"); // use gEnv
1657 gPrintCommand = StrDup("xprint");
1658 }
1659 new TGPrintDialog(fClient->GetDefaultRoot(), this, 400, 150,
1661 if (ret)
1662 Print();
1663 }
1664 break;
1665 case kM_EDIT_CUT:
1666 Cut();
1667 break;
1668 case kM_EDIT_COPY:
1669 Copy();
1670 break;
1671 case kM_EDIT_PASTE:
1672 Paste();
1673 break;
1674 case kM_EDIT_SELECTALL:
1675 SelectAll();
1676 break;
1677 case kM_SEARCH_FIND:
1678 {
1679 Search(kFALSE);
1680 }
1681 break;
1683 if (!fSearch) {
1685 kM_SEARCH_FIND, 0);
1686 return kTRUE;
1687 }
1690 msg2.Form("Couldn't find \"%s\"", fSearch->fBuffer);
1691 new TGMsgBox(fClient->GetDefaultRoot(), this, "Editor",
1692 msg2.Data(), kMBIconExclamation, kMBOk, 0);
1693 }
1694 break;
1695 case kM_SEARCH_GOTO:
1696 {
1697 Long_t ret = fCurrent.fY+1;
1698 new TGGotoDialog(fClient->GetDefaultRoot(), this, 400, 150, &ret);
1699 if (ret > -1) {
1700 ret--; // user specifies lines starting at 1
1701 Goto(ret);
1702 }
1703 }
1704 break;
1705 default:
1706 printf("No action implemented for menu id %zd\n", (size_t)parm1);
1707 break;
1708 }
1709 default:
1710 break;
1711 }
1712 break;
1713
1714 default:
1715 break;
1716 }
1717 return kTRUE;
1718}
1719
1720////////////////////////////////////////////////////////////////////////////////
1721/// Insert a character in the text edit widget.
1722
1724{
1725 if (fReadOnly) return;
1726
1727 char *charstring = 0;
1728 TGLongPosition pos;
1729
1730 if (character == '\t') {
1731 pos.fX = fCurrent.fX;
1732 pos.fY = fCurrent.fY;
1733 fText->InsChar(pos, '\t');
1734 pos.fX++;
1735 while (pos.fX & 0x7) {
1736 pos.fX++;
1737 }
1738 fText->ReTab(pos.fY);
1740 UInt_t(ToScrYCoord(pos.fY+1) - ToScrYCoord(pos.fY)));
1742 if (ToScrXCoord(pos.fX, pos.fY) >= (Int_t)fCanvas->GetWidth()) {
1743 if (pos.fX != fText->GetLineLength(fCurrent.fY)) {
1745 } else {
1747 }
1748 }
1749 SetCurrent(pos);
1750 return;
1751 } else {
1752 if (fInsertMode == kReplace) {
1753 fCurrent.fX++;
1754 new TDelCharCom(this);
1755 }
1757 pos.fX = fCurrent.fX + 1;
1758 pos.fY = fCurrent.fY;
1759 charstring = new char[2];
1760 charstring[1] = '\0';
1761 charstring[0] = character;
1762 }
1764 if (ToScrXCoord(pos.fX, pos.fY) >= (Int_t)fCanvas->GetWidth()) {
1765 if (pos.fX != fText->GetLineLength(fCurrent.fY)) {
1767 } else {
1769 }
1770 if (!fHsb)
1771 gVirtualX->DrawString(fCanvas->GetId(), fNormGC(),
1775 } else {
1776#ifdef R__HAS_COCOA
1777 //I would use const, but some members of TGTextLine are non-const.
1780 if (lineStart < currentLine->GetLineLength()) {
1781 const char *textToRender = currentLine->GetText(lineStart, currentLine->GetLineLength() - lineStart);
1782 //The next two lines can throw and textToRender will leak, but ROOT does not care about such things. :(
1783 gVirtualX->ClearArea(fCanvas->GetId(), Int_t(ToScrXCoord(0, fCurrent.fY)),
1786 gVirtualX->DrawString(fCanvas->GetId(), fNormGC(), Int_t(ToScrXCoord(0, fCurrent.fY)),
1788 textToRender, -1);
1789 delete [] textToRender;
1790 }
1791 }
1792#else
1793 gVirtualX->CopyArea(fCanvas->GetId(), fCanvas->GetId(), fNormGC(),
1799 gVirtualX->ClearArea(fCanvas->GetId(),
1805 gVirtualX->DrawString(fCanvas->GetId(), fNormGC(),
1809 fCursorState = 2; // the ClearArea effectively turned off the cursor
1810#endif
1811 }
1812 delete [] charstring;
1813 SetCurrent(pos);
1814}
1815
1816////////////////////////////////////////////////////////////////////////////////
1817/// Delete a character from the text edit widget.
1818
1820{
1821 if (fReadOnly) {
1822 return;
1823 }
1824
1825 char *buffer;
1826 TGLongPosition pos, pos2;
1827 Long_t len;
1828
1829 pos.fY = fCurrent.fY;
1830 pos.fX = fCurrent.fX;
1831 UInt_t h = 0;
1832
1833 if (fCurrent.fX > 0) {
1834 Int_t y = (Int_t)ToScrYCoord(pos.fY);
1835 h = UInt_t(ToScrYCoord(pos.fY+2) - y);
1836 if (!y) h = h << 1;
1837
1838 pos.fX--;
1839 if (fText->GetChar(pos) == 16) {
1840 do {
1841 pos.fX++;
1842 fText->DelChar(pos);
1843 pos.fX -= 2;
1844 } while (fText->GetChar(pos) != '\t');
1845
1846 pos.fX++;
1847 fText->DelChar(pos);
1848 pos.fX--;
1849 fText->ReTab(pos.fY);
1850 UpdateRegion(0, y, fCanvas->GetWidth(), h);
1851 } else {
1852 pos.fX = fCurrent.fX;
1853 fText->DelChar(pos);
1854 pos.fX = fCurrent.fX - 1;
1855 }
1856 if (ToScrXCoord(fCurrent.fX-1, fCurrent.fY) < 0) {
1858 }
1860 UpdateRegion(0, y, fCanvas->GetWidth(), h);
1861 } else {
1862 if (fCurrent.fY > 0) {
1864 if (len > 0) {
1865 buffer = fText->GetLine(fCurrent, len);
1866 pos.fY--;
1867 pos.fX = fText->GetLineLength(fCurrent.fY-1);
1868 fText->InsText(pos, buffer);
1869 pos.fY++;
1870 delete [] buffer;
1871 } else {
1872 pos.fX = fText->GetLineLength(fCurrent.fY-1);
1873 }
1874
1875 pos2.fY = ToScrYCoord(fCurrent.fY+1);
1876 pos.fY = fCurrent.fY - 1;
1878
1879 if (ToScrXCoord(pos.fX, fCurrent.fY-1) >= (Int_t)fCanvas->GetWidth()) {
1881 }
1882
1883#ifdef R__HAS_COCOA
1885#else
1887 gVirtualX->CopyArea(fCanvas->GetId(), fCanvas->GetId(), fNormGC(), 0,
1889 if (ToScrYCoord(pos.fY) < 0) {
1891 }
1893#endif
1896 }
1897 }
1898
1899 SetCurrent(pos);
1900}
1901
1902////////////////////////////////////////////////////////////////////////////////
1903/// Break a line.
1904
1906{
1907 if (fReadOnly) return;
1908
1909 TGLongPosition pos;
1911 if (ToScrYCoord(fCurrent.fY+2) <= (Int_t)fCanvas->GetHeight()) {
1912#ifdef R__HAS_COCOA
1914#else
1915 gVirtualX->CopyArea(fCanvas->GetId(), fCanvas->GetId(), fNormGC(), 0,
1919 0, (Int_t)ToScrYCoord(fCurrent.fY+2));
1922#endif
1923 if (fVisible.fX != 0) {
1924 SetHsbPosition(0);
1925 }
1928 } else {
1934 }
1935 pos.fY = fCurrent.fY+1;
1936 pos.fX = 0;
1937 SetCurrent(pos);
1938}
1939
1940////////////////////////////////////////////////////////////////////////////////
1941/// Scroll the canvas to new_top in the kVertical or kHorizontal direction.
1942
1951
1952////////////////////////////////////////////////////////////////////////////////
1953/// Redraw the text edit widget.
1954
1963
1964////////////////////////////////////////////////////////////////////////////////
1965/// Go to the previous character.
1966
1968{
1969 if (fCurrent.fY == 0 && fCurrent.fX == 0) {
1970 gVirtualX->Bell(0);
1971 return;
1972 }
1973
1974 TGLongPosition pos;
1975 Long_t len;
1976
1977 pos.fY = fCurrent.fY;
1978 pos.fX = fCurrent.fX;
1979 if (fCurrent.fX > 0) {
1980 pos.fX--;
1981 while (fText->GetChar(pos) == 16) {
1982 pos.fX--;
1983 }
1984
1985 if (ToScrXCoord(pos.fX, pos.fY) < 0) {
1986 if (fVisible.fX-(Int_t)fCanvas->GetWidth()/2 >= 0) {
1988 } else {
1989 SetHsbPosition(0);
1990 }
1991 }
1992 } else {
1993 if (fCurrent.fY > 0) {
1994 pos.fY = fCurrent.fY - 1;
1995 len = fText->GetLineLength(pos.fY);
1996 if (ToScrYCoord(fCurrent.fY) <= 0) {
1998 }
1999 if (ToScrXCoord(len, pos.fY) >= (Int_t)fCanvas->GetWidth()) {
2002 }
2003 pos.fX = len;
2004 }
2005 }
2006 SetCurrent(pos);
2007}
2008
2009////////////////////////////////////////////////////////////////////////////////
2010/// Go to next character.
2011
2013{
2015
2016 if (fCurrent.fY == fText->RowCount()-1 && fCurrent.fX == len) {
2017 gVirtualX->Bell(0);
2018 return;
2019 }
2020
2021 TGLongPosition pos;
2022 pos.fY = fCurrent.fY;
2023 if (fCurrent.fX < len) {
2024 if (fText->GetChar(fCurrent) == '\t') {
2025 pos.fX = fCurrent.fX + 8 - (fCurrent.fX & 0x7);
2026 } else {
2027 pos.fX = fCurrent.fX + 1;
2028 }
2029
2030 if (ToScrXCoord(pos.fX, pos.fY) >= (Int_t)fCanvas->GetWidth()) {
2032 }
2033 } else {
2034 if (fCurrent.fY < fText->RowCount()-1) {
2035 pos.fY = fCurrent.fY + 1;
2036 if (ToScrYCoord(pos.fY+1) >= (Int_t)fCanvas->GetHeight()) {
2038 }
2039 SetHsbPosition(0);
2040 pos.fX = 0;
2041 }
2042 }
2043 SetCurrent(pos);
2044}
2045
2046////////////////////////////////////////////////////////////////////////////////
2047/// Make current position first line in window by scrolling up.
2048
2050{
2051 TGLongPosition pos;
2052 Long_t len;
2053 if (fCurrent.fY > 0) {
2054 pos.fY = fCurrent.fY - 1;
2055 if (ToScrYCoord(fCurrent.fY) <= 0) {
2057 }
2059 if (fCurrent.fX > len) {
2060 if (ToScrXCoord(len, pos.fY) <= 0) {
2061 if (ToScrXCoord(len, pos.fY) < 0) {
2064 } else {
2065 SetHsbPosition(0);
2066 }
2067 }
2068 pos.fX = len;
2069 } else {
2071 }
2072
2073 while (fText->GetChar(pos) == 16) {
2074 pos.fX++;
2075 }
2076 SetCurrent(pos);
2077 }
2078}
2079
2080////////////////////////////////////////////////////////////////////////////////
2081/// Move one line down.
2082
2084{
2085 TGLongPosition pos;
2086 Long_t len;
2087 if (fCurrent.fY < fText->RowCount()-1) {
2089 pos.fY = fCurrent.fY + 1;
2090 if (ToScrYCoord(pos.fY+1) > (Int_t)fCanvas->GetHeight()) {
2092 }
2093 if (fCurrent.fX > len) {
2094 if (ToScrXCoord(len, pos.fY) <= 0) {
2095 if (ToScrXCoord(len, pos.fY) < 0) {
2097 } else {
2098 SetHsbPosition(0);
2099 }
2100 }
2101 pos.fX = len;
2102 } else {
2104 }
2105
2106 while (fText->GetChar(pos) == 16) {
2107 pos.fX++;
2108 }
2109 SetCurrent(pos);
2110 }
2111}
2112
2113////////////////////////////////////////////////////////////////////////////////
2114/// Move one screen up.
2115
2117{
2118 TGLongPosition pos;
2119 pos.fX = fCurrent.fX;
2121 if (fVisible.fY - (Int_t)fCanvas->GetHeight() >= 0) { // +1
2123 } else {
2124 pos.fY = 0;
2125 SetVsbPosition(0);
2126 }
2127 while (fText->GetChar(pos) == 16) {
2128 pos.fX++;
2129 }
2130 SetCurrent(pos);
2131}
2132
2133////////////////////////////////////////////////////////////////////////////////
2134/// Move one screen down.
2135
2137{
2138 TGLongPosition pos;
2139 pos.fX = fCurrent.fX;
2141 Long_t count = fText->RowCount()-1;
2142 if ((Int_t)fCanvas->GetHeight() < ToScrYCoord(count)) {
2144 } else {
2145 pos.fY = count;
2146 }
2147 while (fText->GetChar(pos) == 16) {
2148 pos.fX++;
2149 }
2150 SetCurrent(pos);
2151}
2152
2153////////////////////////////////////////////////////////////////////////////////
2154/// Move to beginning of line.
2155
2157{
2158 TGLongPosition pos;
2159 pos.fY = fCurrent.fY;
2160 pos.fX = 0;
2161 SetHsbPosition(0);
2162 SetCurrent(pos);
2163}
2164
2165////////////////////////////////////////////////////////////////////////////////
2166/// Move to end of line.
2167
2169{
2170 TGLongPosition pos;
2171 pos.fY = fCurrent.fY;
2172 pos.fX = fText->GetLineLength(pos.fY);
2173 if (ToScrXCoord(pos.fX, pos.fY) >= (Int_t)fCanvas->GetWidth()) {
2175 }
2176 SetCurrent(pos);
2177}
2178
2179////////////////////////////////////////////////////////////////////////////////
2180/// Return selection graphics context for text cursor.
2181
2183{
2184 if (!fgCursor0GC) {
2186 fgCursor0GC->SetFunction(kGXxor);
2187 }
2188 return *fgCursor0GC;
2189}
2190
2191////////////////////////////////////////////////////////////////////////////////
2192/// Return default graphics context for text cursor.
2193
2195{
2196 if (!fgCursor1GC) {
2197 fgCursor1GC = new TGGC(GetDefaultGC());
2198 fgCursor1GC->SetFunction(kGXand);
2199 }
2200 return *fgCursor1GC;
2201}
2202
2203////////////////////////////////////////////////////////////////////////////////
2204/// Save a text edit widget as a C++ statement(s) on output stream out
2205
2206void TGTextEdit::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
2207{
2208 out << " TGTextEdit *" << GetName() << " = new TGTextEdit(" << fParent->GetName() << "," << GetWidth() << ","
2209 << GetHeight() << ");\n";
2210 if (option && strstr(option, "keep_names"))
2211 out << " " << GetName() << "->SetName(\"" << GetName() << "\");\n";
2212
2213 if (IsReadOnly())
2214 out << " " << GetName() << "->SetReadOnly(kTRUE);\n";
2215
2216 if (!IsMenuEnabled())
2217 out << " " << GetName() << "->EnableMenu(kFALSE);\n";
2218
2220 out << " " << GetName() << "->ChangeBackground(" << fCanvas->GetBackground() << ");\n";
2221
2222 TGText *txt = GetText();
2223 Bool_t fromfile = strlen(txt->GetFileName()) ? kTRUE : kFALSE;
2224 TString fn;
2225
2226 if (fromfile) {
2227 const char *filename = txt->GetFileName();
2230 } else {
2231 fn = TString::Format("Txt%s", GetName() + 5);
2232 txt->Save(fn.Data());
2233 }
2234 out << " " << GetName() << "->LoadFile(\"" << fn.ReplaceSpecialCppChars() << "\");\n";
2235}
Handle_t Atom_t
WM token.
Definition GuiTypes.h:37
@ kGKeyPress
Definition GuiTypes.h:60
@ kButtonPress
Definition GuiTypes.h:60
@ kFocusIn
Definition GuiTypes.h:61
@ kEnterNotify
Definition GuiTypes.h:61
@ kNotifyNormal
Definition GuiTypes.h:219
@ kNotifyPointer
Definition GuiTypes.h:220
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
@ kGXxor
src XOR dst
Definition GuiTypes.h:74
@ kGXand
src AND dst
Definition GuiTypes.h:69
const Mask_t kKeyShiftMask
Definition GuiTypes.h:195
const Handle_t kNone
Definition GuiTypes.h:88
const Mask_t kKeyControlMask
Definition GuiTypes.h:197
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
@ kButton2
Definition GuiTypes.h:214
@ kButton3
Definition GuiTypes.h:214
@ kButton1
Definition GuiTypes.h:214
EKeySym
Definition KeySymbols.h:25
@ kKey_Right
Definition KeySymbols.h:42
@ kKey_Down
Definition KeySymbols.h:43
@ kKey_Meta
Definition KeySymbols.h:51
@ kKey_Y
Definition KeySymbols.h:150
@ kKey_B
Definition KeySymbols.h:127
@ kKey_PageDown
Definition KeySymbols.h:47
@ kKey_F
Definition KeySymbols.h:131
@ kKey_L
Definition KeySymbols.h:137
@ kKey_CapsLock
Definition KeySymbols.h:53
@ kKey_Up
Definition KeySymbols.h:41
@ kKey_Return
Definition KeySymbols.h:30
@ kKey_Alt
Definition KeySymbols.h:52
@ kKey_C
Definition KeySymbols.h:128
@ kKey_ScrollLock
Definition KeySymbols.h:55
@ kKey_Delete
Definition KeySymbols.h:33
@ kKey_A
Definition KeySymbols.h:126
@ kKey_F3
Definition KeySymbols.h:59
@ kKey_Left
Definition KeySymbols.h:40
@ kKey_Shift
Definition KeySymbols.h:49
@ kKey_E
Definition KeySymbols.h:130
@ kKey_Backspace
Definition KeySymbols.h:29
@ kKey_Z
Definition KeySymbols.h:151
@ kKey_D
Definition KeySymbols.h:129
@ kKey_X
Definition KeySymbols.h:149
@ kKey_Home
Definition KeySymbols.h:38
@ kKey_U
Definition KeySymbols.h:146
@ kKey_Insert
Definition KeySymbols.h:32
@ kKey_Enter
Definition KeySymbols.h:31
@ kKey_Control
Definition KeySymbols.h:50
@ kKey_Tab
Definition KeySymbols.h:27
@ kKey_H
Definition KeySymbols.h:133
@ kKey_End
Definition KeySymbols.h:39
@ kKey_NumLock
Definition KeySymbols.h:54
@ kKey_PageUp
Definition KeySymbols.h:45
@ kKey_K
Definition KeySymbols.h:136
@ kKey_V
Definition KeySymbols.h:147
#define h(i)
Definition RSha256.hxx:106
bool Bool_t
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:77
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
long Longptr_t
Integer large enough to hold a pointer (platform-dependent)
Definition RtypesCore.h:89
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
Definition RtypesCore.h:69
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
Definition RtypesCore.h:68
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
Definition RtypesCore.h:60
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
@ kFDOpen
@ kFDSave
@ kMBNo
Definition TGMsgBox.h:32
@ kMBYes
Definition TGMsgBox.h:31
@ kMBCancel
Definition TGMsgBox.h:37
@ kMBOk
Definition TGMsgBox.h:33
@ kMBIconExclamation
Definition TGMsgBox.h:24
@ kMBIconAsterisk
Definition TGMsgBox.h:25
static Bool_t gDbl_clk
static Bool_t gTrpl_clk
static const char * gFiletypes[]
static char * gPrinter
static char * gPrintCommand
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void input
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t cursor
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t del
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t nchar
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
Option_t Option_t TPoint TPoint const char text
R__EXTERN void * gTQSender
Definition TQObject.h:46
char * StrDup(const char *str)
Duplicate the string str.
Definition TString.cxx:2563
R__EXTERN TSystem * gSystem
Definition TSystem.h:572
#define gVirtualX
Definition TVirtualX.h:337
Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg)
Int_t GET_MSG(Long_t val)
@ kC_TEXTVIEW
@ kTXT_OPEN
@ kCM_MENU
@ kTXT_SAVE
@ kTXT_CLOSE
@ kTXT_ISMARKED
@ kTXT_DATACHANGE
@ kC_COMMAND
@ kTXT_F3
Int_t GET_SUBMSG(Long_t val)
Bool_t Notify() override
This method must be overridden to handle object notification (the base implementation is no-op).
TBreakLineCom(TGTextEdit *te)
Bool_t Notify() override
This method must be overridden to handle object notification (the base implementation is no-op).
TDelCharCom(TGTextEdit *te)
void SetEndPos(TGLongPosition end)
Bool_t fBreakLine
TGLongPosition fEndPos
~TDelTextCom() override
TGText * fText
TDelTextCom(TGTextEdit *te, TGText *txt)
void SetBreakLine(Bool_t on)
TDelTextCom & operator=(const TDelTextCom &dtc)
Bool_t Notify() override
This method must be overridden to handle object notification (the base implementation is no-op).
TDelTextCom(const TDelTextCom &dtc)
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
Definition TGClient.cxx:233
Bool_t IsEditable() const
Definition TGClient.h:89
const TGResourcePool * GetResourcePool() const
Definition TGClient.h:124
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition TGClient.cxx:380
This class creates a file selection dialog.
virtual Bool_t ProcessMessage(Longptr_t, Longptr_t, Longptr_t)
Definition TGFrame.h:185
static Time_t fgLastClick
Definition TGFrame.h:110
virtual void SendMessage(const TGWindow *w, Longptr_t msg, Longptr_t parm1, Longptr_t parm2)
Send message (i.e.
Definition TGFrame.cxx:637
UInt_t fWidth
frame width
Definition TGFrame.h:87
UInt_t GetHeight() const
Definition TGFrame.h:227
virtual Pixel_t GetBackground() const
Definition TGFrame.h:194
static Pixel_t fgWhitePixel
Definition TGFrame.h:103
UInt_t GetWidth() const
Definition TGFrame.h:226
Encapsulate a graphics context used in the low level graphics.
Definition TGGC.h:22
Long_t fX
x position
Definition TGDimension.h:56
Long_t fY
y position
Definition TGDimension.h:57
TGClient * fClient
Connection to display server.
Definition TGObject.h:25
Handle_t GetId() const
Definition TGObject.h:41
Handle_t fId
X11/Win32 Window identifier.
Definition TGObject.h:24
This class creates a popup menu object.
Definition TGMenu.h:110
virtual void DisableEntry(Int_t id)
Disable entry (disabled entries appear in a sunken relieve).
Definition TGMenu.cxx:1720
virtual void EnableEntry(Int_t id)
Enable entry. By default entries are enabled.
Definition TGMenu.cxx:1701
virtual void Associate(const TGWindow *w)
Definition TGMenu.h:206
virtual void AddSeparator(TGMenuEntry *before=nullptr)
Add a menu separator to the menu.
Definition TGMenu.cxx:1056
virtual void AddEntry(TGHotString *s, Int_t id, void *ud=nullptr, const TGPicture *p=nullptr, TGMenuEntry *before=nullptr)
Add a menu entry.
Definition TGMenu.cxx:986
virtual void PlaceMenu(Int_t x, Int_t y, Bool_t stick_mode, Bool_t grab_pointer)
Popup a popup menu.
Definition TGMenu.cxx:1237
virtual Bool_t IsEntryEnabled(Int_t id)
Return true if menu entry is enabled.
Definition TGMenu.cxx:1732
UInt_t fH
height
Definition TGDimension.h:94
UInt_t fW
width
Definition TGDimension.h:93
Int_t fX
x position
Definition TGDimension.h:91
Int_t fY
y position
Definition TGDimension.h:92
static TGSearchDialog *& SearchDialog()
Return global search dialog.
void SetPos(TGLongPosition pos)
TGLongPosition fPos
TGTextEdit * fEdit
TGTextEditCommand(TGTextEdit *te)
Bool_t Notify() override
'Notify' all objects in this collection.
~TGTextEditHist() override
A TGTextEdit is a specialization of TGTextView.
Definition TGTextEdit.h:22
TGLongPosition fCurrent
current cursor position
Definition TGTextEdit.h:43
TGTextEditHist * fHistory
undo manager
Definition TGTextEdit.h:46
@ kM_SEARCH_FINDAGAIN
Definition TGTextEdit.h:33
@ kM_EDIT_SELECTALL
Definition TGTextEdit.h:32
GContext_t fCursor1GC
graphics context for drawing cursor
Definition TGTextEdit.h:38
virtual void Closed()
Definition TGTextEdit.h:126
TGTextEdit(const TGTextEdit &)=delete
virtual Bool_t Goto(Long_t line, Long_t column=0)
Goto the specified line.
static TGGC * fgCursor0GC
Definition TGTextEdit.h:50
static const TGGC & GetCursor1GC()
Return default graphics context for text cursor.
virtual void Saved()
Definition TGTextEdit.h:128
virtual Bool_t Replace(TGLongPosition pos, const char *oldText, const char *newText, Bool_t direction, Bool_t caseSensitive)
Replace text starting at textPos.
virtual void DrawCursor(Int_t mode)
Draw cursor. If mode = 1 draw cursor, if mode = 2 erase cursor.
Bool_t HandleMotion(Event_t *event) override
Handle mouse motion event in text edit widget.
TList * GetHistory() const
Definition TGTextEdit.h:103
virtual void AdjustPos()
Adjust current position.
virtual Bool_t SaveFile(const char *fname, Bool_t saveas=kFALSE)
Save file.
Bool_t HandleDoubleClick(Event_t *event) override
Handle double click event.
EInsertMode GetInsertMode() const
Definition TGTextEdit.h:99
void Delete(Option_t *="") override
Delete selection.
void ScrollCanvas(Int_t newTop, Int_t direction) override
Scroll the canvas to new_top in the kVertical or kHorizontal direction.
void SavePrimitive(std::ostream &out, Option_t *="") override
Save a text edit widget as a C++ statement(s) on output stream out.
virtual void SetMenuState()
Enable/disable menu items in function of what is possible.
virtual Bool_t Cut()
Cut text.
Bool_t fEnableMenu
enable context menu with editor actions
Definition TGTextEdit.h:45
TGLongPosition GetCurrentPos() const
Definition TGTextEdit.h:112
void Clear(Option_t *="") override
Clear text edit widget.
virtual void DelChar()
Delete a character from the text edit widget.
Bool_t HandleFocusChange(Event_t *event) override
Handle focus change event in text edit widget.
GContext_t fCursor0GC
graphics context for erasing cursor
Definition TGTextEdit.h:37
virtual void SavedAs()
Definition TGTextEdit.h:129
virtual void LineDown()
Move one line down.
virtual void ScreenDown()
Move one screen down.
Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override
Process context menu messages.
Bool_t Copy() override
Copy text.
virtual void LineUp()
Make current position first line in window by scrolling up.
EInsertMode fInsertMode
OPTION={GetMethod="GetInsertMode";SetMethod="SetInsertMode";Items=(kInsert="&Insert",...
Definition TGTextEdit.h:44
virtual void CursorOn()
Turn cursor on.
virtual void SetCurrent(TGLongPosition new_coord)
Make the specified position the current position.
virtual void NextChar()
Go to next character.
virtual void ScreenUp()
Move one screen up.
virtual void BreakLine()
Break a line.
void Print(Option_t *="") const override
Send current buffer to printer.
virtual void FindAgain()
Definition TGTextEdit.h:125
virtual void InsChar(char character)
Insert a character in the text edit widget.
virtual void SetInsertMode(EInsertMode mode=kInsert)
Sets the mode how characters are entered.
virtual void CursorOff()
If cursor if on, turn it off.
Int_t fCursorState
cursor state (1=drawn, 2=erased)
Definition TGTextEdit.h:39
TGSearchType * fSearch
structure used by search dialog
Definition TGTextEdit.h:42
virtual void Opened()
Definition TGTextEdit.h:127
Bool_t Search(const char *string, Bool_t direction=kTRUE, Bool_t caseSensitive=kFALSE) override
Search for string in the specified direction.
virtual void PrevChar()
Go to the previous character.
virtual Bool_t Paste()
Paste text into widget.
virtual Bool_t IsMenuEnabled() const
Definition TGTextEdit.h:102
Bool_t HandleKey(Event_t *event) override
The key press event handler converts a key press to some line editor action.
virtual void SetFocus()
Definition TGTextEdit.h:109
void DrawRegion(Int_t x, Int_t y, UInt_t width, UInt_t height) override
Redraw the text edit widget.
TGPopupMenu * fMenu
popup menu with editor actions
Definition TGTextEdit.h:41
~TGTextEdit() override
Cleanup text edit widget.
Bool_t HandleSelection(Event_t *event) override
Handle selection notify event.
Bool_t HandleButton(Event_t *event) override
Handle mouse button event in text edit widget.
Bool_t HandleTimer(TTimer *t) override
Handle timer cursor blink timer.
Long_t ReturnLongestLineWidth() override
Return width of longest line in widget.
Bool_t fEnableCursorWithoutFocus
enable cursor visibility when focus went out from text editor window (default is kTRUE)
Definition TGTextEdit.h:47
virtual void Home()
Move to beginning of line.
Bool_t HandleCrossing(Event_t *event) override
Handle mouse crossing event.
static TGGC * fgCursor1GC
Definition TGTextEdit.h:51
TViewTimer * fCurBlink
cursor blink timer
Definition TGTextEdit.h:40
virtual void End()
Move to end of line.
void Init()
Initialize a text edit widget.
static const TGGC & GetCursor0GC()
Return selection graphics context for text cursor.
ULong_t GetLineLength()
Definition TGText.h:41
char * GetText(ULong_t pos, ULong_t length)
Get length characters from line starting at pos.
Definition TGText.cxx:183
A TGTextView is a text viewer widget.
Definition TGTextView.h:22
Int_t fMaxDescent
maximum descent in font
Definition TGTextView.h:29
virtual void Update()
update the whole window of text view
TGGC fNormGC
graphics context for drawing text
Definition TGTextView.h:31
Bool_t fReadOnly
text cannot be edited
Definition TGTextView.h:39
TGText * fText
text buffer
Definition TGTextView.h:25
virtual void UnMark()
Clear marked region.
virtual Bool_t IsSaved()
Definition TGTextView.h:77
virtual Long_t ToObjXCoord(Long_t xCoord, Long_t line)
Convert x screen coordinate to column in specified line.
virtual void SetHsbPosition(Long_t newPos)
Set position of horizontal scrollbar.
virtual Bool_t LoadFile(const char *fname, long startpos=0, long length=-1)
Load a file in the text view widget.
virtual void Mark(Long_t xPos, Long_t yPos)
Mark a text region from xPos to yPos.
void DrawRegion(Int_t x, Int_t y, UInt_t w, UInt_t h) override
Draw lines in exposed region.
virtual Long_t ToScrYCoord(Long_t yCoord)
Convert line number to screen coordinate.
virtual Long_t ReturnLongestLineWidth()
Return width of longest line.
Bool_t HandleCrossing(Event_t *event) override
Handle mouse crossing event.
TGText * fClipText
clipboard text buffer
Definition TGTextView.h:26
static const TGGC & GetDefaultSelectedGC()
Return selection graphics context in use.
static const TGGC & GetDefaultGC()
Return default graphics context in use.
Bool_t HandleTimer(TTimer *t) override
Handle scroll timer.
Bool_t fIsMarked
true if text is marked/selected
Definition TGTextView.h:36
Bool_t HandleMotion(Event_t *event) override
Handle mouse motion event in the text editor widget.
virtual void Clicked(const char *word)
Definition TGTextView.h:138
TGGC fSelbackGC
graphics context for drawing marked background
Definition TGTextView.h:33
TGGC fSelGC
graphics context for drawing marked text
Definition TGTextView.h:32
virtual Bool_t SelectAll()
Select all text in the viewer.
TGText * GetText() const
Definition TGTextView.h:115
virtual void SetVsbPosition(Long_t newPos)
Set position of vertical scrollbar.
TGLongPosition fMarkedEnd
end position of marked text
Definition TGTextView.h:41
virtual Long_t ToScrXCoord(Long_t xCoord, Long_t line)
Convert column number in specified line to screen coordinate.
virtual void Marked(Bool_t mark)
Definition TGTextView.h:137
virtual void DataChanged()
Definition TGTextView.h:135
Bool_t IsReadOnly() const
Definition TGTextView.h:118
virtual Bool_t Copy()
Copy selected text to clipboard.
virtual void DoubleClicked(const char *word)
Definition TGTextView.h:139
Bool_t HandleButton(Event_t *event) override
Handle mouse button event in text editor.
virtual void SetSBRange(Int_t direction)
Set the range for the kVertical or kHorizontal scrollbar.
TGLongPosition fMarkedStart
start position of marked text
Definition TGTextView.h:40
virtual Long_t ToObjYCoord(Long_t yCoord)
Convert y screen coordinate to line number.
void Clear(Option_t *="") override
Clear text view widget.
A TGText is a multi line text buffer.
Definition TGText.h:57
Bool_t InsChar(TGLongPosition pos, char c)
Insert character c at the specified position pos.
Definition TGText.cxx:705
void ReTab(Long_t row)
Redo all tabs in a line. Needed after a new tab is inserted.
Definition TGText.cxx:1085
Long_t RowCount() const
Definition TGText.h:106
Bool_t DelText(TGLongPosition start, TGLongPosition end)
Delete text between start and end positions.
Definition TGText.cxx:734
Bool_t Search(TGLongPosition *foundPos, TGLongPosition start, const char *searchString, Bool_t direction, Bool_t caseSensitive)
Search for string searchString starting at the specified position going in forward (direction = true)...
Definition TGText.cxx:1141
Bool_t DelLine(ULong_t pos)
Delete specified row. Returns false if row does not exist.
Definition TGText.cxx:962
Bool_t Save(const char *fn)
Save text buffer to file fn.
Definition TGText.cxx:608
Bool_t Replace(TGLongPosition start, const char *oldText, const char *newText, Bool_t direction, Bool_t caseSensitive)
Replace oldText by newText. Returns false if nothing replaced.
Definition TGText.cxx:1195
Bool_t DelChar(TGLongPosition pos)
Delete character at specified position pos.
Definition TGText.cxx:689
Bool_t BreakLine(TGLongPosition pos)
Break line at position pos. Returns false if pos is not valid.
Definition TGText.cxx:1006
Bool_t InsText(TGLongPosition pos, const char *buf)
Insert single line at specified position.
Definition TGText.cxx:886
char * GetLine(TGLongPosition pos, ULong_t length)
Return string at position pos.
Definition TGText.cxx:995
char GetChar(TGLongPosition pos)
Get character a position pos. If character not valid return -1.
Definition TGText.cxx:721
Bool_t LoadBuffer(const char *txtbuf)
Load a 0 terminated buffer. Lines will be split at ' '.
Definition TGText.cxx:511
void Clear()
Clear text buffer.
Definition TGText.cxx:404
TGTextLine * GetCurrentLine() const
Definition TGText.h:102
const char * GetFileName() const
Definition TGText.h:88
Long_t GetLineLength(Long_t row)
Get length of specified line. Returns -1 if row does not exist.
Definition TGText.cxx:1041
TString AsString()
Returns content as ROOT string.
Definition TGText.cxx:1236
Atom_t fClipboard
clipboard property
Definition TGView.h:39
TGHScrollBar * fHsb
horizontal scrollbar
Definition TGView.h:43
TGVScrollBar * fVsb
vertical scrollbar
Definition TGView.h:44
TGLongPosition fVisible
position of visible region
Definition TGView.h:32
@ kHorizontal
Definition TGView.h:29
@ kVertical
Definition TGView.h:29
Int_t fScrolling
scrolling direction
Definition TGView.h:38
TGLongPosition fScrollVal
scroll value
Definition TGView.h:34
TGViewFrame * fCanvas
frame containing the text
Definition TGView.h:42
virtual void UpdateRegion(Int_t x, Int_t y, UInt_t w, UInt_t h)
update a part of view
Definition TGView.cxx:202
virtual void ScrollCanvas(Int_t newTop, Int_t direction)
Scroll the canvas to new_top in the kVertical or kHorizontal direction.
Definition TGView.cxx:462
TGRectangle fExposedRegion
exposed area
Definition TGView.h:36
Int_t fWidgetId
the widget id (used for event processing)
Definition TGWidget.h:46
const TGWindow * fMsgWindow
window which handles widget events
Definition TGWidget.h:48
ROOT GUI Window base class.
Definition TGWindow.h:23
const TGWindow * fParent
Parent window.
Definition TGWindow.h:28
virtual Bool_t IsMapped()
Returns kTRUE if window is mapped on screen, kFALSE otherwise.
Definition TGWindow.cxx:293
const char * GetName() const override
Return unique name, used in SavePrimitive methods.
Definition TGWindow.cxx:334
TInsCharCom(TGTextEdit *te, char ch)
Bool_t Notify() override
This method must be overridden to handle object notification (the base implementation is no-op).
Bool_t Notify() override
This method must be overridden to handle object notification (the base implementation is no-op).
void SetEndPos(TGLongPosition end)
TInsTextCom(TGTextEdit *te)
TGLongPosition fEndPos
A doubly linked list.
Definition TList.h:38
void Add(TObject *obj) override
Definition TList.h:81
TObject * Last() const override
Return the last object in the list. Returns 0 when list is empty.
Definition TList.cxx:690
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
Definition TList.cxx:467
void RemoveLast() override
Remove the last object of the list.
Definition TList.cxx:906
Mother of all ROOT objects.
Definition TObject.h:41
virtual Bool_t Notify()
This method must be overridden to handle object notification (the base implementation is no-op).
Definition TObject.cxx:612
Bool_t Disconnect(const char *signal=nullptr, void *receiver=nullptr, const char *slot=nullptr)
Disconnects signal of this object from slot of receiver.
Basic string class.
Definition TString.h:138
Ssiz_t Length() const
Definition TString.h:425
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2384
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition TSystem.cxx:1285
virtual FILE * OpenPipe(const char *command, const char *mode)
Open a pipe.
Definition TSystem.cxx:660
virtual const char * UnixPathName(const char *unixpathname)
Convert from a local pathname to a Unix pathname.
Definition TSystem.cxx:1073
virtual void AddTimer(TTimer *t)
Add timer to list of system timers.
Definition TSystem.cxx:469
virtual int ClosePipe(FILE *pipe)
Close the pipe.
Definition TSystem.cxx:669
Handles synchronous and a-synchronous timer events.
Definition TTimer.h:51
void Reset()
Reset the timer.
Definition TTimer.cxx:162
void Remove() override
Definition TTimer.h:86
TLine * line
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
Event structure.
Definition GuiTypes.h:174
EGEventType fType
of event (see EGEventType)
Definition GuiTypes.h:175
Int_t fY
pointer x, y coordinates in event window
Definition GuiTypes.h:178
Int_t fXRoot
Definition GuiTypes.h:179
Window_t fWindow
window reported event is relative to
Definition GuiTypes.h:176
UInt_t fState
key or button mask
Definition GuiTypes.h:181
Int_t fYRoot
coordinates relative to root
Definition GuiTypes.h:179
Int_t fX
Definition GuiTypes.h:178
Time_t fTime
time event event occurred in ms
Definition GuiTypes.h:177
UInt_t fCode
key or button code
Definition GuiTypes.h:180
Longptr_t fUser[5]
5 longs can be used by client message events NOTE: only [0], [1] and [2] may be used.
Definition GuiTypes.h:187