@Kevin
I found a new solution:
As a prerequisite, the text cursor is placed at the end of the first line of the subfunction (red arrow in the image)
then I can get the position of the beginning of the line where the cursor is (blue arrow in the figure)
then through the Find function, navigate to the beginning of the next # line (Pink arrow in the figure), It can be a bit complicated to implement
then Create a text area between two # lines (from the red arrow to the pink arrow)
Finally, I can copy and replace the text
There are two related functions that follow for reference, and I don't have the ability to implement full functionality at the moment
I found a private function SciGetSelText in QM's system folder
The code is as follows:
I define the function SciGetCurLineText
It can get the text of the line where the cursor is located
I found a new solution:
As a prerequisite, the text cursor is placed at the end of the first line of the subfunction (red arrow in the image)
then I can get the position of the beginning of the line where the cursor is (blue arrow in the figure)
then through the Find function, navigate to the beginning of the next # line (Pink arrow in the figure), It can be a bit complicated to implement
then Create a text area between two # lines (from the red arrow to the pink arrow)
Finally, I can copy and replace the text
There are two related functions that follow for reference, and I don't have the ability to implement full functionality at the moment
I found a private function SciGetSelText in QM's system folder
The code is as follows:
#sub SciGetSelText
function# h str&s ;;Returns sel start. If h 0, calls GetQmCodeEditor.
if(!h) h=GetQmCodeEditor
TEXTRANGE t
t.chrg.cpMin=SendMessage(h SCI.SCI_GETSELECTIONSTART 0 0)
t.chrg.cpMax=SendMessage(h SCI.SCI_GETSELECTIONEND 0 0)
t.lpstrText=s.all(t.chrg.cpMax-t.chrg.cpMin)
s.fix(SendMessage(h SCI.SCI_GETTEXTRANGE 0 &t))
ret t.chrg.cpMin
I define the function SciGetCurLineText
It can get the text of the line where the cursor is located
out
int j=sub.SciGetCurLineText(0 str'ls)
out ls
;
;str s="bbb"
;SendMessage(h SCI.SCI_REPLACESEL 0 s)
#sub SciGetCurLineText
function# h str&s ;;Returns the text of the line where the current cursor is located. If h 0, calls GetQmCodeEditor.
if(!h) h=GetQmCodeEditor
TEXTRANGE t
int cp=SendMessage(h SCI.SCI_GETCURRENTPOS 0 0)
int lineN=SendMessage(h SCI.SCI_LINEFROMPOSITION cp 0)
int lineLen=SendMessage(h SCI.SCI_LINELENGTH lineN 0)
int lineEnd=SendMessage(h SCI.SCI_GETLINEENDPOSITION lineN 0)
t.chrg.cpMin=lineEnd-lineLen+2
t.chrg.cpMax=lineEnd
t.lpstrText=s.all(t.chrg.cpMax-t.chrg.cpMin)
s.fix(SendMessage(h SCI.SCI_GETTEXTRANGE 0 &t))
ret t.chrg.cpMin