Subversion Repositories oidplus

Compare Revisions

Regard whitespace Rev 746 → Rev 747

/trunk_dos/LISTTEST.PAS
3,7 → 3,7
(************************************************)
(* LISTTEST.PAS *)
(* Author: Daniel Marschall *)
(* Revision: 2022-02-13 *)
(* Revision: 2022-02-16 *)
(* License: Apache 2.0 *)
(* This file contains: *)
(* - Example how to use lists and selection CUI *)
10,7 → 10,7
(************************************************)
 
uses
Crt, StrList, VtsCui;
Crt, Drivers, StrList, VtsCui;
 
var
items: PStringList;
17,8 → 17,11
i, itemIndex: integer;
sTmp: string;
begin
InitList(items);
InitVideo;
CursorOff;
 
CreateList(items);
 
(* Fill the list for testing *)
for i := 1 to 5 do
begin
28,13 → 31,14
 
(* Do inserts and deletions to test their functionality *)
ListInsert(items, 'TEST', 0);
ListDeleteElement(items, 0);
ListDeleteElement(items, 0);
ListDeleteElementByIndex(items, 0);
ListDeleteElementByIndex(items, 0);
ListInsert(items, 'FirstElement', 0);
 
(* Test the selection GUI unit *)
ClrScr;
itemIndex := DrawSelectionList(3, 5, 15, 10, items, true, 0);
itemIndex := DrawSelectionList(3, 5, 15, 10, items, true, '', 0);
ResetDefaultDosColors;
ClrScr;
if itemIndex = -1 then
begin
49,4 → 53,7
FreeList(items);
 
ReadLn;
 
