Laxkit
0.0.7.1
|
An editor for a command prompt. More...
Public Member Functions | |
PromptEdit (anXWindow *prnt, const char *nname, const char *ntitle, unsigned long nstyle, int xx, int yy, int ww, int hh, int brder, anXWindow *prev, unsigned long nowner=None, const char *nsend=NULL, unsigned int ntstyle=0, const char *newtext=NULL) | |
virtual | ~PromptEdit () |
Delete history list. | |
virtual int | readonly (long pos) |
Anything before the start of the command line is readonly. | |
virtual int | ProcessInput (const char *thisexpression=NULL) |
Process input. Usually called on an enter from CharInput, but can be called anytime. | |
virtual void | SetPromptString (const char *nstr) |
Set the prompt string. | |
virtual const char * | GetPromptString () |
Return a const pointer to the current prompstring. | |
virtual int | CharInput (unsigned int ch, const char *buffer, int len, unsigned int state, const LaxKeyboard *d) |
Intercept for a reverse search, and to traverse the in/out queues. | |
Public Member Functions inherited from Laxkit::MultiLineEdit | |
MultiLineEdit (anXWindow *prnt, const char *nname, const char *ntitle, unsigned long nstyle, int xx, int yy, int ww, int hh, int brder, anXWindow *prev, unsigned long nowner=0, const char *nsend=NULL, unsigned int ntstyle=0, const char *newtext=NULL) | |
Constructor. | |
virtual | ~MultiLineEdit () |
Destructor, delete linestats. | |
virtual void | UseTheseScrollers (Scroller *xscroll, Scroller *yscroll) |
Use these external scrollers, rather than dynamically add and remove them. | |
virtual int | init () |
virtual int | Event (const EventData *e, const char *mes) |
virtual int | LBDown (int x, int y, unsigned int state, int count, const LaxMouse *d) |
virtual int | LBDblClick (int x, int y, unsigned int state, const LaxMouse *d) |
Selects whole word. | |
virtual int | LBUp (int x, int y, unsigned int state, const LaxMouse *d) |
Button up, nothing special. | |
virtual int | RBDown (int x, int y, unsigned int state, int count, const LaxMouse *d) |
Button down, nothing special. | |
virtual int | RBUp (int x, int y, unsigned int state, const LaxMouse *d) |
Button up, nothing special. | |
virtual int | WheelDown (int x, int y, unsigned int state, int count, const LaxMouse *d) |
Roll screen. | |
virtual int | WheelUp (int x, int y, unsigned int state, int count, const LaxMouse *d) |
Roll screen. | |
virtual int | MouseMove (int x, int y, unsigned int state, const LaxMouse *d) |
virtual int | Idle (int tid=0) |
virtual int | Resize (int nw, int nh) |
virtual int | MoveResize (int nx, int ny, int nw, int nh) |
virtual int | Find (char *str, int fromcurs=1) |
Find occurence of str, starting from position curpos if fromcurs==1. | |
virtual int | Replace (const char *oldstr, const char *newstr, int all) |
virtual int | SetText (const char *newtext) |
Set the text, and remap the screen. | |
virtual long | SetCurPos (long newcurpos) |
Jump to this new position. | |
virtual int | SetSelection (long newss, long newse) |
Set the selection to these bounds. | |
virtual int | newyssize () |
virtual int | newxssize (int p=1) |
Make sure the scrollers are correct for current line widths. | |
virtual void | wwinspect (int fromline=0) |
Try to figure out if screen still laid out correctly based on word wrapping. | |
virtual int | inschar (int ch) |
Insert character ch at curpos. | |
virtual int | delchar (int bksp) |
Delete character at curpos. bksp==0 means curpos, else curpos-1. | |
virtual int | insstring (const char *blah, int after=0) |
Insert a string. If after!=0 then place curpos after the string. | |
virtual int | replacesel (int ch) |
Replace the selection with this character. | |
virtual int | delsel () |
Delete selection. | |
virtual int | getscreenline (long pos) |
Return the screen line corresponding to character pos. | |
virtual int | replacesel (const char *newt, int after=0) |
virtual long | findpos (int l, int pix, int updatecp=1, int conv=1) |
Returns position most appropriate for x=pix, y=screen line l. | |
virtual long | countout (int linenumber, int &pout) |
Find character position for screen line number linenumber and horizontal pixel pout. | |
virtual int | makeinwindow () |
Make sure curpos is in the window somewhere (shifts screen, does not change curpos. | |
virtual void | findcaret () |
virtual int | ShiftScreen (int x, long y) |
Shift the view by x pixels and y lines. | |
virtual int | isword (long pos) |
Return whether position pos is part of a word. Default is alphanumeric or a period. | |
virtual long | findline (long ls, int &ilsofar) |
virtual long | findlinestart (long pos=-1) |
Find what should be the start of the screen line that contains pos. | |
virtual int | makelinestart (int startline, long ulwc, int godown, int ifdelete) |
Remaps linestats, but does not findcaret. | |
virtual int | Getmostwide () |
Returns which line is the most pixels wide. | |
virtual long | WhichLine (long pos) |
Return which screen line pos is in. | |
virtual void | DrawText (int black=1) |
Draw the screen. | |
virtual int | SetupMetrics () |
Call TextXEditBaseUtf8::SetupMetrics(), set firsttime=0, and SetupScreen(). | |
virtual void | SetupScreen () |
virtual LaxFiles::Attribute * | dump_out_atts (LaxFiles::Attribute *att, int what, Laxkit::anObject *savecontext) |
virtual void | dump_in_atts (LaxFiles::Attribute *att, int flag, Laxkit::anObject *loadcontext) |
Public Member Functions inherited from Laxkit::TextXEditBaseUtf8 | |
TextXEditBaseUtf8 (anXWindow *parnt, const char *nname, const char *ntitle, unsigned long nstyle, int xx, int yy, int ww, int hh, int brder, anXWindow *prev, unsigned long nowner, const char *nsend, const char *newtext=NULL, unsigned long ntstyle=0, int ncntlchar=0) | |
virtual | ~TextXEditBaseUtf8 () |
virtual void | Refresh () |
virtual int | MBUp (int x, int y, unsigned int state, const LaxMouse *d) |
Initiate a middle button paste via selectionPaste(1,0). | |
virtual int | FocusOn (const FocusChangeData *e) |
Draws the caret on. | |
virtual int | FocusOff (const FocusChangeData *e) |
Draws the caret off. | |
virtual int | charwidth (int ch, int r=0) |
Returns real char width with r==1, else returns the custom hexified if r==0. | |
virtual int | Cut () |
Copy() then delsel(). | |
virtual int | Copy () |
Calls anXApp::CopytoBuffer() with the current selection. | |
virtual int | Paste () |
Utilizes anXApp::GetBuffer(). | |
virtual void | Colors (int hl) |
Set curtextcolor and curbkcolor according to whether highlighting is on or not. | |
virtual void | Black (int x, int y, int w, int h) |
Fill x,y,w,h with curbkcolor. | |
virtual int | DrawTabLine () |
Draw a marker at top of text area that shows where and what type of tabs exist for the line. | |
virtual void | DrawCaret (int flag=0, int on=1) |
Update the caret and if necessary the change in the selection. | |
virtual int | DrawLineOfText (int x, int y, long pos, long len, char &check, long eof=-1) |
Draw a single line of text. | |
virtual int | TextOut (int x, int y, char *str, long len, long eof) |
Print out len bytes of str, which is a pointer to somewhere inside thetext. | |
virtual int | ExtentAndStr (char *str, long len, char *&blah, long &p) |
Find a printable string, and its pixel extent. | |
virtual int | GetExtent (long pos, long end, int lsofar=0, long eof=-1) |
Find the extent of the string in range [pos,end). Must be no newlines within the range. | |
virtual long | GetPos (long pos, int pix, int lsofar=0, long eof=-1) |
Returns maximum pos less than or equal to an arbitrary window pixel position. | |
virtual int | UseThisFont (LaxFont *newfont) |
Public Member Functions inherited from Laxkit::anXWindow | |
anXWindow (anXWindow *parnt, const char *nname, const char *ntitle, unsigned long nstyle, int xx, int yy, int ww, int hh, int brder, anXWindow *prev, unsigned long nowner, const char *nsend) | |
Constructor. | |
virtual | ~anXWindow () |
anXWindow destructor. Its X window should have been XDestroy'd before here. | |
virtual const char * | whattype () |
virtual const char * | WindowTitle (int which=0) |
Return basically the name of the window. | |
virtual void | WindowTitle (const char *newtitle) |
Change the title of the window. This text would usually be displayed in the bar provided by a window manager. | |
virtual const char * | tooltip (int mouseid=0) |
By default, return win_tooltip. | |
virtual const char * | tooltip (const char *newtooltip) |
Replace the current tooltip, return the current tooltip (after replacing). | |
virtual anXWindow * | findChildWindowByTitle (const char *title) |
Find the first immediate child window that has win_title==title. | |
virtual anXWindow * | findChildWindowByName (const char *name) |
Find the first immediate child window that has win_name==name. | |
virtual int | Grayed () |
Return whether this window is grayed. | |
virtual int | Grayed (int g) |
Set the gray state of this window. Returns Grayed(void). | |
virtual int | preinit () |
virtual int | close () |
Called by anXApp from anXApp::destroywindow() when a window is to be destroyed. | |
virtual Displayer * | MakeCurrent () |
virtual int | Needtodraw () |
Default is to return needtodraw. | |
virtual void | Needtodraw (int nntd) |
If 0, then the window does not need refreshing. Otherwise it does. | |
virtual int | deletenow () |
Return whether the window is allowed to be deleted. | |
virtual int | setWinStyle (unsigned int stylebit, int newvalue) |
Control various window related basic styling of win_style. | |
virtual int | getWinStyle (unsigned int stylebit) |
Currently, simply return win_style&stylebit. | |
virtual void | installColors (WindowColors *newcolors) |
Dec_count old and inc_count new. | |
virtual ShortcutHandler * | GetShortcuts () |
Return a ShortcutHandler that contains stacks of bound shortcuts and possible window actions. | |
virtual int | PerformAction (int action_number) |
virtual int | ExposeChange (ScreenEventData *e) |
Default behavior on Expose events is to call Needtodraw(1). | |
virtual int | DeviceChange (const DeviceEventData *e) |
virtual int | KeyUp (unsigned int ch, unsigned int state, const LaxKeyboard *kb) |
Called when a key is released. | |
virtual int | ButtonDown (int button, int x, int y, unsigned int state, int count, const LaxMouse *m) |
virtual int | ButtonUp (int button, int x, int y, unsigned int state, const LaxMouse *m) |
virtual int | MBDown (int x, int y, unsigned int state, int count, const LaxMouse *d) |
Default is just to return 1. | |
virtual void | contentChanged () |
Windows may call this when their contents change. | |
virtual void | selectionChanged () |
Windows may call this when their selections change. | |
virtual anXWindow * | GetController () |
Return the window most relevant for tab control loops. | |
virtual int | SelectNextControl (const LaxDevice *d) |
Transfer focus to nextcontrol. | |
virtual int | SelectPrevControl (const LaxDevice *d) |
Transfer the focus to prevcontrol. | |
virtual void | ControlActivation (int on) |
Do special activation or not when controls are activated by tabbing. | |
virtual int | AddPrevControl (anXWindow *prev) |
virtual int | AddNextControl (anXWindow *next) |
virtual int | ConnectControl (anXWindow *towhat, int after=1) |
Connect towhat to this. Used for tab loops. | |
virtual int | CloseControlLoop () |
Close a tab loop. | |
virtual void | SetOwner (anXWindow *nowner, const char *mes=NULL, unsigned int send_mask=0) |
Set the new owner and control message. | |
virtual void | SetOwner (unsigned long nowner_id, const char *mes=NULL, unsigned int send_mask=0) |
virtual void | dump_out (FILE *f, int indent, int what, anObject *context) |
Simple dumping function. | |
Public Member Functions inherited from Laxkit::Tagged | |
virtual int | HasTag (const char *tag, int casematters) |
Return whether the tag exists. | |
virtual int | NumberOfTags () |
Return the number of tags, strangely enough. | |
virtual const char * | GetTag (int i) |
Return const pointer to the tag text for tag number i, where i==0 is the first tag. | |
virtual char * | GetAllTags () |
Return a new char[] with a space separated list of all the tags. | |
virtual int | InsertTags (const char *tags, int casematters) |
Insert tags from a string such as 'tag1 tag2 tag3 "tag with spaces" tag4'. | |
virtual int | InsertTag (const char *tag, int casematters) |
Insert tag if it doesn't exist already. | |
virtual int | RemoveTag (const char *tag) |
The tag must be an exact match. | |
virtual int | RemoveTag (int i) |
Remove tag number i. i must be in range [0..NumberOfTags()-1]. | |
virtual void | FlushTags () |
Public Member Functions inherited from LaxFiles::DumpUtility | |
virtual void | dump_in (FILE *f, int indent, int what, Laxkit::anObject *loadcontext, Attribute **att) |
Read in a file segment as an Attribute, and pass parsing duties to dump_in_atts. | |
virtual | ~DumpUtility () |
Empty virtual destructor. | |
Public Member Functions inherited from Laxkit::aDrawable | |
aDrawable (Drawable d=0) | |
virtual int | DrawableType () |
virtual int | ValidDrawable () |
Public Member Functions inherited from Laxkit::TextEditBaseUtf8 | |
TextEditBaseUtf8 (const char *newtext=NULL, unsigned long nstyle=0, unsigned int ncntlchar=0) | |
Constructor. | |
virtual | ~TextEditBaseUtf8 () |
delete[] thetext and cutbuffer. | |
virtual int | charwidth (unsigned int usc, int actual=0) |
virtual int | GetTabChar (int atpix) |
For CHAR_TABS, returns the character to center on, or 0 if no such tab there. | |
virtual int | GetNextTab (int atpix) |
Redefine for custom tabstops, default is even spacing with tabwidth pixels. | |
virtual int | GetNextTab (int atpix, int &tabtype) |
Redefine for custom tabstops, default is even spacing with tabwidth pixels. | |
virtual int | inschar (unsigned int ucs, char a=1) |
Insert character at curpos. Afterward, make curpos on it (a==0) or after (a==1) it. Ignores selection, always at curpos. | |
virtual int | replacesel (unsigned int ucs) |
Replace the selection with character ch. | |
virtual int | onlf (long pos=-1) |
Return whether pos is on a delimiter. 0==no, 1==first delimiter, 2==second delimeter. | |
virtual int | findword (long pos, long &start, long &end) |
Find the start and end of a word that includes position pos. | |
virtual const char * | GetCText () |
Return a const pointer to thetext. | |
virtual char * | GetText () |
Return a new char[] copy of thetext. | |
virtual char * | GetSelText () |
Return a new char[] copy of the selected text. | |
virtual char * | CutSelText () |
Cut out the selected text, and return a copy to a new char[] containing the text. | |
virtual long | GetSelection (long &sels, long &sele) |
Get information about the selection positions. | |
virtual long | Getnumlines () |
Return the number of newlines in the whole buffer. | |
virtual long | Getnlines (long s=-1, long e=-1) |
Return the number of newlines in range [s,e]. | |
virtual long | Getcharswide () |
Returns most characters wide in all of lines of thetext. | |
virtual int | Getpixwide (long linenum) |
Return pix wide of line from p to newline. | |
virtual int | Modified (int m=1) |
virtual int | Undo () |
virtual int | Redo () |
virtual long | GetCurLine () |
virtual long | SetCurLine (long nline) |
virtual long | GetCurpos () |
virtual long | SetCurpos (long ncurpos) |
Returns new curpos. | |
virtual int | SetDelimiter (char n1, char n2=0) |
Set the newline delimiter to "n1n2". n2==0 means use single character newline. | |
virtual int | Find (const char *str, int fromcurs=1) |
Find str in thetext, start search at fromcurs, wrap around. | |
virtual int | Replace (const char *newstr, int start, int end) |
Replace a range of text with a new string. |
Protected Member Functions | |
virtual char * | process (const char *in) |
Takes an in, and returns a new char[] out. | |
Protected Member Functions inherited from Laxkit::MultiLineEdit | |
virtual int | send () |
Protected Member Functions inherited from Laxkit::TextXEditBaseUtf8 | |
virtual void | docaret (int w=1) |
Inverts the caret area. DrawCaret is responsible for maintaining con. | |
virtual void | settextrect () |
This updates textrect based on new window dimensions. | |
virtual int | selectionDropped (unsigned char *data, unsigned long len, Atom actual_type, Atom which) |
virtual char * | getSelectionData (int *len, Atom property, Atom targettype, Atom selection) |
Return the selected text, or NULL if no selection. | |
Protected Member Functions inherited from Laxkit::anXWindow | |
virtual int | deletekid (anXWindow *w) |
Purges child anXWindows from window's child stack. | |
virtual void | SwapBuffers () |
Swap buffers. This should be called from Refresh() if VIEWPORT_BACK_BUFFER is set in win_style. | |
virtual void | SetupBackBuffer () |
Initialize the backbuffer. | |
Protected Member Functions inherited from Laxkit::TextEditBaseUtf8 | |
virtual int | extendtext () |
Extend the memory allocated for thetext. | |
virtual long | nextpos (long l) |
Return the next utf8 character position after l. | |
virtual long | prevpos (long l) |
Return the utf8 character position befor l. | |
virtual void | makevalidpos (long &l) |
Make l point only to 1st byte of a utf8 char or 2-char delimiter. | |
virtual int | Undo (UndoData *data) |
virtual int | Redo (UndoData *data) |
virtual int | AddUndo (int type, const char *str, long len, long start, long end) |
Protected Attributes | |
char * | promptstring |
long | start |
Points to the start of the command line. | |
HistoryNode * | history |
int | numhistory |
int | maxhistory |
This number of inputs and outputs are stored. | |
Protected Attributes inherited from Laxkit::MultiLineEdit | |
char * | blanktext |
ButtonDownInfo | buttondown |
int | cdir |
int | scrollwidth |
int | mostpixwide |
int | mostcharswide |
int | maxpixwide |
int | numlines |
int | lpers |
The number of lines per screen. | |
int | longestline |
int | mx |
int | my |
struct Laxkit::MultiLineEdit::Linestat * | linestats |
Holds the character start position, pixel length, and pixel indentation of a screen line. | |
Scroller * | xscroller |
Scroller * | yscroller |
int | xscrollislocal |
int | yscrollislocal |
Protected Attributes inherited from Laxkit::TextXEditBaseUtf8 | |
int | cx |
The x position of the current position, measured from the top left corner of the window. | |
int | cy |
The baseline y position of the current line, measured from the top left corner of the window. | |
int | oldx |
The old value of cx for a caret that might need to be blanked out. | |
int | oldy |
The old value of cy for a caret that might need to be blanked out. | |
int | curlineoffset |
The pixel horizontal offset the text is shifted. | |
char | firsttime |
char | con |
Nonzero if the caret is supposed to be on, and is drawn on, on the screen. | |
long | dpos |
The beginning position in thetext that needs to be redrawn. | |
long | nlines |
The number of lines starting from the line of dpos that must be redrawn. | |
long | oldsellen |
The previous selection length to help narrow down what on screen must be redrawn. | |
long | oldcp |
The previous curpos to help narrow down what on screen must be redrawn. | |
int | textascent |
int | textheight |
int | textdescent |
unsigned long | curtextcolor |
unsigned long | textbgcolor |
unsigned long | curbkcolor |
unsigned long | bkwrongcolor |
unsigned long | wscolor |
LaxFont * | thefont |
int | valid |
An extra modifier to control what colors are used. | |
DoubleRectangle | textrect |
The rectangle inside of which text can be drawn. | |
Protected Attributes inherited from Laxkit::anXWindow | |
char * | win_tooltip |
Convenience variable to hold the window's tooltip, if any. | |
int | needtodraw |
RefPtrStack< anXWindow > | _kids |
Stack of children of the window. | |
Protected Attributes inherited from Laxkit::Tagged | |
PtrStack< char > | list_of_tags |
Protected Attributes inherited from Laxkit::TextEditBaseUtf8 | |
long | curline |
long | curpos |
long | selstart |
long | sellen |
int | cntlmovedist |
int | tabwidth |
char * | thetext |
char * | cutbuffer |
long | textlen |
long | maxtextmem |
char | newline |
char | newline2 |
char | cntlchar |
char | modified |
long | maxtextlen |
long | mintextlen |
long | maxcharswide |
long | mincharswide |
long | maxlines |
long | minlines |
unsigned long | textstyle |
int | undomode |
UndoManager | undomanager |
Additional Inherited Members | |
Public Attributes inherited from Laxkit::MultiLineEdit | |
int | padx |
int | pady |
An editor for a command prompt.
This is everything the standard MultiLineEdit is, but it keeps track of inputs and outputs. A prompt string is displayed, and input can be processed, and the output is appended to the edit's text.
|
virtual |
Intercept for a reverse search, and to traverse the in/out queues.
*** clear to start of command line
*** clear to end of command line
*** clear whole command line
*** other readline-y things like searching? tab completion?
Reimplemented from Laxkit::MultiLineEdit.
References ProcessInput().
Takes an in, and returns a new char[] out.
This out should not have pre and post newlines. Those would be inserted in ProcessInput().
References newstr().
Referenced by ProcessInput().
Process input. Usually called on an enter from CharInput, but can be called anytime.
This takes the expression, finds an output expression, then inserts the output, and a new prompt into the edit.
If thisexpression==NULL then the text between the prompt and the end is processed. Otherwise, thisexpression is processed, and whatever is on the current command line is ignored.
References GetPromptString(), Laxkit::HistoryNode::inputlen, Laxkit::HistoryNode::inputstart, Laxkit::MultiLineEdit::inschar(), Laxkit::MultiLineEdit::insstring(), maxhistory, Laxkit::TextEditBaseUtf8::nextpos(), Laxkit::HistoryNode::outputlen, Laxkit::HistoryNode::outputstart, process(), Laxkit::TextEditBaseUtf8::SetCurpos(), and start.
Referenced by CharInput().