diff --git a/Examples/Console/ConBoard/ConBoard.dpr b/Examples/Console/ConBoard/ConBoard.dpr new file mode 100644 index 0000000..8622d54 --- /dev/null +++ b/Examples/Console/ConBoard/ConBoard.dpr @@ -0,0 +1,67 @@ +program ConBoard; + +uses + CRT, KolibriOS; + +var + LogFilePath: PKolibriChar = '/tmp0/1/BOARDLOG.TXT'; + + Ch: KolibriChar; + Prefix: array[0..3] of KolibriChar; // #0#0#0#0 by program start + PrefixIndex: LongWord = 0; // 0 by program start but warning + IsStartLine: Boolean = True; + Attr: TFileAttributes; + BytesWritten: LongWord; + +begin + InitConsole('Console board'); + + if CmdLine^ <> #0 then + LogFilePath := CmdLine; + + repeat + if DebugRead(Ch) then + begin + if IsStartLine then + begin + Prefix[PrefixIndex] := Ch; + if PrefixIndex = High(Prefix) - 1 then + begin + // Kernel + if (Prefix[0] = 'K') and (Prefix[1] = ' ') and (Prefix[2] = ':') then + TextColor(Yellow) + else + // Launcher + if (Prefix[0] = 'L') and (Prefix[1] = ':') and (Prefix[2] = ' ') then + TextColor(White) + else + TextColor(LightGray); + IsStartLine := False; + PrefixIndex := Low(Prefix); + with GetSystemTime do + con_printf('[%02x:%02x:%02x] ', Hours, Minutes, Seconds); + con_write_asciiz(Prefix); + LongWord(Prefix) := 0; // Prefix := #0#0#0#0; + end + else + Inc(PrefixIndex); + end + else + begin + con_write_string(@Ch, 1); + if Ch = #10 then + begin + IsStartLine := True; + TextColor(LightGray); + end; + end; + + if GetFileAttributes(LogFilePath, Attr) = ERROR_FILE_NOT_FOUND then + begin + CreateFile(LogFilePath); + Attr.Size := 0; + end; + WriteFile(LogFilePath, Ch, SizeOf(Ch), Attr.Size, BytesWritten); + end; + until LongBool(con_get_flags and CON_WINDOW_CLOSED); +end. diff --git a/Examples/Console/ConBoard/build.bat b/Examples/Console/ConBoard/build.bat new file mode 100644 index 0000000..82915f4 --- /dev/null +++ b/Examples/Console/ConBoard/build.bat @@ -0,0 +1 @@ +@call "%~dp0..\..\..\Tools\build.bat" "%~dp0ConBoard" \ No newline at end of file diff --git a/Examples/Examples.bpg b/Examples/Examples.bpg index f4515e6..bec33b2 100644 --- a/Examples/Examples.bpg +++ b/Examples/Examples.bpg @@ -9,9 +9,9 @@ MAKE = $(ROOT)\bin\make.exe -$(MAKEFLAGS) -f$** DCC = $(ROOT)\bin\dcc32.exe $** BRCC = $(ROOT)\bin\brcc32.exe $** #------------------------------------------------------------------------------ -PROJECTS = CharMap.exe ColorButtons.exe ConsoleColors.exe DateTime.exe DrawImage.exe DrawImageEx.exe DrawText.exe \ - Echo.exe GetCurrentDirectory.exe GetPixel.exe GetPointOwner.exe Hello.exe HelloGUI.exe LoadFile.exe ReadFolder.exe \ - Screenshot.exe SetCursor.exe SetPixel.exe SetWindowPos.exe +PROJECTS = CharMap.exe ColorButtons.exe ConBoard.exe ConsoleColors.exe DateTime.exe DrawImage.exe DrawImageEx.exe \ + DrawText.exe Echo.exe GetCurrentDirectory.exe GetPixel.exe GetPointOwner.exe Hello.exe HelloGUI.exe LoadFile.exe \ + ReadFolder.exe Screenshot.exe SetCursor.exe SetPixel.exe SetWindowPos.exe #------------------------------------------------------------------------------ default: $(PROJECTS) #------------------------------------------------------------------------------ @@ -22,6 +22,9 @@ CharMap.exe: Console\CharMap\CharMap.dpr ColorButtons.exe: GUI\ColorButtons\ColorButtons.dpr $(DCC) +ConBoard.exe: Console\ConBoard\ConBoard.dpr + $(DCC) + ConsoleColors.exe: Console\ConsoleColors\ConsoleColors.dpr $(DCC)