Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[Wrapper] Scintilla Wrapper v1.4.2.4


  • Please log in to reply
122 replies to this topic
maestrith
  • Members
  • 786 posts
  • Last active: Apr 10 2019 01:28 PM
  • Joined: 17 Sep 2005

Thanks Maestrith, this is the same as I get.

Thanks for a link to your AHK Studio, what a great tool. I tried both versions and imported all available themes. Unfortunately HatofGod theme looks the same as on the picture above, missing many colors. Also Default theme only have mostly blue and red colors and nothing else. Muted light theme looks ok, like on picture. Do you experience the same?

I have also noticed a very small Lexer file was downloaded on AHK Studio startup. What's the difference to the file from this wrapper?

Could anyone post a working script with working colors? thanks.

The lexer that is downloaded with AHK Studio is my compiled version.  I removed all of the folding and changed a few things as far as the custom coloring is concerned.



okram
  • Members
  • 230 posts
  • Last active: Oct 15 2015 05:55 AM
  • Joined: 05 Oct 2012

Hi, I finally got it working for me. Few questions

- is it possible to change the border of the scintilla (flat or no border)? I tried

sci := new scintilla(WinExist(),-1,-1,700,700,"SciLexer.dll")

- must be obvious but I cannot find a command to change the text background color, the one I found only changes the color of the background with no characters. I tried

sci.StyleSetBack(32, "0x000000")

Thanks, any input is highly appreciated!



okram
  • Members
  • 230 posts
  • Last active: Oct 15 2015 05:55 AM
  • Joined: 05 Oct 2012

Unfortunately I still cannot find a way to change the border of the scintilla. Is it possible to have the border flat or no border?

Thanks for any help!



RaptorX
  • Members
  • 751 posts
  • Last active: Feb 19 2015 02:47 AM
  • Joined: 19 Feb 2010

Hi, I finally got it working for me. Few questions
- is it possible to change the border of the scintilla (flat or no border)? I tried

sci := new scintilla(WinExist(),-1,-1,700,700,"SciLexer.dll")
- must be obvious but I cannot find a command to change the text background color, the one I found only changes the color of the background with no characters. I tried
sci.StyleSetBack(32, "0x000000")
Thanks, any input is highly appreciated!

 
The last parameter of the wrapper allows you to play with window styles, are you trying to add a border or to remove it? because by default my wrapper does not add a border to the component, if you want to add a border you would have to do this:

sci := new scintilla(WinExist(),-1,-1,700,700,"SciLexer.dll", "BORDER")
AutoHotkey Toolkit [Main Project]
Scintilla Wrapper
LexAHKL

okram
  • Members
  • 230 posts
  • Last active: Oct 15 2015 05:55 AM
  • Joined: 05 Oct 2012

Thanks for your answer. When I put a scintilla into my gui I see a border around it, it is not a thin line but a kind of 3d border with some depth. I would like to get rid of this and only use a simple flat border like a regular gui edit control (or no border ar all).

Example:

#include ..\SCI.ahk
#singleinstance force

Gui +LastFound
sci := new scintilla(WinExist(), 0, 0, 500, 300, A_ScriptDir "\SciLexer.dll" )

Gui, show, w600 h400
return

I like your wrapper very much! Thanks!



RaptorX
  • Members
  • 751 posts
  • Last active: Feb 19 2015 02:47 AM
  • Joined: 19 Feb 2010
Ah now I know what you are referring to... go to the SCI.ahk file and go to line 268. remove "WS_EX_CLIENTEDGE" and replace it with a 0...
I have the wrapper add that 3D sunken edge to blend a bit with the other controls.

try this:

#include ..\SCI.ahk
#singleinstance force

Gui +LastFound
sci := new scintilla(WinExist(), 10, 0, 200, 200, a_scripdir "\SciLexer.dll")

gui add, edit, w200 h200 y210
Gui, show, w600 h900
return
once with the WS_EX_CLIENTEDGE that i mentioned and one with that value set to 0 and see the difference.
AutoHotkey Toolkit [Main Project]
Scintilla Wrapper
LexAHKL

okram
  • Members
  • 230 posts
  • Last active: Oct 15 2015 05:55 AM
  • Joined: 05 Oct 2012

