Jump to content

Move to another line In SciTE


Go to solution Solved by Jos,

Recommended Posts

Posted

I am doing a project where I want to move from one line#  in SciTE to another line#.

This is an example of what I am using.  It seems clunky but does the job.

Does anyone know of a way to do it cleanly without the lag and flashing that occurs ?

REB

#include <WindowsConstants.au3>
HotKeySet("{ESC}", "getOut")
$fileActivate = WinGetTitle("[CLASS:SciTEWindow]")
Local $Button
ButtonPress()
Func GoTo()
    Local $Pos
    $Pos = MouseGetPos()
    WinActivate($fileActivate)
    Send("^g")
    Send(1)
    Send("{ENTER}")
    MouseMove($Pos[0], $Pos[1], 0)
    ButtonPress()
EndFunc   ;==>GoTo
Func ButtonPress()
    $aGui = GUICreate("", 100, 30, -1, @DesktopHeight * .542, BitOR($WS_POPUP, $WS_DLGFRAME), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
    GUISetBkColor(0xC0C0C0) ; 0xD4D0C8) ;0xF7C1C5) ;0x66FF66)
    GUISetFont(9, 575)
    $Button = GUICtrlCreateButton("GoTo", 5, 10, 42, 20)
    GUICtrlSetTip($Button, "Click on any line and" & @CRLF & "Then Click button to goto line 1", "GoTo", 2)
    GUISetState(@SW_SHOW)
    WinActivate($fileActivate)
    $FlagDo = 1
    Do
        $msg = GUIGetMsg()
        Select
            Case $msg = $Button
                GoTo()

        EndSelect
    Until $FlagDo = 0
EndFunc   ;==>ButtonPress
Func getOut()
    Exit
EndFunc   ;==>getOut

MEASURE TWICE - CUT ONCE

Posted

Look at the SciTE Jump (signature) source code and you will see a UDF called SciTE. There is a clue how to jump to a "line number". Good luck!

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

Hi,

  that got rid of the flash and the lag, the GO TO line box is still going to popup briefly though...

Hope this helps...

#include <WindowsConstants.au3>
HotKeySet("{ESC}", "getOut")
$fileActivate = WinGetTitle("[CLASS:SciTEWindow]")
Local $Button
ButtonPress()
Func GoTo()
    Local $Pos
    $Pos = MouseGetPos()
    WinActivate($fileActivate)
    Send("^g")
    Send(1)
    Send("{ENTER}")
    ;MouseMove($Pos[0], $Pos[1], 0)
    ;ButtonPress()
EndFunc   ;==>GoTo
Func ButtonPress()
    $aGui = GUICreate("", 100, 30, -1, @DesktopHeight * .542, BitOR($WS_POPUP, $WS_DLGFRAME), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
    GUISetBkColor(0xC0C0C0) ; 0xD4D0C8) ;0xF7C1C5) ;0x66FF66)
    GUISetFont(9, 575)
    $Button = GUICtrlCreateButton("GoTo", 5, 10, 42, 20)
    GUICtrlSetTip($Button, "Click on any line and" & @CRLF & "Then Click button to goto line 1", "GoTo", 2)
    GUISetState(@SW_SHOW)
    WinActivate($fileActivate)
    $FlagDo = 1
    Do
        $msg = GUIGetMsg()
        Select
            Case $msg = $Button
                GoTo()

        EndSelect
    Until $FlagDo = 0
EndFunc   ;==>ButtonPress
Func getOut()
    Exit
EndFunc   ;==>getOut
Posted

I would personally advise against using Send in this instance, but then again I could be wrong.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

Func GoTo()

    Local $Pos
    $Pos = MouseGetPos()
    WinActivate($fileActivate)
    ControlSend($fileActivate, "", "", "^g")
    ControlSend($fileActivate, "", "", "1")
    ControlSend($fileActivate, "", "", "!g")

EndFunc   ;==>GoTo

Of course your right.... :bye:

Didn't wanna completely rewrite his code ;-)

Posted

I still think sending the SCI_GOTOLINE message to SciTE is the most reliable method. Hopefully the OP will look at my suggestion too.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

  • Developers
  • Solution
Posted

This is an example using the SciTE Director interface:

