Laxkit  0.0.7.1
Classes | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes
Laxkit::MultiLineEdit Class Reference

*** please note this class is currently seriously broken *** Multiline edit with optional word wrap. More...

Inheritance diagram for Laxkit::MultiLineEdit:
Inheritance graph
[legend]

List of all members.

Classes

struct  Linestat
 Holds information about the screen lines. More...

Public Member Functions

 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 CharInput (unsigned int ch, const char *buffer, int len, unsigned int state, const LaxKeyboard *d)
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::Attributedump_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 charwhattype ()
virtual const charWindowTitle (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 chartooltip (int mouseid=0)
 By default, return win_tooltip.
virtual const chartooltip (const char *newtooltip)
 Replace the current tooltip, return the current tooltip (after replacing).
virtual anXWindowfindChildWindowByTitle (const char *title)
 Find the first immediate child window that has win_title==title.
virtual anXWindowfindChildWindowByName (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 DisplayerMakeCurrent ()
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 ShortcutHandlerGetShortcuts ()
 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 anXWindowGetController ()
 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 charGetTag (int i)
 Return const pointer to the tag text for tag number i, where i==0 is the first tag.
virtual charGetAllTags ()
 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 int readonly (long pos=-1)
 Returns if the text is readonly at the given position.
virtual const charGetCText ()
 Return a const pointer to thetext.
virtual charGetText ()
 Return a new char[] copy of thetext.
virtual charGetSelText ()
 Return a new char[] copy of the selected text.
virtual charCutSelText ()
 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.

Public Attributes

int padx
int pady

Protected Member Functions

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 chargetSelectionData (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

charblanktext
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.
Scrollerxscroller
Scrolleryscroller
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
LaxFontthefont
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
charwin_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< charlist_of_tags
- Protected Attributes inherited from Laxkit::TextEditBaseUtf8
long curline
long curpos
long selstart
long sellen
int cntlmovedist
int tabwidth
charthetext
charcutbuffer
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

Detailed Description

*** please note this class is currently seriously broken *** Multiline edit with optional word wrap.

Optional scrollers, handles l/r/c/char tabs, simple l/r/c justification.

 NOTES:
 *** means not yet implemented..
  Usual char codes:
  ESC         get out of any control modes, deselect selection ***
  ^l          put in/out select line mode ***
  ^left,^right  jump word left or right
  ^up,^down   jump to first/last line on screen
  ^a          select all
  ^c/C, ^ins  copy
  ^x/X, +del  cut
  ^v/V  +ins  paste
  ^w          toggle word wrap
  ^+w         toggle show whitespace
  ^.          increase tab width
  ^,          decrease tab width
  ^t ???      set l/r/c/n tab *** slide around a guide??? ***
              rm tab***
  ^\          toggle show hex chars
  lbdbl       select word***
  lbtrp       select line***
  rb-drag     ShiftScreen***
  wheel       move y
  ^wheel      move page y
  +wheel      move x
  ^+wheel     move page x
  
Todo:
*** lots of stuff, particularly adding scrollers, see class description....
#define GOODEDITWW_FILL_LR_BOX <-- make x,y scrollers cover up the little box in lower right
#define GOODEDITWW_ABS_SCROLLERS <-- use some definite rectangle, and don't unmap??? huh?
#define GOODEDITWW_Y_IS_LINES <-- if scrollers show line span or character span
#define GOODEDITWW_Y_IS_CHARS
<pre>
TODO
*** smart refreshing when moving screen XMoveArea.. make sure little windows on top dealt with ok?? how??
*** make a window for tab position editing??
*** might be useful to have a charwidth(long pos) for strange fonts??
*** center and right justified
*** wheel up doing weird
*** not blacking out when add lines at eof
*** not drawing final box for eof if eof on its own line
*** deleting lines no good
*** makeinwindow? not dealing with right edge after textrect change
*** select, then focus out, then click on, and old selection is not removed
*** end on wrapped lines now not going to end (this is actually a feature!! though should make cursor at fake-eol
equivalent to cursor at beg of next line for wrapped lines
*** wwinspect doesn't seem to be working well, inschars allowed to go beyond maxpixlen
FOR FANCY
put this in a derived class?:
^t then arrows to position tab, l/r/c/n selects type, ^arrows selects current tabs, ESC escapes
</pre>

Member Function Documentation

int Laxkit::MultiLineEdit::delchar ( int  bksp)
virtual

Delete character at curpos. bksp==0 means curpos, else curpos-1.

*** this is rather convoluted, rethink it

Reimplemented from Laxkit::TextEditBaseUtf8.

References Laxkit::TextEditBaseUtf8::delchar(), Laxkit::TextXEditBaseUtf8::dpos, findcaret(), Getmostwide(), linestats, lpers, makeinwindow(), makelinestart(), newxssize(), newyssize(), Laxkit::TextXEditBaseUtf8::nlines, Laxkit::TextEditBaseUtf8::onlf(), and wwinspect().

int Laxkit::MultiLineEdit::delsel ( )
virtual
int Laxkit::MultiLineEdit::Event ( const EventData e,
const char mes 
)
virtual

Responds to 'xscroller' and 'yscroller'.

Todo:
*** not sure if this is ok since scrollers use the panner now...

Reimplemented from Laxkit::anXWindow.

References findlinestart(), Laxkit::Scroller::GetCurPos(), Laxkit::Scroller::GetCurPosEnd(), lpers, makelinestart(), newxssize(), newyssize(), and ShiftScreen().

void Laxkit::MultiLineEdit::findcaret ( )
virtual
long Laxkit::MultiLineEdit::findline ( long  ls,
int ilsofar 
)
virtual

Returns pos of start of next potential screen line after ls, assumes ilsofar set right updates ilsofar which basically becomes pixlen of line with ls.

References Laxkit::TextXEditBaseUtf8::GetExtent(), isword(), Laxkit::TextEditBaseUtf8::nextpos(), Laxkit::TextEditBaseUtf8::onlf(), and Laxkit::TextEditBaseUtf8::prevpos().

Referenced by findlinestart(), makelinestart(), and wwinspect().

long Laxkit::MultiLineEdit::findpos ( int  l,
int  pix,
int  updatecp = 1,
int  conv = 1 
)
virtual
int Laxkit::MultiLineEdit::Getmostwide ( )
virtual

Returns which line is the most pixels wide.

Does not recompute linestats.pixlens

References linestats, lpers, Laxkit::Scroller::SetSize(), and Laxkit::TextXEditBaseUtf8::textrect.

Referenced by delchar(), inschar(), makeinwindow(), SetText(), and SetupScreen().

int Laxkit::MultiLineEdit::getscreenline ( long  pos)
virtual

Return the screen line corresponding to character pos.

If the position is before the screen, then -1 is returned. If the position is after the screen, then lpers+2 is returned.

*** see also WhichLine()..

References linestats, and lpers.

Referenced by delsel().

int Laxkit::MultiLineEdit::Idle ( int  tid = 0)
virtual

currently empty...

Reimplemented from Laxkit::anXWindow.

int Laxkit::MultiLineEdit::init ( )
virtual

If multilineedit uses outside supplied scrollers, the must be passed into this before init is called. Otherwise new scrollers are created here.

Init sets an initial textrect size, and sets curlineoffset to be at padx.

Reimplemented from Laxkit::TextXEditBaseUtf8.

References Laxkit::TextXEditBaseUtf8::curlineoffset, Laxkit::TextXEditBaseUtf8::settextrect(), and Laxkit::TextXEditBaseUtf8::textrect.

int Laxkit::MultiLineEdit::LBDown ( int  x,
int  y,
unsigned int  state,
int  count,
const LaxMouse d 
)
virtual
Todo:
*** should put in drag and drop when lbdown on a selection

Reimplemented from Laxkit::anXWindow.

References Laxkit::ButtonDownInfo::down(), findpos(), LBDblClick(), and makeinwindow().

int Laxkit::MultiLineEdit::makeinwindow ( )
virtual

Make sure curpos is in the window somewhere (shifts screen, does not change curpos.

Assumes the caret's cx,cy already set accurately.

References Laxkit::TextXEditBaseUtf8::cy, findcaret(), Getmostwide(), lpers, makelinestart(), newxssize(), newyssize(), Laxkit::Scroller::SetCurPos(), and Laxkit::TextXEditBaseUtf8::textrect.

Referenced by delchar(), delsel(), Find(), inschar(), insstring(), LBDown(), Replace(), SetCurPos(), and SetSelection().

int Laxkit::MultiLineEdit::makelinestart ( int  startline,
long  ulwc,
int  godown,
int  ifdelete 
)
virtual

Remaps linestats, but does not findcaret.

It does find and set mostpixwide,longestline, dpos,nlines

Todo:
*****put newyssize in mls?
Parameters:
ulwcScreen line to begin remapping from
godownCharacter to place at beginning of screen line startline
ifdeleteIf godown<=0, then remap backwards from startline, else forwards from startline 1 to reallocate linestats, else do not reallocate

References Laxkit::TextXEditBaseUtf8::dpos, findline(), findlinestart(), linestats, lpers, Laxkit::TextXEditBaseUtf8::nlines, Laxkit::TextEditBaseUtf8::onlf(), and Laxkit::TextEditBaseUtf8::prevpos().

Referenced by delchar(), delsel(), Event(), insstring(), makeinwindow(), SetText(), SetupScreen(), ShiftScreen(), and wwinspect().

int Laxkit::MultiLineEdit::MouseMove ( int  x,
int  y,
unsigned int  state,
const LaxMouse d 
)
virtual
Todo:
institute drag and drop for selections

Reimplemented from Laxkit::anXWindow.

References findpos(), Laxkit::ButtonDownInfo::isdown(), lpers, Laxkit::ButtonDownInfo::move(), and ShiftScreen().

int Laxkit::MultiLineEdit::MoveResize ( int  nx,
int  ny,
int  nw,
int  nh 
)
virtual

*** probably should cache resize events, so don't have to constantly SetupScreen which drag-resizing a window.

Reimplemented from Laxkit::TextXEditBaseUtf8.

References Laxkit::TextXEditBaseUtf8::settextrect(), and SetupScreen().

int Laxkit::MultiLineEdit::newyssize ( )
virtual

NOTE: the scrollers are always flush with right and bottom, and newyssize,newxssize modify textrect

Referenced by delchar(), delsel(), Event(), inschar(), insstring(), makeinwindow(), SetText(), SetupScreen(), ShiftScreen(), UseTheseScrollers(), and wwinspect().

int Laxkit::MultiLineEdit::Replace ( const char oldstr,
const char newstr,
int  all 
)
virtual
Todo:
*** this, like the others in base classes are wholly inadequate

Reimplemented from Laxkit::TextEditBaseUtf8.

References findcaret(), makeinwindow(), and Laxkit::TextEditBaseUtf8::Replace().

int Laxkit::MultiLineEdit::Resize ( int  nw,
int  nh 
)
virtual

*** probably should cache resize events, so don't have to constantly SetupScreen which drag-resizing a window.

Reimplemented from Laxkit::TextXEditBaseUtf8.

References Laxkit::TextXEditBaseUtf8::settextrect(), and SetupScreen().

void Laxkit::MultiLineEdit::SetupScreen ( )
virtual

Sets up lpers, does Getmostwide(), and moves scrollers (if any) to correct positions. Then findcaret().

Todo:

*** if (xscroller && xscroller->win_on) xscroller->MoveResize(0,win_h-scrollwidth, win_w,scrollwidth);

*** if (yscroller && yscroller->win_on) yscroller->MoveResize(win_w-scrollwidth,0, scrollwidth,win_h);

References findcaret(), Getmostwide(), lpers, makelinestart(), Laxkit::Scroller::MoveResize(), newxssize(), newyssize(), and Laxkit::TextXEditBaseUtf8::textrect.

Referenced by MoveResize(), Resize(), SetupMetrics(), and UseTheseScrollers().

int Laxkit::MultiLineEdit::ShiftScreen ( int  x,
long  y 
)
virtual

Shift the view by x pixels and y lines.

Todo:
*** need smart ShiftScreen XCopyArea

Returns 1 if there is a change, 0 if not

References Laxkit::TextXEditBaseUtf8::curlineoffset, findcaret(), Laxkit::Scroller::GetCurPos(), linestats, lpers, makelinestart(), newxssize(), newyssize(), and Laxkit::Scroller::SetCurPos().

Referenced by Event(), MouseMove(), WheelDown(), and WheelUp().

void Laxkit::MultiLineEdit::UseTheseScrollers ( Scroller xscroll,
Scroller yscroll 
)
virtual

Use these external scrollers, rather than dynamically add and remove them.

Todo:
*** this needs work..

References Laxkit::anXApp::destroywindow(), newxssize(), newyssize(), SetupScreen(), Laxkit::TextXEditBaseUtf8::textrect, and Laxkit::anXWindow::win_on.

long Laxkit::MultiLineEdit::WhichLine ( long  pos)
virtual

Return which screen line pos is in.

If the position is before the screen, then -1 is returned. If the position is after the screen, then lpers is returned (*** is that really oK??).

*** see getscreenline()... this is reimp from TextEditBaseUtf8, i think its really supposed to be the absolute line..

This function is used in TextXEditBaseUtf8::DrawCaret() to figure out what lines to either highlight or de-highlight.

Reimplemented from Laxkit::TextEditBaseUtf8.

References linestats, and lpers.

void Laxkit::MultiLineEdit::wwinspect ( int  fromline = 0)
virtual

Try to figure out if screen still laid out correctly based on word wrapping.

Called anytime changes are made in thetext. It changes linestats, needtodraw, dpos, nlines.

This inspects lines starting at fromline to ensure that they are. correct given current wrapping setup. It was checking each line only until the next line is correct, but that doesn't catch all changes, for instance adding a character to one line may change the previous line (if it is a space in a wrapped word for instance) or it may only cause the line it was typed on wrap differently. So you must scan from fromline to eo-screen.

Todo:
*** perhaps an optimization would be wwinspect(fromline,scanAtLeastThisManyLines)

References Laxkit::TextXEditBaseUtf8::dpos, findcaret(), findline(), findlinestart(), linestats, lpers, makelinestart(), newxssize(), newyssize(), and Laxkit::TextXEditBaseUtf8::nlines.

Referenced by delchar(), and inschar().


Member Data Documentation

int Laxkit::MultiLineEdit::lpers
protected

The number of lines per screen.

Line 0 is the first line of the screen and line lpers-1 is the last full line on the screen. Typically lines do not fit exactly on the screen, but it is useful to have a couple extra. So line lpers is usually the half on screen line, and line lpers+1 is the next line after that. The linestats array will have lpers+2 elements.

This is set only in SetupScreen(), newxsize() and newysize().

Referenced by delchar(), DrawText(), Event(), findcaret(), findpos(), Getmostwide(), getscreenline(), inschar(), insstring(), makeinwindow(), makelinestart(), MouseMove(), SetupScreen(), ShiftScreen(), WheelDown(), WheelUp(), WhichLine(), and wwinspect().


The documentation for this class was generated from the following files:

Mon Feb 17 2014 11:53:00, Laxkit