-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMainWindow.Console.vb
More file actions
executable file
·109 lines (94 loc) · 4.1 KB
/
Copy pathMainWindow.Console.vb
File metadata and controls
executable file
·109 lines (94 loc) · 4.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
' MainWindow.Console.vb
' Created: 2025-08-04 08:05:40
Imports Gtk
Imports System
Partial Public Class MainWindow
' Clear csonsole using BottomPanelManager
' Clear console using BottomPanelManager
Public Sub ClearConsole()
Try
pBottomPanelManager?.ClearConsole()
Catch ex As Exception
Console.WriteLine($"ClearConsole error: {ex.Message}")
End Try
End Sub
' Append to console using BottomPanelManager
Public Sub ConsoleLineOut(vText As String)
Try
pBottomPanelManager?.AppendToConsole(vText + vbCrLf)
Catch ex As Exception
Console.WriteLine($"AppendToConsole error: {ex.Message}")
End Try
End Sub
Private ReadOnly Property pOutputTextView As TextView
Get
Return pBottomPanelManager?.ConsoleTextView
End Get
End Property
''' <summary>
''' Shows an error to the user via a modal dialog, and also logs it to the console panel
''' </summary>
''' <remarks>
''' This is the only 2-argument ShowError overload in the project and is called from
''' ~190 sites across the MainWindow.*.vb partial files for user-facing error conditions
''' (e.g. "No project is currently open"). It used to only call ConsoleLineOut, so every
''' one of those calls was silently swallowed whenever the bottom panel was hidden or a
''' different bottom-panel tab was active - the user would click something, nothing
''' visible would happen, and the actual error text was sitting unseen in the console
''' buffer. A modal dialog is what every one of those call sites' message text ("Please
''' open a project first", etc.) is actually written for.
''' </remarks>
Public Sub ShowError(vCaption As String, vMessage As String)
ConsoleLineOut(vCaption + ": " + vMessage)
Try
' Marshal to the GTK main thread - this project installs no SynchronizationContext,
' so Await continuations in Async Function callers (e.g. MainWindow.Run.vb's
' RunProject/RunProjectAsync Catch blocks) resume on a thread-pool thread, and a
' MessageDialog can only be safely created/Run/Destroyed on the thread owning the
' GTK main loop
Application.Invoke(Sub()
Try
Dim lDialog As New MessageDialog(Me, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, vMessage)
lDialog.Title = vCaption
lDialog.Run()
lDialog.Destroy()
Catch ex As Exception
Console.WriteLine($"ShowError dialog error: {ex.Message}")
End Try
End Sub)
Catch ex As Exception
Console.WriteLine($"ShowError error: {ex.Message}")
End Try
End Sub
''' <summary>
''' Shows an informational message to the user via a modal dialog, and also logs it to
''' the console panel - see ShowError's remarks for why this can't just log to console
''' </summary>
Public Sub ShowInfo(vCaption As String, vMessage As String)
ConsoleLineOut(vCaption + ": " + vMessage)
Try
' See ShowError's remarks on why this must marshal to the GTK main thread
Application.Invoke(Sub()
Try
Dim lDialog As New MessageDialog(Me, DialogFlags.Modal, MessageType.Info, ButtonsType.Ok, vMessage)
lDialog.Title = vCaption
lDialog.Run()
lDialog.Destroy()
Catch ex As Exception
Console.WriteLine($"ShowInfo dialog error: {ex.Message}")
End Try
End Sub)
Catch ex As Exception
Console.WriteLine($"ShowInfo error: {ex.Message}")
End Try
End Sub
Private Sub ShowTerminalPanel()
Try
If pBottomPanelManager IsNot Nothing Then
pBottomPanelManager.ShowConsole()
End If
Catch ex As Exception
Console.WriteLine($"ShowTerminalPanel error: {ex.Message}")
End Try
End Sub
End Class