TextArea inserts

Post

Posted
Rating:
#1 (In Topic #1408)
Avatar
Regular
thatbruce is in the usergroup ‘Regular’
 Help me out folks,

Given a TextArea, I want to insert some text at the beginning of the current line or at the beginning of the text if there is only one line. This is regardless of whether the text is being wrapped at this point.
I have no idea.

b

Online now: No Back to the top

Post

Posted
Rating:
#2
Guru
BruceSteers is in the usergroup ‘Guru’
I find it best to not consider if TextArea can do it with it's own methods (especially with wrapping enabled)
but instead just use normal String commands like RInstr() on the text.
like this….  

Code (gambas)

  1.  
  2. '' Insert "NEW: " to the start of the current line
  3. Public Sub Button1_Click()
  4.  
  5.   InsertAtSOL(TextArea1, "NEW: ")
  6.  
  7.  
  8. '' Insert provided Text at the textarea Start of Line (SOL)
  9. Public Sub InsertAtSOL(Area As TextArea, Text As String)
  10.  
  11.   Dim iCurPos As Integer = Area.Pos  ' Note Current cursor position
  12.   Dim iPos As Integer = Max(0, RInStr(Area.Text, "\n", iCurPos))  ' find the next LF to the left of cursor or goto start of doc
  13.   Area.Pos = iPos  ' move cursor
  14.   Area.Insert(Text)  ' insert text
  15.   Area.Pos = iCurPos + Text.Len ' move cursor back to where it was.
  16.   Area.SetFocus
  17.  
  18.  
  19.  
Online now: No Back to the top

Post

Posted
Rating:
#3
Guru
BruceSteers is in the usergroup ‘Guru’
 Is it a bug that pressing "Home" key on a wrapped line only goes to the start of the active row that may not be the actual start of the line?
Seems like a bug to me.
Terminal does not act like that and home key goes to start of the command no matter how many lines its using.
Online now: No Back to the top

Post

Posted
Rating:
#4
Avatar
Regular
thatbruce is in the usergroup ‘Regular’
 Thanks Bruce, as I said I had no idea!
And yes I reckon that is a bug but it may be a GUI thing.
b

Online now: No Back to the top
1 guest and 0 members have just viewed this.