Opt("WinSearchChildren", 1)
Global $WM_COPYDATA = 74
; Get SciTE DirectorHandle
$Scite_hwnd = WinGetHandle("DirectorExtension")
; Get My GUI Handle
Global $My_Hwnd = GUICreate("AutoIt3-SciTE interface")
;
; goto the specified Line column
$line = 25
$Column = 15
SendSciTE_Command($My_Hwnd, $Scite_hwnd, "goto:" & $Line & "," & $Column) ; Clear Output pane "IDM_CLEAROUTPUT"
Exit
;
; Send command to SciTE
Func SendSciTE_Command($My_Hwnd, $Scite_hwnd, $sCmd)
    Local $My_Dec_Hwnd = Dec(StringRight($My_Hwnd, 8))
    $sCmd = ":" & $My_Dec_Hwnd & ":" & $sCmd
    ConsoleWrite('-->' & $sCmd & @LF)
    Local $CmdStruct = DllStructCreate('Char[' & StringLen($sCmd) + 1 & ']')
    DllStructSetData($CmdStruct, 1, $sCmd)
    Local $COPYDATA = DllStructCreate('Ptr;DWord;Ptr')
    DllStructSetData($COPYDATA, 1, 1)
    DllStructSetData($COPYDATA, 2, StringLen($sCmd) + 1)
    DllStructSetData($COPYDATA, 3, DllStructGetPtr($CmdStruct))
    DllCall('User32.dll', 'None', 'SendMessage', 'HWnd', $Scite_hwnd, _
            'Int', $WM_COPYDATA, 'HWnd', $My_Hwnd, _
            'Ptr', DllStructGetPtr($COPYDATA))
EndFunc   ;==>SendSciTE_Command

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

Thank you Jos

This works perfect in my project.

guinness

You were right. I had the SciTE UDF but could not get it to work. It does work well in your

SciTE Jump program. You Recommended to me to make my own comment deleter and

I am well on my way and jos's post will give it a very functionally  finished look.

Thanks to all

REB

MEASURE TWICE - CUT ONCE

Posted

It's easy...literally 2 functions.

#include '_SciTE.au3'

Example()

Func Example()
    _SciTE_GetHandles() ; Start SciTE.
    _SciTE_GoToLine(29) ; Go to line 30 in the editor.
EndFunc   ;==>Example

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

@ guinness

WOW --- That is easy. :thumbsup:

I will definitely try this out.

You guys are very patient and helpful.

Thank you very much.

REB

MEASURE TWICE - CUT ONCE

Posted

Let me know if you get stuck. The SciTE UDF (which is quite primitive) has some useful functions like placing a specific number to the top of the visible screen.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

  • 1 year later...
Posted

@Jos , could you please tell me what is the significance of this line in above code ?

  Quote
Global $My_Hwnd = GUICreate("AutoIt3-SciTE interface")
  Reveal hidden contents

 

Posted

Come on. It's like you aren't even trying. It's passed to SciTE, in that SciTE can then send a WM_COPYDATA back to you with relevant information, if you happen to send a message that sends data back. Not every message sends data back to the end user. I really suggest strongly you do some more reading, as this is kind of basic stuff if you're used to the likes of VB.NET etc.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted (edited)

@guinness I just ran the code. But seriously, i was in the middle of some work. But i can't resist my mind from rading this code and run it. But suddenly, i noticed this line. I have an assumption about this line. Now with your answer, i have cleared my doubt. I know i have more to read. A lot of links are waiting for me. Sorry for asking a basic question. 

 

edit - I edited this three times. Yet i can't convey my idea with this reoly. sorry for my poor english.

 

Edited by kcvinu
  Reveal hidden contents

 

Posted

Well if you're busy then my advice is wait until you're not.The forum shouldn't be a substitute for asking questions simply because of laziness or being "busy". Use it as a tool and don't abuse it.

I like to give people the benefit of the doubt and will often help if someone shows effort in the subject they're stuck on. You're only asking questions and I have yet to see any physical evidence of what that effort has led you to. If you want me to write a tutorial, then at least be honest. If you do, then I would expect some code in return.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted (edited)

@guinness , My job is a one year contract. So i can't wait for too long. And plus, i love to do things with autoit. So i will use 1 hour everyday for autoit learning. But in somedays, i can't utilize this time effectively. This time, this mistake was happen by( you called it laziness) only by lack of planning. I have a few projects in my mind. 1) Adding some functionality to SciTE, (2) Making a text expander for word (almost finished), (3) Making a file mover , (4) Making a code editor for AutoIt (I think it will always be a dream). And because of lack of planning, learning about all these projects are mixed and it become totally collapsed. Now i promise you, that i never asked silly questions until it started eating my head.

Edited by kcvinu
  Reveal hidden contents

 

Posted

Fair enough.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...