Scintilla GETLINE

Just starting out? Need help? Post your questions and find answers here.
User avatar
rndrei
Enthusiast
Enthusiast
Posts: 184
Joined: Thu Dec 28, 2023 9:04 pm

Scintilla GETLINE

Post by rndrei »

How to find out the current line number where the cursor is located? This does not work:

Code: Select all

ScintillaSendMessage(#Sc, #SCI_GETLINE))
ScintillaSendMessage(#Sc, #SCI_GETCURLINE))
infratec
Always Here
Always Here
Posts: 7662
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Scintilla GETLINE

Post by infratec »

AZJIO
Addict
Addict
Posts: 2225
Joined: Sun May 14, 2017 1:48 am

Re: Scintilla GETLINE

Post by AZJIO »

User avatar
rndrei
Enthusiast
Enthusiast
Posts: 184
Joined: Thu Dec 28, 2023 9:04 pm

Re: Scintilla GETLINE

Post by rndrei »

figured out how to find the current line number

Code: Select all

line_number=ScintillaSendMessage(#Sc, #SCI_LINEFROMPOSITION,ScintillaSendMessage(#Sc, #SCI_GETCURRENTPOS ))
But now I can't figure out how to find the current position in the current line?
Yes! ru:)
infratec
Always Here
Always Here
Posts: 7662
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Scintilla GETLINE

Post by infratec »

https://www.scintilla.org/ScintillaDoc. ... ONFROMLINE

Maybe you have to substract the general position.
User avatar
Piero
Addict
Addict
Posts: 1040
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

Re: Scintilla GETLINE

Post by Piero »

AZJIO wrote: Mon Sep 30, 2024 4:59 pm ru?
mac?
User avatar
rndrei
Enthusiast
Enthusiast
Posts: 184
Joined: Thu Dec 28, 2023 9:04 pm

Re: Scintilla GETLINE

Post by rndrei »

Piero wrote:
AZJIO wrote:ru?
mac?
Linux
User avatar
Piero
Addict
Addict
Posts: 1040
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

Re: Scintilla GETLINE

Post by Piero »

rndrei wrote: Mon Sep 30, 2024 7:05 pm
Piero wrote:
AZJIO wrote:ru?
mac?
Linux
Very well!
Anyway that's a joke between me and AZJIO; I admire his work, so I'm trying to convince him to also GET A MAC :x
infratec
Always Here
Always Here
Posts: 7662
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Scintilla GETLINE

Post by infratec »

Code: Select all

EnableExplicit


Procedure ScintillaCallBack(Gadget, *scinotify.SCNotification)
  If *scinotify\updated
    PostEvent(#PB_Event_Gadget, 0, Gadget, #PB_EventType_Change)
  EndIf
EndProcedure




Define.i Event, CurrentPos, Row, Col, Length


If OpenWindow(0, 0, 0, 330, 200, "ScintillaGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  
  ScintillaGadget(0, 10, 10, 310, 160, @ScintillaCallBack())
  
  ScintillaSendMessage(0, #SCI_STYLESETFORE, 0, RGB(255, 0, 0))
  
  CreateStatusBar(0, WindowID(0))
  AddStatusBarField(100)
  
  SetActiveGadget(0)
  
  Repeat
    Event = WaitWindowEvent()
    
    If Event = #PB_Event_Gadget
      If EventGadget() = 0
        If EventType() = #PB_EventType_Change
          CurrentPos = ScintillaSendMessage(0, #SCI_GETCURRENTPOS)
          Row = ScintillaSendMessage(0, #SCI_LINEFROMPOSITION, CurrentPos)
          Col = CurrentPos - ScintillaSendMessage(0, #SCI_POSITIONFROMLINE, Row)
          Length = ScintillaSendMessage(0, #SCI_GETLENGTH)
          StatusBarText(0, 0, Str(Row + 1) + " : " + Str(Col + 1) + " (" + Str(CurrentPos) + ") / [" + Str(Length) + "]", #PB_StatusBar_Center)
        EndIf
      EndIf
    EndIf
    
  Until Event = #PB_Event_CloseWindow
EndIf
User avatar
rndrei
Enthusiast
Enthusiast
Posts: 184
Joined: Thu Dec 28, 2023 9:04 pm

Re: Scintilla GETLINE

Post by rndrei »

thank's! it's work!
Post Reply