Thank you very much for this info, very helpful!

 

May I use the opportunity and ask one more? My idea was to have a border which would look exactly like the edit regular control, so I tried to put scintilla under edit control. It looks ok, but is this a correct usage? The only problem I found with this is that Ctrl-A (select all) shortcut is not working. Any workaround? Also border is not getting blue cast when focused. Any other pros/cons? Am I doing it right? MyEdit associated variable of edit control is probably not useful? Thanks a lot for the great wrapper!

#include ..\SCI.ahk
#singleinstance force

Gui, Add, Edit, w200 h200 hwndEdd -VScroll -HScroll vMyEdit
Gui, +LastFound
sci := new scintilla(Edd,-2,-2,200,200,"SciLexer.dll")
sci.GrabFocus()

gui add, edit, w200 h200 x10 y210
Gui, show, w600 h900
return
f6::exitapp


RaptorX
  • Members
  • 751 posts
  • Last active: Feb 19 2015 02:47 AM
  • Joined: 19 Feb 2010
This is not a good way to fix that. As far a I know there is no way to make a custom component like scintilla to look *exactly the same* as the default windows edit control.
but you might want to make it look similar by taking away the horizontal bar and the gray margin like this:

#include ..\SCI.ahk
#singleinstance force

Gui +LastFound

sci := new scintilla(WinExist(), 10, 0, 200, 200, a_scriptdir "\SciLexer.dll")

sci.setwrapmode(true) ; this removes the horizontal scrollbar
sci.SetMarginWidthN(1, 0) ; this removes the left margin

Gui, show, w210 h210
return
This will look very similar to the standard edit control and nobody would probably note the difference unless you use any of the advanced options of scintilla.
AutoHotkey Toolkit [Main Project]
Scintilla Wrapper
LexAHKL

okram
  • Members
  • 230 posts
  • Last active: Oct 15 2015 05:55 AM
  • Joined: 05 Oct 2012

Hi, thanks again for this great wrapper.

 

I have one question regarding Scintilla and Unicode use. I can show Unicode characters in scintilla by using sci.SETCODEPAGE(65001) but when I retrieve a text from it I always get strange characters. I'm using Ahk_L 32bit Unicode.

 

How can the Unicode text be retrieved from Scintilla? I would be grateful for any help.

sci.SETCODEPAGE(65001)
sci.SETKEYSUNICODE(1)

sci.GetText(sci.getLength()+1, String)
msgbox %String%   ;get strange characters


okram
  • Members
  • 230 posts
  • Last active: Oct 15 2015 05:55 AM
  • Joined: 05 Oct 2012

Here is an example. Whatever I do, I cannot pass Unicode string to Scintilla (get ??? characters instead). Writing Unicode characters into scintilla works well.

What am I missing in the code below?

#include SCI.ahk
#singleinstance force

String:="Поздрав!"
msgbox %String% - works

Gui +LastFound
sci := new scintilla(WinExist())

sci.SETCODEPAGE(65001)
sci.SETKEYSUNICODE(1)
sci.SetWrapMode(true)

sci.SetText(unused, String)   ;passing string to scintilla

Gui, show, w600 h400
return


GuiClose:
    ExitApp





okram
  • Members
  • 230 posts
  • Last active: Oct 15 2015 05:55 AM
  • Joined: 05 Oct 2012

I'm posting my question again if someone could help me with the idea how to make this Scintilla Wrapper work with Unicode characters.

 

I'm using Ahk_L 32bit Unicode but the following script does not work - Scintilla does not show Unicode characters. Any help is much appreciated, thanks.

#include SCI.ahk
#singleinstance force

String:="Поздрав!"
msgbox %String% - works

Gui +LastFound
sci := new scintilla(WinExist())
sci.SetWrapMode(true)
sci.SetText(unused, String) ;passing string to scintilla
Gui, show, w600 h400
return

GuiClose:
ExitApp


RobertL
  • Members
  • 15 posts
  • Last active: Sep 25 2014 08:48 AM
  • Joined: 08 Oct 2013

I alos write the issue below at Github, it's a little easier to read.
 


