44#include "RConfigure.h"
50 "Text files",
"*.txt",
214 start_src.
fX = start_src.
fY = 0;
392 if (untitled || saveas) {
492 if (len < 0) len = 0;
494 buf2 =
new char[len + 2];
495 strncpy(buf2, buf1, (
UInt_t)len);
498 while (buf2[i] !=
'\0') {
499 if (buf2[i] ==
'\t') {
501 while (buf2[j] == 16)
504 strcpy(buf2+i+1, buf2+j);
508 fwrite(buf2,
sizeof(
char), strlen(buf2)+1, p);
517 msg.
Form(
"Printed: %s\nLines: %ld\nUsing: %s -P%s",
557 if (endPos.
fX == -1) {
601 th = th < 0 ? 0 : th;
602 ys = ys < 0 ? 0 : ys;
652 msg.
Form(
"Couldn't find \"%s\"",
string);
697 const char *newText,
Bool_t direction,
Bool_t caseSensitive)
700 if (!
fText->
Replace(textPos, oldText, newText, direction, caseSensitive)) {
839 if (count == -1 || count ==
'\t') {
954 if (!nchar)
return kTRUE;
964 start_src.
fY = start_src.
fX = 0;
968 if (end_src.
fX < 0) {
985 if (start_src.
fY == end_src.
fY) {
1062 char *word =
line->GetWord(pos.
fX);
1161 if (
line[i] ==
' ' ||
line[i] ==
'\t') {
1162 while (start >= 0) {
1163 if (
line[start] ==
' ' ||
line[start] ==
'\t') --start;
1167 while (end < (
Int_t)len) {
1168 if (
line[end] ==
' ' ||
line[end] ==
'\t') ++end;
1171 }
else if (isalnum(
line[i])) {
1172 while (start >= 0) {
1173 if (isalnum(
line[start])) --start;
1177 while (end < (
Int_t)len) {
1178 if (isalnum(
line[end])) ++end;
1182 while (start >= 0) {
1183 if (isalnum(
line[start]) ||
line[start] ==
' ' ||
line[start] ==
'\t') {
1190 while (end < (
Int_t)len) {
1191 if (isalnum(
line[end]) ||
line[end] ==
' ' ||
line[end] ==
'\t') {
1205 char *word =
new char[len + 1];
1288 switch((
EKeySym)keysym & ~0x20) {
1383 if (
n && keysym >= 32 && keysym < 127 &&
1570 fCanvas, 400, 150, srch, &ret);
1573 this,
"Search(char *,Bool_t,Bool_t)");
1603 msg2.
Form(
"Save \"%s\"?",
1701 printf(
"No action implemented for menu id %zd\n", (
size_t)parm1);
1722 char *charstring = 0;
1725 if (character ==
'\t') {
1730 while (pos.
fX & 0x7) {
1754 charstring =
new char[2];
1755 charstring[1] =
'\0';
1756 charstring[0] = character;
1769 charstring, strlen(charstring));
1775 if (lineStart < currentLine->GetLineLength()) {
1776 const char *textToRender = currentLine->GetText(lineStart, currentLine->GetLineLength() - lineStart);
1784 delete [] textToRender;
1803 charstring, strlen(charstring));
1807 delete [] charstring;
2204 out <<
" TGTextEdit *";
2207 <<
");"<< std::endl;
2208 if (option && strstr(option,
"keep_names"))
2209 out <<
" " <<
GetName() <<
"->SetName(\"" <<
GetName() <<
"\");" << std::endl;
2212 out <<
" " <<
GetName() <<
"->SetReadOnly(kTRUE);" << std::endl;
2216 out <<
" " <<
GetName() <<
"->EnableMenu(kFALSE);" << std::endl;
2235 out <<
" " <<
GetName() <<
"->LoadFile(" << quote << fn.
Data() << quote <<
");" << std::endl;
const Mask_t kKeyShiftMask
const Mask_t kKeyControlMask
Handle_t Window_t
Window handle.
include TDocParser_001 C image html pict1_TDocParser_001 png width
static const char * gFiletypes[]
static char * gPrintCommand
R__EXTERN void * gTQSender
char * StrDup(const char *str)
Duplicate the string str.
R__EXTERN TSystem * gSystem
Bool_t Notify()
This method must be overridden to handle object notification.
TBreakLineCom(TGTextEdit *te)
TDelCharCom(TGTextEdit *te)
Bool_t Notify()
This method must be overridden to handle object notification.
void SetEndPos(TGLongPosition end)
TDelTextCom(TGTextEdit *te, TGText *txt)
void SetBreakLine(Bool_t on)
TDelTextCom & operator=(const TDelTextCom &dtc)
TDelTextCom(const TDelTextCom &dtc)
Bool_t Notify()
This method must be overridden to handle object notification.
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
Bool_t IsEditable() const
const TGResourcePool * GetResourcePool() const
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
This class creates a file selection dialog.
char * fFilename
selected file name
const char ** fFileTypes
file types used to filter selectable files
char * fIniDir
on input: initial directory, on output: new directory
Bool_t fOverwrite
if true overwrite the file with existing name on save
void SetIniDir(const char *inidir)
Set directory name.
virtual void MapRaised()
map raised
virtual Bool_t ProcessMessage(Longptr_t, Longptr_t, Longptr_t)
static Time_t fgLastClick
virtual void SendMessage(const TGWindow *w, Longptr_t msg, Longptr_t parm1, Longptr_t parm2)
Send message (i.e.
virtual Pixel_t GetBackground() const
static Pixel_t fgWhitePixel
Encapsulate a graphics context used in the low level graphics.
void SetFunction(EGraphicsFunction v)
Set graphics context drawing function.
TGClient * fClient
Connection to display server.
Handle_t fId
X11/Win32 Window identifier.
Cursor_t GetTextCursor() const
virtual TGSearchType * GetType() const
static TGSearchDialog *& SearchDialog()
Return global search dialog.
void SetPos(TGLongPosition pos)
TGTextEditCommand(TGTextEdit *te)
Bool_t Notify()
'Notify' all objects in this collection.
virtual ~TGTextEditHist()
A TGTextEdit is a specialization of TGTextView.
TGLongPosition fCurrent
current cursor position
TGTextEditHist * fHistory
undo manager
GContext_t fCursor1GC
graphics context for drawing cursor
virtual Bool_t HandleFocusChange(Event_t *event)
Handle focus change event in text edit widget.
TGTextEdit(const TGTextEdit &)=delete
virtual Bool_t Goto(Long_t line, Long_t column=0)
Goto the specified line.
virtual Bool_t HandleDoubleClick(Event_t *event)
Handle double click event.
static TGGC * fgCursor0GC
static const TGGC & GetCursor1GC()
Return default graphics context for text cursor.
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.
virtual Bool_t Copy()
Copy text.
TList * GetHistory() const
virtual void AdjustPos()
Adjust current position.
virtual Bool_t SaveFile(const char *fname, Bool_t saveas=kFALSE)
Save file.
EInsertMode GetInsertMode() const
virtual void DrawRegion(Int_t x, Int_t y, UInt_t width, UInt_t height)
Redraw the text edit widget.
virtual Bool_t HandleCrossing(Event_t *event)
Handle mouse crossing event.
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
TGLongPosition GetCurrentPos() const
virtual Long_t ReturnLongestLineWidth()
Return width of longest line in widget.
virtual void Print(Option_t *="") const
Send current buffer to printer.
virtual void DelChar()
Delete a character from the text edit widget.
virtual Bool_t HandleSelection(Event_t *event)
Handle selection notify event.
GContext_t fCursor0GC
graphics context for erasing cursor
virtual Bool_t HandleKey(Event_t *event)
The key press event handler converts a key press to some line editor action.
virtual void LineDown()
Move one line down.
virtual void Clear(Option_t *="")
Clear text edit widget.
virtual void ScreenDown()
Move one screen down.
virtual void Delete(Option_t *="")
Delete selection.
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save a text edit widget as a C++ statement(s) on output stream out.
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion event in text edit widget.
virtual void LineUp()
Make current position first line in window by scrolling up.
EInsertMode fInsertMode
OPTION={GetMethod="GetInsertMode";SetMethod="SetInsertMode";Items=(kInsert="&Insert",...
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.
virtual ~TGTextEdit()
Cleanup text edit widget.
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.
virtual Bool_t Search(const char *string, Bool_t direction=kTRUE, Bool_t caseSensitive=kFALSE)
Search for string in the specified direction.
Int_t fCursorState
cursor state (1=drawn, 2=erased)
TGSearchType * fSearch
structure used by search dialog
virtual void PrevChar()
Go to the previous character.
virtual Bool_t Paste()
Paste text into widget.
virtual Bool_t IsMenuEnabled() const
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in text edit widget.
TGPopupMenu * fMenu
popup menu with editor actions
virtual void ScrollCanvas(Int_t newTop, Int_t direction)
Scroll the canvas to new_top in the kVertical or kHorizontal direction.
Bool_t fEnableCursorWithoutFocus
enable cursor visibility when focus went out from text editor window (default is kTRUE)
virtual void Home()
Move to beginning of line.
virtual Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2)
Process context menu messages.
static TGGC * fgCursor1GC
TViewTimer * fCurBlink
cursor blink timer
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.
virtual Bool_t HandleTimer(TTimer *t)
Handle timer cursor blink timer.
char * GetText(ULong_t pos, ULong_t length)
Get length characters from line starting at pos.
A TGTextView is a text viewer widget.
Int_t fMaxDescent
maximum descent in font
virtual void Update()
update the whole window of text view
TGGC fNormGC
graphics context for drawing text
Bool_t fReadOnly
text cannot be edited
TGText * fText
text buffer
virtual void UnMark()
Clear marked region.
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.
virtual Long_t ToScrYCoord(Long_t yCoord)
Convert line number to screen coordinate.
virtual Long_t ReturnLongestLineWidth()
Return width of longest line.
TGText * fClipText
clipboard text buffer
static const TGGC & GetDefaultSelectedGC()
Return selection graphics context in use.
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion event in the text editor widget.
static const TGGC & GetDefaultGC()
Return default graphics context in use.
Bool_t fIsMarked
true if text is marked/selected
virtual Bool_t HandleCrossing(Event_t *event)
Handle mouse crossing event.
virtual void Clicked(const char *word)
TGGC fSelbackGC
graphics context for drawing marked background
TGGC fSelGC
graphics context for drawing marked text
virtual Bool_t SelectAll()
Select all text in the viewer.
virtual void SetVsbPosition(Long_t newPos)
Set position of vertical scrollbar.
TGLongPosition fMarkedEnd
end position of marked text
virtual void DrawRegion(Int_t x, Int_t y, UInt_t w, UInt_t h)
Draw lines in exposed region.
virtual Long_t ToScrXCoord(Long_t xCoord, Long_t line)
Convert column number in specified line to screen coordinate.
virtual void Clear(Option_t *="")
Clear text view widget.
virtual void DataChanged()
Bool_t IsReadOnly() const
virtual Bool_t Copy()
Copy selected text to clipboard.
virtual void DoubleClicked(const char *word)
virtual Bool_t HandleTimer(TTimer *t)
Handle scroll timer.
virtual Bool_t HandleButton(Event_t *event)
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
virtual Long_t ToObjYCoord(Long_t yCoord)
Convert y screen coordinate to line number.
A TGText is a multi line text buffer.
Bool_t InsChar(TGLongPosition pos, char c)
Insert character c at the specified position pos.
void ReTab(Long_t row)
Redo all tabs in a line. Needed after a new tab is inserted.
Bool_t DelText(TGLongPosition start, TGLongPosition end)
Delete text between start and end positions.
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)...
Bool_t DelLine(ULong_t pos)
Delete specified row. Returns false if row does not exist.
Bool_t Save(const char *fn)
Save text buffer to file fn.
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.
Bool_t DelChar(TGLongPosition pos)
Delete character at specified position pos.
Bool_t BreakLine(TGLongPosition pos)
Break line at position pos. Returns false if pos is not valid.
Bool_t InsText(TGLongPosition pos, const char *buf)
Insert single line at specified position.
char * GetLine(TGLongPosition pos, ULong_t length)
Return string at position pos.
char GetChar(TGLongPosition pos)
Get character a position pos. If character not valid return -1.
Bool_t LoadBuffer(const char *txtbuf)
Load a 0 terminated buffer. Lines will be split at ' '.
void Clear()
Clear text buffer.
TGTextLine * GetCurrentLine() const
const char * GetFileName() const
Long_t GetLineLength(Long_t row)
Get length of specified line. Returns -1 if row does not exist.
TString AsString()
Returns content as ROOT string.
Atom_t fClipboard
clipboard property
TGHScrollBar * fHsb
horizontal scrollbar
TGVScrollBar * fVsb
vertical scrollbar
TGLongPosition fVisible
position of visible region
Int_t fScrolling
scrolling direction
TGLongPosition fScrollVal
scroll value
TGViewFrame * fCanvas
frame containing the text
virtual void UpdateRegion(Int_t x, Int_t y, UInt_t w, UInt_t h)
update a part of view
virtual void ScrollCanvas(Int_t newTop, Int_t direction)
Scroll the canvas to new_top in the kVertical or kHorizontal direction.
TGRectangle fExposedRegion
exposed area
ROOT GUI Window base class.
virtual const char * GetName() const
Return unique name, used in SavePrimitive methods.
const TGWindow * fParent
Parent window.
virtual Bool_t IsMapped()
Returns kTRUE if window is mapped on screen, kFALSE otherwise.
Bool_t Notify()
This method must be overridden to handle object notification.
TInsCharCom(TGTextEdit *te, char ch)
void SetEndPos(TGLongPosition end)
TInsTextCom(TGTextEdit *te)
Bool_t Notify()
This method must be overridden to handle object notification.
virtual void Add(TObject *obj)
virtual void RemoveLast()
Remove the last object of the list.
virtual TObject * Last() const
Return the last object in the list. Returns 0 when list is empty.
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Mother of all ROOT objects.
virtual Bool_t Notify()
This method must be overridden to handle object notification.
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
Bool_t Disconnect(const char *signal=0, void *receiver=0, const char *slot=0)
Disconnects signal of this object from slot of receiver.
const char * Data() const
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
virtual FILE * OpenPipe(const char *command, const char *mode)
Open a pipe.
virtual const char * UnixPathName(const char *unixpathname)
Convert from a local pathname to a Unix pathname.
virtual void AddTimer(TTimer *t)
Add timer to list of system timers.
virtual int ClosePipe(FILE *pipe)
Close the pipe.
Handles synchronous and a-synchronous timer events.
void Reset()
Reset the timer.