1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-06-29 10:30:36 +00:00

Extends contextual menu to work with the Help system.

This commit is contained in:
FellippeHeitor 2021-01-09 00:51:22 -03:00
parent 4ed7a5b233
commit 6fb030b9ac

View file

@ -148,6 +148,7 @@ FUNCTION ide2 (ignore)
IF ideerror = 3 THEN errorat$ = "File access error": CLOSE #150
IF ideerror = 4 THEN errorat$ = "Path not found"
IF ideerror = 5 THEN errorat$ = "Cannot create folder"
IF ideerror = -1 THEN GOTO errorReportDone 'fail quietly - like ON ERROR RESUME NEXT
qberrorcode = ERR
IF qberrorcode THEN
@ -173,6 +174,7 @@ FUNCTION ide2 (ignore)
PCOPY 3, 0
idemessagebox ideerrormessageTITLE$, errorat$
errorReportDone:
END IF
IF (ideerror > 1) AND (AttemptToLoadRecent = -1) THEN
@ -989,45 +991,8 @@ FUNCTION ide2 (ignore)
'COLOR 0, 7: LOCATE idewy, (idewx - 6) / 2: PRINT " Help "
'create and draw back string
Back_Str$ = STRING$(1000, 0)
Back_Str_I$ = STRING$(4000, 0)
top = UBOUND(back$)
FOR x = 1 TO top
n$ = Back_Name$(x)
IF x = Help_Back_Pos THEN p = LEN(Back_Str$)
Back_Str$ = Back_Str$ + " "
Back_Str_I$ = Back_Str_I$ + MKL$(x)
FOR x2 = 1 TO LEN(n$)
Back_Str$ = Back_Str$ + CHR$(ASC(n$, x2))
Back_Str_I$ = Back_Str_I$ + MKL$(x)
NEXT
Back_Str$ = Back_Str$ + " "
Back_Str_I$ = Back_Str_I$ + MKL$(x)
GOSUB HelpAreaShowBackLinks
IF x <> top THEN
Back_Str$ = Back_Str$ + CHR$(0)
Back_Str_I$ = Back_Str_I$ + MKL$(0)
END IF
NEXT
Back_Str$ = Back_Str$ + STRING$(1000, 0)
Back_Str_I$ = Back_Str_I$ + STRING$(4000, 0)
Back_Str_Pos = p - idewx \ 2 + (LEN(Back_Name$(Help_Back_Pos)) + 2) \ 2 + 3
'COLOR 1, 2
'LOCATE idewy, 2: PRINT MID$(Back_Str$, Back_Str_Pos, idewx - 5)
LOCATE idewy, 2
FOR x = Back_Str_Pos TO Back_Str_Pos + idewx - 6
i = CVL(MID$(Back_Str_I$, (x - 1) * 4 + 1, 4))
a = ASC(Back_Str$, x)
IF a THEN
IF IdeSystem = 3 THEN COLOR 0, 7 ELSE COLOR 7, 0
IF i < Help_Back_Pos THEN COLOR 9
IF i > Help_Back_Pos THEN COLOR 9
PRINT CHR$(a);
ELSE
COLOR 7, 0
PRINT CHR$(196);
END IF
NEXT
'Help_Search_Str
IF IdeSystem = 3 AND LEFT$(IdeInfo, 1) <> CHR$(0) THEN
a$ = ""
@ -1869,6 +1834,10 @@ FUNCTION ide2 (ignore)
IdeSystem = 3
END IF
END IF
IF mCLICK2 THEN
GOTO invokecontextualmenu
END IF
END IF
END IF
@ -2040,6 +2009,9 @@ FUNCTION ide2 (ignore)
IF mX > 1 AND mX < idewx AND mY > 2 AND mY < (idewy - 5) THEN 'inside text box
IdeSystem = 1
IF mCLICK2 THEN GOTO invokecontextualmenu ELSE GOTO ideloop
ELSEIF mY >= idewy AND mY < idewy + idesubwindow THEN 'inside help
IdeSystem = 3
IF mCLICK2 THEN GOTO invokecontextualmenu ELSE GOTO ideloop
END IF
END IF
@ -2054,7 +2026,7 @@ FUNCTION ide2 (ignore)
'IF idesubwindow THEN PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt: GOTO ideloop
'idesubwindow = idewy \ 2: idewy = idewy - idesubwindow
closeHelp:
idewy = idewy + idesubwindow
idehelp = 0
idesubwindow = 0
@ -2127,6 +2099,7 @@ FUNCTION ide2 (ignore)
IF ((KCTRL AND KB = KEY_INSERT) OR (KCONTROL AND UCASE$(K$) = "C")) AND Help_Select = 2 THEN 'copy to clipboard
copyhelp2clip:
ideerror = -1 'if it fails, just carry on
clip$ = ""
FOR y = Help_SelY1 TO Help_SelY2
IF y <> Help_SelY1 THEN clip$ = clip$ + CHR$(13) + CHR$(10)
@ -2151,6 +2124,7 @@ FUNCTION ide2 (ignore)
NEXT
IF Help_SelY1 = Help_SelY2 AND Help_cy > Help_cy1 THEN clip$ = clip$ + CHR$(13) + CHR$(10)
IF clip$ <> "" THEN _CLIPBOARD$ = clip$
ideerror = 1
GOTO keep_select
END IF
@ -2898,6 +2872,7 @@ FUNCTION ide2 (ignore)
IF mCLICK2 THEN 'Second mouse button pressed.
invokecontextualmenu:
IF mX > 1 + maxLineNumberLength AND mX < idewx AND mY > 2 AND mY < (idewy - 5) THEN 'inside text box
IdeSystem = 1
IF ideselect = 0 THEN 'Right click only positions the cursor if no selection is active
idecx = (mX - 1 + idesx - 1) - maxLineNumberLength
idecy = mY - 2 + idesy - 1
@ -2924,16 +2899,12 @@ FUNCTION ide2 (ignore)
idecx = (mX - 1 + idesx - 1) - maxLineNumberLength
idecy = mY - 2 + idesy - 1
IF idecy > iden THEN idecy = iden
ideshowtext
PCOPY 3, 0
END IF
IF mY - 2 + idesy - 1 < idecy OR mY - 2 + idesy - 1 > idecy THEN
ideselect = 0
idecx = (mX - 1 + idesx - 1) - maxLineNumberLength
idecy = mY - 2 + idesy - 1
IF idecy > iden THEN idecy = iden
ideshowtext
PCOPY 3, 0
END IF
END IF
ELSE 'Multiple lines selected
@ -2946,11 +2917,18 @@ FUNCTION ide2 (ignore)
idecx = (mX - 1 + idesx - 1) - maxLineNumberLength
idecy = mY - 2 + idesy - 1
IF idecy > iden THEN idecy = iden
ideshowtext
END IF
END IF
END IF
GOSUB redrawitall
PCOPY 3, 0
idecontextualmenu = 1
IdeMakeContextualMenu
GOTO showmenu
ELSEIF idehelp = 1 AND mY >= idewy AND mY < idewy + idesubwindow THEN 'inside help area
IdeSystem = 3
GOSUB redrawitall
PCOPY 3, 0
END IF
END IF
END IF
idecontextualmenu = 1
IdeMakeContextualMenu
GOTO showmenu
@ -4381,7 +4359,8 @@ FUNCTION ide2 (ignore)
END IF
IF mCLICK2 AND idecontextualmenu = 1 THEN 'A new right click in the text area repositions the contextual menu
IF mX > 1 AND mX < idewx AND mY > 2 AND mY < (idewy - 5) THEN
IF (mX > 1 AND mX < idewx AND mY > 2 AND mY < (idewy - 5)) OR _
(mY >= idewy AND mY < idewy + idesubwindow) THEN
PCOPY 3, 0: SCREEN , , 3, 0
GOTO invokecontextualmenu
ELSE
@ -5533,6 +5512,11 @@ FUNCTION ide2 (ignore)
IF IdeSystem = 3 THEN GOTO selectAllInHelp
END IF
IF menu$(m, s) = "Clo#se Help ESC" THEN
PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt
GOTO closeHelp
END IF
IF menu$(m, s) = "#Start F5" THEN
PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt
GOTO idemrun
@ -5907,6 +5891,15 @@ FUNCTION ide2 (ignore)
DEF SEG = 0
ideshowtext
IF idehelp THEN
Help_ShowText
q = idehbar(2, idewy + idesubwindow - 1, idewx - 2, Help_cx, help_w + 1)
q = idevbar(idewx, idewy + 1, idesubwindow - 2, Help_cy, help_h + 1)
GOSUB HelpAreaShowBackLinks
END IF
IF IDEShowErrorsImmediately OR IDECompilationRequested THEN
COLOR 7, 1: LOCATE idewy - 3, 2: PRINT SPACE$(idewx - 2);: LOCATE idewy - 2, 2: PRINT SPACE$(idewx - 2);: LOCATE idewy - 1, 2: PRINT SPACE$(idewx - 2); 'clear status window
@ -5915,8 +5908,12 @@ FUNCTION ide2 (ignore)
LOCATE idewy - 3, 2
IF idecompiling = 1 THEN
PRINT "...";
ELSE
IF idefocusline THEN
PRINT "...";
ELSE
PRINT "OK"; 'report OK status
END IF
statusarealink = 0
IF totalWarnings > 0 THEN
COLOR 11, 1
@ -5928,6 +5925,49 @@ FUNCTION ide2 (ignore)
END IF
END IF
RETURN
HelpAreaShowBackLinks:
Back_Str$ = STRING$(1000, 0)
Back_Str_I$ = STRING$(4000, 0)
top = UBOUND(back$)
FOR x = 1 TO top
n$ = Back_Name$(x)
IF x = Help_Back_Pos THEN p = LEN(Back_Str$)
Back_Str$ = Back_Str$ + " "
Back_Str_I$ = Back_Str_I$ + MKL$(x)
FOR x2 = 1 TO LEN(n$)
Back_Str$ = Back_Str$ + CHR$(ASC(n$, x2))
Back_Str_I$ = Back_Str_I$ + MKL$(x)
NEXT
Back_Str$ = Back_Str$ + " "
Back_Str_I$ = Back_Str_I$ + MKL$(x)
IF x <> top THEN
Back_Str$ = Back_Str$ + CHR$(0)
Back_Str_I$ = Back_Str_I$ + MKL$(0)
END IF
NEXT
Back_Str$ = Back_Str$ + STRING$(1000, 0)
Back_Str_I$ = Back_Str_I$ + STRING$(4000, 0)
Back_Str_Pos = p - idewx \ 2 + (LEN(Back_Name$(Help_Back_Pos)) + 2) \ 2 + 3
'COLOR 1, 2
'LOCATE idewy, 2: PRINT MID$(Back_Str$, Back_Str_Pos, idewx - 5)
LOCATE idewy, 2
FOR x = Back_Str_Pos TO Back_Str_Pos + idewx - 6
i = CVL(MID$(Back_Str_I$, (x - 1) * 4 + 1, 4))
a = ASC(Back_Str$, x)
IF a THEN
IF IdeSystem = 3 THEN COLOR 0, 7 ELSE COLOR 7, 0
IF i < Help_Back_Pos THEN COLOR 9
IF i > Help_Back_Pos THEN COLOR 9
PRINT CHR$(a);
ELSE
COLOR 7, 0
PRINT CHR$(196);
END IF
NEXT
RETURN
END FUNCTION
SUB idebox (x, y, w, h)
@ -5949,14 +5989,14 @@ SUB ideboxshadow (x, y, w, h)
COLOR 2, 0
FOR y2 = y + 1 TO y + h - 1
FOR x2 = x + w TO x + w + 1
IF x2 <= idewx AND y2 <= idewy THEN
IF x2 <= idewx AND y2 <= idewy + idesubwindow THEN
LOCATE y2, x2: PRINT CHR$(SCREEN(y2, x2));
END IF
NEXT
NEXT
y2 = y + h
IF y2 <= idewy THEN
IF y2 <= idewy + idesubwindow THEN
FOR x2 = x + 2 TO x + w + 1
IF x2 <= idewx THEN
LOCATE y2, x2: PRINT CHR$(SCREEN(y2, x2));
@ -7775,6 +7815,7 @@ FUNCTION idenewfolder$(thispath$)
END IF
ideerror = 5
MKDIR thispath$ + idepathsep$ + idetxt(o(1).txt)
ideerror = 1
idenewfolder$ = idetxt(o(1).txt)
EXIT SUB
END IF
@ -9037,7 +9078,7 @@ SUB ideshowtext
NEXT m
'apply selection color change if necessary
IF IdeSystem = 1 AND ideselect <> 0 THEN
IF (IdeSystem = 1 OR IdeSystem = 2) AND ideselect <> 0 THEN
IF l >= sy1 AND l <= sy2 THEN
IF sy1 = sy2 THEN 'single line select
COLOR 1, 7
@ -14217,6 +14258,7 @@ SUB IdeMakeContextualMenu
m = idecontextualmenuID: i = 0
menu$(m, i) = "Contextual": i = i + 1
IF IdeSystem = 1 OR IdeSystem = 2 THEN
'Figure out if the user wants to search for a selected term -- copied from idefind$
IF ideselect THEN
IF ideselecty1 = idecy THEN 'single line selected
@ -14421,9 +14463,8 @@ SUB IdeMakeContextualMenu
NoRGBFound:
'--------- _RGB mixer check done. --------------------------------------------
IF (IdeSystem = 1 AND ideselect <> 0) THEN menu$(m, i) = "Cu#t Shift+Del or Ctrl+X": i = i + 1
IF (IdeSystem = 1 AND ideselect = 1) OR _
(IdeSystem = 3 AND Help_Select = 2) THEN
IF (ideselect <> 0) THEN menu$(m, i) = "Cu#t Shift+Del or Ctrl+X": i = i + 1
IF (ideselect = 1) THEN
menu$(m, i) = "#Copy Ctrl+Ins or Ctrl+C": i = i + 1
END IF
@ -14466,6 +14507,14 @@ SUB IdeMakeContextualMenu
END IF
menu$(m, i) = "New #SUB...": i = i + 1
menu$(m, i) = "New #FUNCTION...": i = i + 1
ELSEIF IdeSystem = 3 THEN
IF (Help_Select = 2) THEN
menu$(m, i) = "#Copy Ctrl+Ins or Ctrl+C": i = i + 1
END IF
menu$(m, i) = "Select #All Ctrl+A": i = i + 1
menu$(m, i) = "-": i = i + 1
menu$(m, i) = "Clo#se Help ESC": i = i + 1
END IF
menusize(m) = i - 1
END SUB