1
1
Fork 0
mirror of https://github.com/FellippeHeitor/InForm.git synced 2025-01-15 03:49:56 +00:00

Moves CheckPreview from a TIMER event into BeforeUpdateDisplay. Also:

Adds a mechanism to restore the preview's contents in case of crash/restart.
This commit is contained in:
FellippeHeitor 2018-06-10 21:20:23 -03:00
parent 84f654f94b
commit 975828e338
2 changed files with 37 additions and 17 deletions

View file

@ -122,7 +122,7 @@ DIM SHARED OpenDialogOpen AS _BYTE, OverwriteOldFiles AS _BYTE
DIM SHARED RevertEdit AS _BYTE, OldColor AS _UNSIGNED LONG
DIM SHARED ColorPreviewWord$, BlinkStatusBar AS SINGLE, StatusBarBackColor AS _UNSIGNED LONG
DIM SHARED HostPort AS STRING, Host AS LONG, Client AS LONG
DIM SHARED Stream$, FormDataReceived AS _BYTE
DIM SHARED Stream$, FormDataReceived AS _BYTE, LastFormData$
TYPE newInputBox
ID AS LONG
@ -183,8 +183,8 @@ IF _FILEEXISTS("falcon.h") = 0 THEN RestoreFalcon
DIM SHARED CurrentPath$
DIM SHARED OpenDialog AS LONG
CheckPreviewTimer = _FREETIMER
ON TIMER(CheckPreviewTimer, .003) CheckPreview
'CheckPreviewTimer = _FREETIMER
'ON TIMER(CheckPreviewTimer, .003) CheckPreview
UiEditorTitle$ = "InForm Designer"
@ -959,12 +959,18 @@ SUB __UI_BeforeUpdateDisplay
END IF
END IF
CheckPreview
IF NOT MidRead THEN
MidRead = True
DIM incomingData$, Signal$
GET #Client, , incomingData$
Stream$ = Stream$ + incomingData$
STATIC bytesIn~&, refreshes~&
refreshes~& = refreshes~& + 1
bytesIn~& = bytesIn~& + LEN(incomingData$)
Caption(StatusBar) = LTRIM$(STR$(refreshes~&)) + ": " + LTRIM$(STR$(bytesIn~&)) + " bytes received. (" + Stream$ + "...)"
$IF WIN THEN
IF PreviewAttached THEN
@ -1047,7 +1053,8 @@ SUB __UI_BeforeUpdateDisplay
CASE "SIGNAL"
Signal$ = Signal$ + thisData$
CASE "FORMDATA"
LoadPreview thisData$
LastFormData$ = thisData$
LoadPreview
FormDataReceived = True
CASE "UNDOPOINTER"
UndoPointer = CVI(thisData$)
@ -2393,7 +2400,7 @@ SUB __UI_OnLoad
__UI_ForceRedraw = True
_FREEIMAGE tempIcon
TIMER(CheckPreviewTimer) ON
'TIMER(CheckPreviewTimer) ON
EXIT SUB
UiEditorPreviewNotFound:
@ -2856,15 +2863,18 @@ FUNCTION ReadSequential$ (Txt$, Bytes%)
Txt$ = MID$(Txt$, Bytes% + 1)
END FUNCTION
SUB LoadPreview (FormData$)
SUB LoadPreview
DIM a$, b$, i AS LONG, __UI_EOF AS _BYTE, Answer AS _BYTE
DIM NewType AS INTEGER, NewWidth AS INTEGER, NewHeight AS INTEGER
DIM NewLeft AS INTEGER, NewTop AS INTEGER, NewName AS STRING
DIM NewParentID AS STRING, FloatValue AS _FLOAT, Dummy AS LONG
DIM FormData$
TIMER(__UI_EventsTimer) OFF
TIMER(__UI_RefreshTimer) OFF
FormData$ = LastFormData$
b$ = ReadSequential$(FormData$, 4)
REDIM PreviewCaptions(1 TO CVL(b$)) AS STRING
@ -3092,8 +3102,9 @@ SUB CheckPreview
Control(ViewMenuPreview).Disabled = True
ELSE
'Preview was closed.
TIMER(__UI_EventsTimer) OFF
Control(ViewMenuPreview).Disabled = False
__UI_WaitMessage = "Reloading preview window..."
UiPreviewPID = 0
__UI_ProcessInputTimer = 0 'Make the "Please wait" message show up immediataly
@ -3113,6 +3124,11 @@ SUB CheckPreview
Handshake
IF LEN(LastFormData$) THEN
b$ = "RESTORECRASH>" + LastFormData$ + "<END>"
PUT #Client, , b$
END IF
TIMER(__UI_EventsTimer) ON
END IF
END IF

View file