in Examples\5-get_text.ahk
For example, when use sci.SetText(unused, "2 ") in line 16, it raise 3 error:

  • The following variable name contains an illegal character"2 " in Line 333,
  • sci.GetText(sci.getLength()+1, myvar) return 1 in myvar,
  • "2 “ doesn't set to Sci's content.
Another problem. I try to migrate to AHK V2, althogh there is not much different.There is my fork (I'm an beginner).
But I must change and use lParam in buf ? (lParam := StrGet((msg = "GetTextRange") ? blParam : lParam, "CP0"), buf:=false) : null in line 85 within function __call, while it has to be &lParam.
  • In original V1, lParam is a address befor __sendEditor(this.hwnd, "GetText", Length, lParam), and a string buffer after?
  • In V2, lParam is address. I don't konw why?!
The error above is bound up with the lParam problem. Test other value such as  `sci.SetText(unused, "22")`.
Please help~

BTW, I replace %lParam%+0 with (- - lParam!=lParam and %lParam%+0) in Line 333, this also works in AHK V2.

 

↓Same as Github.


I happen to meet this problem when testing. I find and give the use case intentionally to expose issue.
In other case (eg. the text has more characters) everything works fine.
 
The 1st error (variable name contains an illegal character) is caused by %lParam%+0 (lParam="2 ").
I use - - lParam!=lParam to filter out number, which can't start with a digit in var name in V2.
 
What confused me more is the lParam problem. The error above is related to it.
For examplesci.SetText(unused, "t "), its phenomenon is representativ.
When GetTexting, StrGet(lParam, "CP0") return the expected value "t " (that was I wonder and made in V2 using lParam), and in original, it use StrGet(&lParam, "CP0"), so the result is "1" (the 2nd error mentioned above).
 
 
I replace %hwnd%_df to df_%hwnd% for the var name case in V2.
Also I want to ask, in form of %x%+0 ? %x% : xx may only be used for reffering ‘global scintilla variables’, and is read only? (eg. use "SCI_ADDTEXT" name or SCI_ADDTEXT(2001) id)
Or, x may be any var name writing and reading when runtime? ( Like %hwnd%_dfdf_%hwnd%)

My lParam/&lParam problem may be lParam:= &lParam, USE lParam:= &lParamA(and VarSetCapacity(lParamA,..)) See this. I will test.


Edited by RobertL, 13 June 2014 - 05:45 AM.


RaptorX
  • Members
  • 751 posts
  • Last active: Feb 19 2015 02:47 AM
  • Joined: 19 Feb 2010

Hi there,

 

I was testing and found that if you remove the space at the end it doesnt provoke that error.
I will continue checking to see what is going on.

I still have the issue with the control not being set.

I have not seen any issue if the text has more characters or if it is only text though, are you having other issues besides this?

 

What is more likely going on is that if you only put numbers the wrapper is mistaking it with a pointer.
I will have to fix that.


AutoHotkey Toolkit [Main Project]
Scintilla Wrapper
LexAHKL

Ex0rpl4net
  • Members
  • 87 posts
  • Last active: Jun 25 2015 01:09 PM
  • Joined: 14 May 2013

Hi there,

 

I was testing and found that if you remove the space at the end it doesnt provoke that error.
I will continue checking to see what is going on.

I still have the issue with the control not being set.

I have not seen any issue if the text has more characters or if it is only text though, are you having other issues besides this?

 

What is more likely going on is that if you only put numbers the wrapper is mistaking it with a pointer.
I will have to fix that.

hey,im trying to get the line number i am currently working on, i tred messing around with "sci.GETCURLINE" but its giving me the line's contents and not its number

 

1| line 1

2| line 2  |if im currently editing this line i want the function to return "2" and i dont know how to do it

3| line 3



maestrith
  • Members
  • 786 posts
  • Last active: Apr 10 2019 01:28 PM
  • Joined: 17 Sep 2005

hey,im trying to get the line number i am currently working on, i tred messing around with "sci.GETCURLINE" but its giving me the line's contents and not its number

 

1| line 1

2| line 2  |if im currently editing this line i want the function to return "2" and i dont know how to do it

3| line 3

to get your current line you need to do a SCI_GETCURRENTPOS and then pass that to SCI_LINEFROMPOSITION(int pos) 

This will return a 0 based value (line 1=0 line 23=22..etc)