Skip to content

Commit a18aa02

Browse files
committed
Added debugOutputHandler to CreateWindow
1 parent 59dd64c commit a18aa02

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/EmptyFlow.SciterAPI/Client/HostWindowsAPI.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ public void CloseWindow ( IntPtr window ) {
3232
/// <param name="hostCallback">Host callback, can be remake all default events like bahaviour, create window or so on. If omit will be apply default just like in main window.</param>
3333
/// <param name="parent">Can be specified parent window, can be useful in some cases.</param>
3434
/// <param name="asMain">Point to main window will be stored to SciterAPIHost instance and can be accessed via <see cref="MainWindow"/> property.</param>
35+
/// <param name="debugOutputHandler">If <see cref="debugOutput"/> is true you can override default console output on you own custom delegate.</param>
3536
/// <returns>Pointer to created window.</returns>
36-
public nint CreateWindow ( int width = 0, int height = 0, int x = 0, int y = 0, WindowsFlags? flags = default, bool debugOutput = false, SciterHostCallback? hostCallback = default, nint parent = default, bool asMain = false ) {
37+
public nint CreateWindow ( int width = 0, int height = 0, int x = 0, int y = 0, WindowsFlags? flags = default, bool debugOutput = false, Action<string>? debugOutputHandler = default, SciterHostCallback? hostCallback = default, nint parent = default, bool asMain = false ) {
3738
if ( asMain && m_mainWindow != nint.Zero ) throw new Exception ( "The main window had already been created earlier!" );
3839

3940
var rectangePointer = nint.Zero;
@@ -58,7 +59,11 @@ public nint CreateWindow ( int width = 0, int height = 0, int x = 0, int y = 0,
5859
windowPointer,
5960
1,
6061
( IntPtr param, uint subsystem, uint severity, IntPtr text_ptr, uint text_length ) => {
61-
Console.WriteLine ( Marshal.PtrToStringUni ( text_ptr, (int) text_length ) );
62+
if ( debugOutputHandler != default ) {
63+
debugOutputHandler?.Invoke ( Marshal.PtrToStringUni ( text_ptr, (int) text_length ) );
64+
} else {
65+
Console.WriteLine ( Marshal.PtrToStringUni ( text_ptr, (int) text_length ) );
66+
}
6267
return IntPtr.Zero;
6368
}
6469
);

0 commit comments

Comments
 (0)