CursorOn;
DoneVideo;
end.
/trunk_dos/OIDFILE.PAS
226,7 → 226,7
(* Remove last CRLF *)
oid^.Description := Copy(oid^.Description, 1, Length(oid^.Description)-Length(#13#10));
 
(* Check if something is not correct *)
(* Check if everything is correct *)
ReadOidFile := (version = WANT_VERS) and (oid^.FileId <> '');
 
Close(f);
/trunk_dos/OIDPLUS.EXE
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk_dos/OIDPLUS.PAS
3,7 → 3,7
(************************************************)
(* OIDPLUS.PAS *)
(* Author: Daniel Marschall *)
(* Revision: 2022-02-15 *)
(* Revision: 2022-02-16 *)
(* License: Apache 2.0 *)
(* This file contains: *)
(* - "OIDplus for DOS" program *)
21,7 → 21,7
Dos, Crt, Drivers, StrList, VtsFuncs, VtsCui, OidFile, OidUtils;
 
const
VERSIONINFO = 'Revision: 2022-02-15';
VERSIONINFO = 'Revision: 2022-02-16';
DEFAULT_STATUSBAR = '(C)2020-2022 ViaThinkSoft. Licensed under the terms of the Apache 2.0 license.';
TITLEBAR_LEFT_TEXT = 'OIDplus';
DISKIO_SOUND_DEBUGGING = false;
344,7 → 344,7
2) then
begin
if sInput = '' then continue;
if not IsPositiveInteger(sInput) then
if not IsPositiveIntegerOrZero(sInput) then
begin
ShowMessage('Invalid numeric ID (must be a positive integer)', 'ERROR', true);
_Pause;
802,20 → 802,10
DisplayOIDFile(rootfile);
end;
 
procedure OP_ManageRAs;
begin
ClrScr;
DrawTitleBar('Manage Registration Authorities', TITLEBAR_LEFT_TEXT, '');
DrawStatusBar('');
 
(* TODO: Implement "Manage RAs" feature *)
end;
 
procedure OP_ReturnToMSDOS;
begin
ClrScr;
TextBackground(Black);
TextColor(LightGray);
(* Note: These two lines don't seem to be necessary if you use DoneVideo *)
ResetDefaultDosColors;
ClrScr; (*Important, so that the DOS command prompt is also LightGray *)
 
WriteLn('Thank you for using OIDplus for DOS.');
825,7 → 815,7
function _GetTreeViewLine(oid: POID; indent: integer): string;
var
i: integer;
sTmp: string;
sTmp, sTmp2: string;
begin
(* Build line *)
sTmp := RepeatStr(' ', indent*TREEVIEW_INDENT);
841,10 → 831,13
sTmp := sTmp + ': ' + oid^.Description;
end;
end;
for i := 1 to Length(sTmp) do
begin
if (sTmp[i]=#13) or (sTmp[i]=#10) then sTmp[i] := ' ';
end;
 
sTmp := StringReplace(sTmp, #13#10, ' ');
repeat
sTmp2 := sTmp;
sTmp := StringReplace(sTmp, ' ', ' ');
until sTmp = sTmp2;
 
sTmp := TrimLineToWidth(sTmp, TREEVIEW_WIDTH);
_GetTreeViewLine := sTmp;
end;
894,6 → 887,23
end;
end;
 
procedure TreeViewPreview;
var
list: PStringList;
begin
CreateList(list);
 
DrawStatusBar('Press ESC to return to the main menu');
ListLoadFromFile(list, TREEVIEW_FILENAME);
DrawSelectionList(2, 3, ScreenWidth-2, ScreenHeight-4,
list, true, 'PREVIEW OF '+TREEVIEW_FILENAME, 2);
(* TODO: Jump to selected OID *)
 
DrawStatusBar(DEFAULT_STATUSBAR);
 
FreeList(list);
end;
 
procedure OP_TreeView;
var
F: Text;
943,6 → 953,8
ShowMessage('TreeView successfully exported as '+TREEVIEW_FILENAME, 'TREEVIEW EXPORT', true);
_Pause;
end;
 
TreeViewPreview;
end;
 
procedure OP_MainMenu;
949,7 → 961,7
var
menu: PStringList;
menuRes, menuLeft, menuTop: integer;
menuIdOID, menuIdRA, menuIdTree, menuIdExit: integer;
menuIdOID, menuIdTree, menuIdExit: integer;
begin
repeat
ClrScr;
962,7 → 974,6
CreateList(menu);
 
menuIdOID := ListAppend(menu, 'Manage OIDs');
menuIdRA := -99; (*ListAppend(menu, 'Manage RAs');*)
menuIdTree := ListAppend(menu, 'Export TreeView');
menuIdExit := ListAppend(menu, 'Return to DOS');
 
977,10 → 988,6
begin
OP_ManageOIDs;
end
else if menuRes = menuIdRA then
begin
OP_ManageRAs;
end
else if menuRes = menuIdTree then
begin
OP_Treeview;
994,5 → 1001,6
InitVideo; (* sets ScreenWidth and ScreenHeight *)
CursorOff;
OP_MainMenu;
CursorOn;
DoneVideo;
end.
/trunk_dos/STRLIST.PAS
3,7 → 3,7
(************************************************)
(* STRLIST.PAS *)
(* Author: Daniel Marschall *)
(* Revision: 2022-02-14 *)
(* Revision: 2022-02-16 *)
(* License: Apache 2.0 *)
(* This file contains: *)
(* - StringList implementation for Turbo Pascal *)
34,6 → 34,8
procedure SplitStrToList(str: string; list: PStringList; separator: string);
procedure OIDtoArcList(oid: string; list: PStringList);
procedure ListBubbleSortNumericString(list: PStringList);
function ListLoadFromFile(list: PStringList; filename: string): boolean;
function ListSaveToFile(list: PStringList; filename: string): boolean;
 
implementation
 
305,4 → 307,61
end;
end;
 
function ListLoadFromFile(list: PStringList; filename: string): boolean;
var
f: Text;
s: string;
begin
Assign(f, filename);
 
{$I-}
Reset(f);
{$I+}
if IoResult <> 0 then
begin
ListLoadFromFile := false;
(* Must not call Close(f) if file was never opened *)
Exit;
end;
 
ListClear(list);
 
while not EOF(f) do
begin
ReadLn(f, s);
ListAppend(list, s);
end;
 
Close(f);
ListLoadFromFile := true;
end;
 
function ListSaveToFile(list: PStringList; filename: string): boolean;
var
f: Text;
i: integer;
s: string;
begin
Assign(f, filename);
 
{$I-}
Rewrite(f);
{$I+}
if IoResult <> 0 then
begin
ListSaveToFile := false;
(* Must not call Close(f) if file was never opened *)
Exit;
end;
 
for i := 0 to ListCount(list)-1 do
begin
s := ListGetElement(list, i);
WriteLn(f, s);
end;
 
Close(f);
ListSaveToFile := true;
end;
 
end.
/trunk_dos/TODO.TXT
1,5 → 1,11
 
TODO:
* (See "TODO" entries in the *.pas files)
 
IDEAS:
* If you call OIDPLUS.EXE with an argument to a .OID file, then open this OID
* TreeView: Write to StringList (avoid recursive calls) and save StringList to file
* TreeView: In the preview, let the user jump to a specific OID
* Implement RAs
* Implement Create/Update timestamps? (people must be able to predate it)
* See "TODO" entries in the *.pas files
* Data exchange between OIDplus for Win95 and OIDplus 2.0 ?
/trunk_dos/VTSCUI.PAS
3,7 → 3,7
(************************************************)
(* VTSCUI.PAS *)
(* Author: Daniel Marschall *)
(* Revision: 2022-02-14 *)
(* Revision: 2022-02-16 *)
(* License: Apache 2.0 *)
(* This file contains: *)
(* - ViaThinkSoft CUI (Console User Interface) *)
36,6 → 36,7
procedure ShowMessage(msg: string; title: string; dobeep: boolean);
procedure CursorOn;
procedure CursorOff;
procedure ResetDefaultDosColors;
 
implementation
 
374,6 → 375,7
iEndScope := itemIndex;
goto doAgain;
end;
(* TODO: Implement PgUp and PgDown keys *)
end;
 
if sc = #13(*Return*) then
595,4 → 597,10
int 10h
end;
 
procedure ResetDefaultDosColors;
begin
TextBackground(Black);
TextColor(LightGray);
end;
 
end.
/trunk_dos/VTSFUNCS.PAS
3,7 → 3,7
(************************************************)
(* VTSFUNCS.PAS *)
(* Author: Daniel Marschall *)
(* Revision: 2022-02-14 *)
(* Revision: 2022-02-16 *)
(* License: Apache 2.0 *)
(* This file contains: *)
(* - Various functions *)
29,10 → 29,12
function DeleteFile(filename: string): boolean;
function FileExists(filename: string): boolean;
 
function IsPositiveInteger(s: string): boolean;
function IsPositiveIntegerOrZero(s: string): boolean;
function StrToInt(s: string): Integer;
function IntToStr(Value: Integer): string;
 
function StringReplace(s, search, replace: string): string;
 
implementation
 
uses
202,11 → 204,11
end;
end;
 
function IsPositiveInteger(s: string): boolean;
function IsPositiveIntegerOrZero(s: string): boolean;
var
i: integer;
begin
IsPositiveInteger := false;
IsPositiveIntegerOrZero := false;
 
if Length(s) = 0 then exit;
if (s[1] = '0') and (s <> '0') then exit;
215,7 → 217,7
if not (s[i] in ['0'..'9']) then exit;
end;
 
IsPositiveInteger := true;
IsPositiveIntegerOrZero := true;
end;
 
function StrToInt(s: string): Integer;
234,4 → 236,30
IntToStr := s;
end;
 
function StringReplace(s, search, replace: string): string;
var
i: integer;
output: string;
begin
if s = '' then exit;
if search = '' then exit; (* invalid arg *)
 
output := '';
while s <> '' do
begin
if Copy(s, 1, Length(search)) = search then
begin
output := output + replace;
Delete(s, 1, Length(search));
end
else
begin
output := output + Copy(s, 1, 1);
Delete(s, 1, 1);
end;
end;
 
StringReplace := output;
end;
 
end.