From c0d08c204477d5959f811da3f50cd6866f1f1b80 Mon Sep 17 00:00:00 2001 From: Roland Heyder Date: Tue, 10 Sep 2024 22:45:56 +0200 Subject: [PATCH] Export enhancement The "Export As ..." feature now checks for an active selection first. Only if no selection was made, then the entire loaded source file will be exported as usual. --- source/ide/ide_methods.bas | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index a2253a543..50a86cc12 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -20668,21 +20668,23 @@ SUB ExportCodeAs (docFormat$) IF INSTR(_OS$, "[LINUX]") = 0 THEN cEol$ = CHR$(13) + cEol$ '------------------------------ PCOPY 3, 2: SCREEN , , 3, 0 - sTxt$ = "" ' '=> source code text - FOR i& = 1 TO iden - sTxt$ = sTxt$ + idegetline(i&) + cEol$ - perc$ = str2$(INT(30 / iden * i&)) - IdeInfo = CHR$(0) + STRING$(3 - LEN(perc$), 32) + perc$ + "% exported..." - UpdateIdeInfo - NEXT i& - WHILE RIGHT$(sTxt$, LEN(cEol$)) = cEol$ 'normalize line feeds at EOF - sTxt$ = LEFT$(sTxt$, LEN(sTxt$) - LEN(cEol$)) - WEND + sTxt$ = getSelectedText$(-1) '=> source code text (current selection) + IF sTxt$ = "" THEN + FOR i& = 1 TO iden ' '=> get full source, if no selection was made + sTxt$ = sTxt$ + idegetline(i&) + cEol$ + perc$ = str2$(INT(30 / iden * i&)) + IdeInfo = CHR$(0) + STRING$(3 - LEN(perc$), 32) + perc$ + "% exported..." + UpdateIdeInfo + NEXT i& + WHILE RIGHT$(sTxt$, LEN(cEol$)) = cEol$ 'normalize line feeds at EOF + sTxt$ = LEFT$(sTxt$, LEN(sTxt$) - LEN(cEol$)) + WEND + END IF IF sTxt$ = "" THEN sTxt$ = sTxt$ + cEol$: ELSE sTxt$ = sTxt$ + cEol$ + cEol$ - sLen& = LEN(sTxt$) ' '=> source code length - sPos& = 1 ' '=> source code read position - eTxt$ = SPACE$(1000000) '=> export text buffer - ePos& = 1 ' '=> export text buffer write position + sLen& = LEN(sTxt$) ' '=> source code length + sPos& = 1 ' '=> source code read position + eTxt$ = SPACE$(1000000) ' '=> export text buffer + ePos& = 1 ' '=> export text buffer write position '---------- post% = 0 ''=> GOSUB argument = 0/-1 (close pre current / post current char) what$ = "" '=> GOSUB argument = command descriptor