@ -28,7 +28,7 @@ DIM SHARED UndoPointer AS INTEGER, TotalUndoImages AS INTEGER, MidUndo AS _BYTE
REDIM SHARED UndoImage(100) AS STRING
DIM SHARED IsCreating AS _BYTE
DIM SHARED Host AS LONG, HostPort AS STRING
DIM SHARED Stream$
DIM SHARED Stream$, RestoreCrashData$
REDIM SHARED QB64KEYWORDS(0) AS STRING
READ_KEYWORDS
@ -68,6 +68,7 @@ CONST InDisk = 1
CONST InClipboard = 2
CONST ToEditor = 3
CONST ToUndoBuffer = 4
CONST FromEditor = 5
DIM i AS LONG
DIM SHARED AlphaNumeric(255)
@ -240,6 +241,10 @@ SUB __UI_BeforeUpdateDisplay
thisCommand$ = LEFT$(thisData$, INSTR(thisData$, ">") - 1)
thisData$ = MID$(thisData$, LEN(thisCommand$) + 2)
SELECT CASE UCASE$(thisCommand$)
CASE "RESTORECRASH"
RestoreCrashData$ = thisData$
LoadPreview FromEditor
EXIT SUB
CASE "WINDOWPOSITION"
NewWindowLeft = CVI(LEFT$(thisData$, 2))
NewWindowTop = CVI(MID$(thisData$, 3, 2))
@ -309,14 +314,12 @@ SUB __UI_BeforeUpdateDisplay
END SELECT
LOOP
$IF WIN THEN
IF NewWindowLeft <> -32001 AND NewWindowTop <> -32001 AND (NewWindowLeft <> _SCREENX OR NewWindowTop <> _SCREENY) THEN
_SCREENMOVE NewWindowLeft + 612, NewWindowTop
END IF
$END IF
'Check if the editor is still alive
$IF WIN THEN
DIM hnd&, b&, ExitCode&
@ -455,10 +458,7 @@ SUB __UI_BeforeUpdateDisplay
'Editor sent property value
b$ = ReadSequential$(Property$, 2)
TempValue = CVI(b$)
IF TempValue <> 213 AND TempValue <> 214 AND TempValue <> 215 AND TempValue <> 217 AND TempValue <> 221 THEN
'Save undo image except for select, undo, redo, copy and select all signals
SaveUndoImage
END IF
SELECT CASE TempValue
CASE 1 'Name
b$ = ReadSequential$(Property$, 4)
@ -932,6 +932,7 @@ SUB __UI_BeforeUpdateDisplay
NEXT
CASE 201 TO 210
'Alignment commands
b$ = ReadSequential$(Property$, 2)
DoAlign TempValue
CASE 211, 212 'Z-Ordering -> Move up/down
DIM tID1 AS LONG, tID2 AS LONG
@ -969,9 +970,10 @@ SUB __UI_BeforeUpdateDisplay
IF CVL(b$) > 0 THEN Control(CVL(b$)).ControlIsSelected = True
CASE 214 TO 221
b$ = ReadSequential$(Property$, 2)
__UI_KeyPress TempValue
CASE 222 'New textbox control with the NumericOnly property set to true
SaveUndoImage
b$ = ReadSequential$(Property$, 2)
TempValue = __UI_NewControl(__UI_Type_TextBox, "", 120, 23, TempWidth \ 2 - 60, TempHeight \ 2 - 12, ThisContainer)
Control(TempValue).Name = "Numeric" + Control(TempValue).Name
SetCaption TempValue, RTRIM$(Control(TempValue).Name)
@ -990,6 +992,7 @@ SUB __UI_BeforeUpdateDisplay
__UI_FirstSelectedID = TempValue
__UI_ForceRedraw = True
CASE 223
b$ = ReadSequential$(Property$, 2)
AlternateNumericOnlyProperty
END SELECT
__UI_ForceRedraw = True
@ -1143,7 +1146,6 @@ END SUB
SUB __UI_KeyPress (id AS LONG)
SELECT CASE id
CASE 201 TO 210
SaveUndoImage
DoAlign id
CASE 214
RestoreUndoImage
@ -1166,7 +1168,6 @@ SUB __UI_KeyPress (id AS LONG)
AlternateNumericOnlyProperty
CASE 224
DIM TempID AS LONG
SaveUndoImage
TempID = AddNewMenuBarControl
SelectNewControl TempID
END SELECT
@ -1653,6 +1654,9 @@ SUB LoadPreview (Destination AS _BYTE)
ELSEIF UndoBuffer THEN
IF UndoPointer = TotalUndoImages THEN EXIT SUB
Clip$ = UndoImage$(UndoPointer)
ELSEIF Destination = FromEditor THEN
Clip$ = RestoreCrashData$
UndoBuffer = True
ELSE
Clip$ = _CLIPBOARD$
b$ = ReadSequential$(Clip$, LEN(__UI_ClipboardCheck$))