From 8d1b9374da6bc640147e4e59942562efe12928f3 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Tue, 26 Jun 2018 00:25:47 -0300 Subject: [PATCH] Fixes #69. --- InForm/InForm.ui | 43 ++++++++++++++++++++++++++++++++------ InForm/UiEditorPreview.bas | 42 ++++--------------------------------- InForm/xp.uitheme | 2 ++ 3 files changed, 43 insertions(+), 44 deletions(-) diff --git a/InForm/InForm.ui b/InForm/InForm.ui index d7aedfc..89f6176 100644 --- a/InForm/InForm.ui +++ b/InForm/InForm.ui @@ -1290,6 +1290,7 @@ SUB __UI_UpdateDisplay IF __UI_ActiveTipID > 0 THEN IF __UI_ActiveTipID <> __UI_PreviousTipID OR ToolTip(__UI_ActiveTipID) <> __UI_TempTips(__UI_ActiveTipID) THEN __UI_PreviousTipID = __UI_ActiveTipID + ToolTip(__UI_ActiveTipID) = RestoreCHR$(ToolTip(__UI_ActiveTipID)) __UI_TempTips(__UI_ActiveTipID) = ToolTip(__UI_ActiveTipID) DIM ThisLine%, TextTop%, Temp& @@ -4398,7 +4399,7 @@ SUB SetCaption (ThisID AS LONG, TempCaption$) IF ThisID = 0 THEN EXIT SUB - NewCaption$ = TempCaption$ + NewCaption$ = RestoreCHR$(TempCaption$) 'Parse for hotkey markers StartSearchForSep: @@ -4846,16 +4847,14 @@ FUNCTION __UI_GetTextBoxLine$ (id AS LONG, LineNumber AS LONG, StartPosition AS END FUNCTION '--------------------------------------------------------------------------------- -SUB AddItem (WhichListBox AS LONG, Item$) +SUB AddItem (WhichListBox AS LONG, TempItem$) DIM ThisID AS LONG, prevFont AS LONG - DIM BorderOffset AS INTEGER + DIM BorderOffset AS INTEGER, Item$ ThisID = WhichListBox IF Control(ThisID).Type <> __UI_Type_ListBox AND Control(ThisID).Type <> __UI_Type_DropdownList THEN EXIT SUB - DO WHILE INSTR(Item$, CHR$(13)) > 0 - MID$(Item$, INSTR(Item$, CHR$(13)), 1) = CHR$(10) - LOOP + Item$ = Replace$(RestoreCHR$(TempItem$), CHR$(13), CHR$(10), False, 0) Text(ThisID) = Text(ThisID) + Item$ + CHR$(13) Control(ThisID).Max = Control(ThisID).Max + 1 @@ -5895,6 +5894,38 @@ FUNCTION IconPreview& (IconFile$) END IF END FUNCTION +FUNCTION RestoreCHR$ (__Text$) + DIM Text$, i AS LONG, BackSlash AS LONG, SemiColon AS LONG + DIM j AS LONG, tempNum$ + + Text$ = __Text$ + + IF INSTR(Text$, "\") = 0 THEN + RestoreCHR$ = Text$ + EXIT FUNCTION + END IF + + DO + BackSlash = INSTR(BackSlash + 1, Text$, "\") + IF BackSlash = 0 THEN EXIT DO + + SemiColon = INSTR(BackSlash + 1, Text$, ";") + IF SemiColon = 0 THEN _CONTINUE + + tempNum$ = "" + FOR j = BackSlash + 1 TO SemiColon - 1 + IF ASC(Text$, j) < 48 OR ASC(Text$, j) > 57 THEN tempNum$ = "": EXIT FOR + tempNum$ = tempNum$ + MID$(Text$, j, 1) + NEXT + + IF LEN(tempNum$) THEN + Text$ = LEFT$(Text$, BackSlash - 1) + CHR$(VAL(tempNum$)) + MID$(Text$, SemiColon + 1) + END IF + LOOP + + RestoreCHR$ = Text$ +END FUNCTION + 'Control types: FUNCTION __UI_Type_Form%%:__UI_Type_Form%% = 1: END FUNCTION FUNCTION __UI_Type_Frame%%: __UI_Type_Frame%% = 2: END FUNCTION diff --git a/InForm/UiEditorPreview.bas b/InForm/UiEditorPreview.bas index da27df4..9acb9d2 100644 --- a/InForm/UiEditorPreview.bas +++ b/InForm/UiEditorPreview.bas @@ -2254,12 +2254,11 @@ SUB LoadPreviewText 'Caption DummyText$ = nextParameter(b$) 'discard first parameter DummyText$ = nextParameter(b$) - DummyText$ = RestoreCHRfromEscapeCode$(DummyText$) SetCaption TempValue, DummyText$ ELSEIF LEFT$(b$, 8) = "AddItem " THEN 'Caption DummyText$ = nextParameter(b$) 'discard first parameter - DummyText$ = RestoreCHRfromEscapeCode(nextParameter(b$)) + DummyText$ = nextParameter(b$) AddItem TempValue, DummyText$ ELSEIF LEFT$(b$, 10) = "LoadImage " THEN 'Image @@ -2269,12 +2268,12 @@ SUB LoadPreviewText ELSEIF LEFT$(b$, 22) = "ToolTip(__UI_NewID) = " THEN 'Tooltip DummyText$ = MID$(b$, INSTR(b$, " = ") + 3) - DummyText$ = RestoreCHRfromEscapeCode$(DummyText$) + DummyText$ = RestoreCHR$(DummyText$) ToolTip(TempValue) = removeQuotation$(DummyText$) ELSEIF LEFT$(b$, 19) = "Text(__UI_NewID) = " THEN 'Text DummyText$ = MID$(b$, INSTR(b$, " = ") + 3) - DummyText$ = RestoreCHRfromEscapeCode$(DummyText$) + DummyText$ = RestoreCHR$(DummyText$) Text(TempValue) = removeQuotation$(DummyText$) IF Control(TempValue).Type = __UI_Type_PictureBox OR Control(TempValue).Type = __UI_Type_Button THEN @@ -2289,7 +2288,7 @@ SUB LoadPreviewText ELSEIF LEFT$(b$, 19) = "Mask(__UI_NewID) = " THEN 'Mask DummyText$ = MID$(b$, INSTR(b$, " = ") + 3) - DummyText$ = RestoreCHRfromEscapeCode$(DummyText$) + DummyText$ = RestoreCHR$(DummyText$) Mask(TempValue) = removeQuotation$(DummyText$) ELSEIF INSTR(b$, "__UI_NewControl") > 0 THEN 'New Control @@ -2983,36 +2982,3 @@ SUB LoadDefaultFonts Control(__UI_FormID).Font = SetFont("InForm/resources/NotoMono-Regular.ttf", 12) END IF END SUB - -FUNCTION RestoreCHRfromEscapeCode$ (__Text$) - DIM Text$, i AS LONG, BackSlash AS LONG, SemiColon AS LONG - DIM j AS LONG, tempNum$ - - Text$ = __Text$ - - IF INSTR(Text$, "\") = 0 THEN - RestoreCHRfromEscapeCode$ = Text$ - EXIT FUNCTION - END IF - - DO - BackSlash = INSTR(BackSlash + 1, Text$, "\") - IF BackSlash = 0 THEN EXIT DO - - SemiColon = INSTR(BackSlash + 1, Text$, ";") - IF SemiColon = 0 THEN _CONTINUE - - tempNum$ = "" - FOR j = BackSlash + 1 TO SemiColon - 1 - IF ASC(Text$, j) < 48 OR ASC(Text$, j) > 57 THEN tempNum$ = "": EXIT FOR - tempNum$ = tempNum$ + MID$(Text$, j, 1) - NEXT - - IF LEN(tempNum$) THEN - Text$ = LEFT$(Text$, BackSlash - 1) + CHR$(VAL(tempNum$)) + MID$(Text$, SemiColon + 1) - END IF - LOOP - - RestoreCHRfromEscapeCode$ = Text$ -END FUNCTION - diff --git a/InForm/xp.uitheme b/InForm/xp.uitheme index d78b095..ea92c62 100644 --- a/InForm/xp.uitheme +++ b/InForm/xp.uitheme @@ -729,11 +729,13 @@ SUB __UI_DrawTextBox (This AS __UI_ControlTYPE, ControlState, ss1 AS LONG, ss2 A This.FocusState = __UI_Focus = This.ID __UI_TempCaptions(This.ID) = Caption(This.ID) IF Mask(This.ID) <> __UI_TempMask(This.ID) THEN + Mask(This.ID) = RestoreCHR$(Mask(This.ID)) __UI_TempMask(This.ID) = Mask(This.ID) Text(This.ID) = __UI_EmptyMask(This.ID) END IF IF __UI_TempTexts(This.ID) <> Text(This.ID) THEN __UI_StateHasChanged = True + Text(This.ID) = RestoreCHR$(Text(This.ID)) __UI_TempTexts(This.ID) = Text(This.ID) END IF This.SelectionLength = __UI_SelectionLength