Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scintilla control modifies line text and Lexer
#1
Hi,

The following code, I can:
1.Use the hotkey Ctrl+Q to add // to the beginning of the current line
2.Use the hotkey Alt+Q to Replace the text of the current line
But it's not perfect. It flashes during execution. Can it be executed in the background without selecting the line text?

In addition, Can i use Scintilla control built-in language Lexer(Keywords auto coloring, As shown in the picture below)? Can anyone provide an example?
[Image: 1676708532]

I want to switch different code coloring Lexer schemes by pushing buttons, As shown in the picture below​​​​​​​
[Image: 1676708486]
Thanks in advance for any advice and help
david


Macro Macro5
Code:
Copy      Help
;
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 384 240 "Dialog" "4"
;3 Scintilla 0x54000000 0x20000 8 8 368 206 ""
;4 Button 0x54032000 0x0 40 220 48 14 "C# Lexer"
;5 Button 0x54032000 0x0 104 220 48 14 "QM Lexer"
;6 Button 0x54032000 0x4 168 220 70 14 "Powershell  Lexer"
;1 Button 0x54030001 0x4 268 220 48 14 "OK"
;2 Button 0x54030000 0x4 328 220 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040C02 "*" "" "" ""

str controls="3"
str cs3
cs3=
;using System;
;namespace HelloWorld
;{
;,/// <summary>
;,/// Summary description for Class1.
;,/// </summary>
;,class HelloWorldClass
;,{
;,,static void Main(string[] args)
;,,{
;,,,Console.WriteLine("Hello World!");
;,,,Console.ReadLine();
;,,}
;,}
;}

str qm3.getmacro

str ps3=
;$Hash = @{ }
;$Hash = @{ a = 1; b = 2; c = 3 }
;$Hash.Add('d', 4)
;$Hash.ContainsKey('d')
;$Hash['d']
;$Hash.GetEnumerator() | Sort-Object Name

int sci

if(!ShowDialog(dd &sub.DlgProc 0)) ret


#sub DlgProc v
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,DT_SetAccelerators(hDlg "401 Cq[]402 Aq")
,sci=id(3 hDlg)
,sub.SetText cs3
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 401 ;;Ctrl+Q: add //
,sub.Sci(SCI.SCI_MOVESELECTEDLINESDOWN 0 0)
,sub.Sci(SCI.SCI_MOVESELECTEDLINESUP 0 0)
,_s.getsel
,_s-"//"
,_s.setsel
,
,case 402 ;;Alt+Q:  Modify the current line text
,sub.Sci(SCI.SCI_MOVESELECTEDLINESDOWN 0 0)
,sub.Sci(SCI.SCI_MOVESELECTEDLINESUP 0 0)
,_s.getsel
,_s=
,;hello world
,_s+"[]"
,_s.setsel
,
,case 4 ;;C# Lexer
,sub.SetText cs3
,
,case 5 ;;QM Lexer
,sub.SetText qm3
,
,case 6 ;;Powershell Lexer
,sub.SetText ps3

ret 1

#sub Sci v
function# message [param1] [param2]
ret SendMessage(sci message param1 param2)

#sub Sci2 v
function# message [param1] [$text]
ret SendMessage(sci message param1 text)

#sub GetText v
function str&text
int n=SendMessage(sci SCI.SCI_GETTEXTLENGTH 0 0)
text.fix(SendMessage(sci SCI.SCI_GETTEXT n+1 text.all(n)))

#sub SetText v
function $text
sub.Sci2(SCI.SCI_SETTEXT 0 text)


Messages In This Thread
Scintilla control modifies line text and Lexer - by Davider - 02-15-2023, 07:42 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)