program test; uses sysutils, classes, buffers, views, events, controllers, painters, console_painters, terminals, textfitters, keyboard, undos; var buffer : ITextBuffer; view : ITextView; dispatch : IMessageLoop; controller : ITextController; stream : TStream; FileName : TFileName; painter : IContinuousCharacterPainter; terminal : ITerminal; begin {$IFDEF WIN32} terminal := TWindowsTerminal.Create; {$ELSE} terminal := TUNIXTerminal.Create; // TODO specify which one? {$ENDIF} {$IFNDEF UNIT_TEST} terminal.ClrSCR; terminal.GotoHome; {$ENDIF} painter := TContinuousConsoleCharacterPainter.Create(terminal); // TODO specify terminal? buffer := TTextBuffer.Create; terminal.UpdateTerminalSize; view := TTextView.Create(painter); view.Buffer := buffer; controller := TTextController.Create(view); if ParamCount >= 1 then begin FileName := ParamStr(ParamCount); try stream := TFileStream.Create(FileName, fmOpenRead); // BAM. controller.Load(stream); terminal.SetTitle(FileName); except terminal.RestoreSettings; raise; end; FreeAndNil(stream); controller.FileName := FileName; end; dispatch := TMessageLoop.Create; dispatch.Fallback := controller.ProcessEvent; {$IFNDEF UNIT_TEST} try dispatch.Run; except if terminal <> nil then terminal.RestoreSettings; dispatch := nil; // free. raise; end; FreeAndNil(dispatch); {$ENDIF} end.