Add support for multiple browser windows

This commit is contained in:
John Sennesael 2020-12-30 18:36:07 -06:00
parent 8bafbbf0cd
commit 801cf24da7
2 changed files with 52 additions and 20 deletions

View File

@ -42,13 +42,31 @@ So far, the following keyboard shortcuts are supported:
* Alt+left - Back.
* Alt+right - Forward.
# How do i build & run it
At the time of writing, I still have to put up a build toolchain with proper build scripts
and such for building outside of Lazarus.
So to build it right now, you have to open the turbogopher.lpi file with lazarus and build with shift+f9
This should produce an executable in the project root directory that you can run from a terminal.
Don't run it from within lazarus, because it doesn't know how to handle console stuff.
# FILES
The only relevant file right now is /tmp/turbogopher_debug.txt which should contain the last
log line (for debugging) - this will go away / be configurable eventually.
# TODO
(very) basic browsing works, but a lot of work is left:
* Opening non-text links and associated mime type handling.
* Opening search links / stuff that takes user input.
* A lot of configuration dialogs to allow configuration of keybindings, colors, logfile, loglevel, etc,...
* Better UTF-8 to Ansi conversion.
* ... stuff?
* (essential) Opening non-text links and associated mime type handling.
* (essential) Opening search links / stuff that takes user input.
* (feature) A lot of configuration dialogs to allow configuration of keybindings, colors, logfile, loglevel, etc,...
* (improvement) Better UTF-8 to Ansi conversion.
* (essential) Add make scripts for people to build this without lazarus. Add packaging stuff, release pipeline stuff.
* (FV bug?) Application does not resize when terminal is resized.
* (feature) History menu and/or window.
* (feature) ability to download/save pages.

View File

@ -18,6 +18,7 @@ uses
GopherClient;
const cmGo = 1000;
const cmNewBrowser = 1001;
type
@ -26,8 +27,11 @@ type
procedure HandleEvent(var Event: TEvent); virtual;
procedure InitStatusLine; virtual;
procedure InitMenuBar; virtual;
private
WindowMenu: PMenu;
end;
PTurboGopherApplication = ^TTurboGopherApplication;
TTurboGopherApplication = class(TCustomApplication)
public
constructor Create(TheOwner: TComponent); override;
@ -48,8 +52,6 @@ type
FileLogger: TFileLogger;
end;
PTurboGopherApplication = ^TTurboGopherApplication;
implementation
uses
@ -58,6 +60,7 @@ implementation
GoWindow;
var
FApplication: PTurboGopherApplication = nil;
FLogWindow: TLogWindow;
FGoWindow: TGoWindow;
FBrowserWindows: array of TBrowserWindow;
@ -80,6 +83,13 @@ implementation
FGoWindow.Show();
ClearEvent(Event);
end;
cmNewBrowser:
begin
if FApplication <> nil then
begin
FApplication^.CreateBrowserWindow;
end;
end;
end;
end;
@ -110,6 +120,9 @@ implementation
Rect := default(Objects.TRect);
GetExtent(Rect);
Rect.B.Y := Rect.A.Y + 1;
WindowMenu := NewMenu(
NewItem('~N~ew browser window', 'Ctrl-T', kbCtrlT, cmNewBrowser, hcNoContext, nil)
);
MenuBar := New(
PMenuBar,
Init(
@ -122,7 +135,8 @@ implementation
NewSubMenu('~B~rowse', hcNoContext,
NewMenu(
NewItem('~G~o', 'Alt-G', kbAltG, cmGo, hcNoContext, nil)
), nil
),
NewSubMenu('~W~indow', hcNoContext, WindowMenu, nil)
)
)
)
@ -134,16 +148,16 @@ implementation
constructor TTurboGopherApplication.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
ActiveBrowserWindow := 0;
StopOnException := True;
TurboGraphicsApplication.Init;
Logger := TLogger.Create;
FileLogger := TFileLogger.Create(@Logger, '/tmp/turbogopher_debug.txt');
Client := TGopherClient.Create(@Logger);
FLogWindow := TLogWindow.Init(Self);
FGoWindow := TGoWindow.Create(Self);
CreateBrowserWindow;
inherited Create(TheOwner);
ActiveBrowserWindow := 0;
StopOnException := True;
TurboGraphicsApplication.Init;
Logger := TLogger.Create;
FileLogger := TFileLogger.Create(@Logger, '/tmp/turbogopher_debug.txt');
Client := TGopherClient.Create(@Logger);
FLogWindow := TLogWindow.Init(Self);
FGoWindow := TGoWindow.Create(Self);
CreateBrowserWindow;
end;
procedure TTurboGopherApplication.CreateBrowserWindow;
@ -157,6 +171,7 @@ implementation
var
ErrorMsg: String;
begin
FApplication := @Self;
{ quick check parameters }
ErrorMsg:=CheckOptions('h', 'help');
if ErrorMsg<>'' then
@ -220,8 +235,7 @@ implementation
procedure TTurboGopherApplication.WriteHelp;
begin
{ add your help code here }
writeln('Usage: ', ExeName, ' -h');
writeln('Usage: ', ExeName, ' -h');
end;
end.