Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
paule32 committed Nov 15, 2023
1 parent 994a91e commit c12a66d
Show file tree
Hide file tree
Showing 9 changed files with 638 additions and 127 deletions.
196 changes: 196 additions & 0 deletions src/Turbo.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
// -----------------------------------------------------------------
// File: Turbo.cc
// Author: (c) 2023 Jens Kallup - paule32
// All rights reserved
//
// only for education, and non-profit usage !
// -----------------------------------------------------------------
# define Uses_TKeys
# define Uses_TApplication
# define Uses_TEvent
# define Uses_TRect
# define Uses_TDialog
# define Uses_TStaticText
# define Uses_TButton
# define Uses_TMenuBar
# define Uses_TSubMenu
# define Uses_TMenuItem
# define Uses_TStatusLine
# define Uses_TStatusItem
# define Uses_TStatusDef
# define Uses_TDeskTop
# define Uses_TChDirDialog
# define Uses_TFileDialog
# define Uses_MsgBox
# define Uses_TDisplay
# define Uses_TScreen
# define Uses_TEditor
# define Uses_TEditWindow
# define Uses_TMemo
# define Uses_TStreamableClass
# include <tvision/tv.h>

# include <string.h>
# include <stdlib.h>

#include "formcmds.h"

#define FORM_WILDCARD "*.f32"

extern TPoint shadowSize;
const int MAXSIZE = 150;

ushort doEditDialog( int dialog, ... );
ushort execDialog( TDialog *d, void *data );

class TFormApp : public TApplication
{
public:

TFormApp();

void handleEvent( TEvent& Event);
static TMenuBar *initMenuBar( TRect r);
static TStatusLine *initStatusLine( TRect r);
void changeDir();

TEditWindow * openEditor( const char *fileName, Boolean visible );
void fileNew();
void fileOpen();
};

TEditWindow *TFormApp::openEditor( const char *fileName, Boolean visible )
{
TRect r = deskTop->getExtent();
TView *p = validView( new TEditWindow( r, fileName, wnNoNumber ) );
if( !visible )
p->hide();
deskTop->insert( p );
return (TEditWindow *)p;
}

void TFormApp::fileOpen()
{
char fileName[MAXPATH];
strcpy( fileName, "*.*" );

if( execDialog( new TFileDialog( "*.*", "Open file",
"~N~ame", fdOpenButton, 100 ), fileName) != cmCancel )
openEditor( fileName, True );
}

void TFormApp::fileNew()
{
openEditor( 0, True );
}

// TFormApp
TFormApp::TFormApp() :
TProgInit(&TFormApp::initStatusLine,
&TFormApp::initMenuBar,
&TFormApp::initDeskTop),
TApplication()
{
TEvent event;
TEditor::editorDialog = doEditDialog;

// Display about box
event.what = evCommand;
event.message.command = cmAboutBox;
putEvent(event);
}

void TFormApp::changeDir()
{
TView *d = validView( new TChDirDialog( 0, hlChangeDir ) );

if( d != 0 ) {
deskTop->execView( d );
destroy(d);
}
}

void TFormApp::handleEvent(TEvent& event)
{
int newMode;
char aboutMsg[80];

TApplication::handleEvent(event);
if (event.what == evCommand)
{
switch (event.message.command)
{
case cmListOpen:
fileOpen();
break;
case cmChgDir:
changeDir();
break;
case cmAboutBox:
strcpy(aboutMsg, "\x3Turbo Vision AsmJit 1.0\n\n\x3non-profit Project");
messageBox(aboutMsg, mfInformation | mfOKButton);
break;
case cmVideoMode:
newMode = TScreen::screenMode ^ TDisplay::smFont8x8;
if ((newMode & TDisplay::smFont8x8) != 0)
shadowSize.x = 1;
else
shadowSize.x = 2;
setScreenMode((ushort)newMode);
break;

default:
return;
}
clearEvent(event);
}
}

TMenuBar *TFormApp::initMenuBar( TRect r)
{

r.b.y = r.a.y + 1;
return new TMenuBar(r,
*new TSubMenu( "~\xF0~", hcNoContext ) +
*new TMenuItem( "~V~ideo mode", cmVideoMode, kbNoKey, hcNoContext, "" ) +
newLine() +
*new TMenuItem( "~A~bout...", cmAboutBox, kbNoKey, hcNoContext ) +
*new TSubMenu( "~F~ile", hcNoContext) +
*new TMenuItem( "~O~pen...", cmListOpen, kbF3, hcNoContext, "F3" ) +
*new TMenuItem( "~S~ave", cmListSave, kbF2, hcNoContext, "F2" ) +
newLine() +
*new TMenuItem( "~C~hange directory...", cmChgDir, kbNoKey, hcNoContext ) +
*new TMenuItem( "~D~OS shell", cmDosShell, kbNoKey, hcNoContext ) +
*new TMenuItem( "E~x~it", cmQuit, kbAltX, hcNoContext, "Alt-X" ) +
*new TSubMenu( "~W~indow", hcNoContext ) +
*new TMenuItem( "~M~ove", cmResize, kbCtrlF5, hcNoContext, "Cntl-F5") +
*new TMenuItem( "~N~ext", cmNext, kbF6, hcNoContext, "F6") +
*new TMenuItem( "~P~rev", cmPrev, kbShiftF6, hcNoContext, "Shift-F6") +
*new TMenuItem( "~C~lose", cmClose, kbAltF3, hcNoContext, "Alt-F3")
);
}

TStatusLine *TFormApp::initStatusLine( TRect r )
{
r.a.y = r.b.y - 1;
return new TStatusLine( r,
*new TStatusDef( 0, 0xFFFF ) +
*new TStatusItem( "~F2~ Save", kbF2, cmListSave ) +
*new TStatusItem( "~F3~ Open", kbF3, cmListOpen ) +
*new TStatusItem( "~F10~ Menu", kbF10, cmMenu) +
*new TStatusItem( 0, kbShiftDel, cmCut ) +
*new TStatusItem( 0, kbCtrlIns, cmCopy ) +
*new TStatusItem( 0, kbShiftIns, cmPaste ) +
*new TStatusItem( "", kbCtrlF5, cmResize )
);
}

int TurboMain(void)
{
TFormApp *formApp = new TFormApp;
formApp->run();

TObject::destroy(formApp);

return 0;
}
29 changes: 15 additions & 14 deletions src/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -797,24 +797,25 @@ if [[ -n "${built_dis}" ]]; then
# ----------------------------------------
# build turbo vision stuff ...
# ----------------------------------------
cd ${SRC}/tv
${GXX} ${FLAGS} -c *.cpp
ar rcx libtvision.a *.o
mv libtvision.a ${TMP}
cd ${TMP}
#cd ${SRC}/tv
#${GXX} ${FLAGS} -c *.cpp
#ar rcx libtvision.a *.o
#mv libtvision.a ${TMP}
#cd ${TMP}

cmd=$(${GXX} ${FLAGS} -o${TMP}/tvdemo1.o -c ${SRC}/tvdemo1.cpp 2>&1 ); run_check $? "${cmd}"
cmd=$(${GXX} ${FLAGS} -o${TMP}/tvdemo2.o -c ${SRC}/tvdemo2.cpp 2>&1 ); run_check $? "${cmd}"
cmd=$(${GXX} ${FLAGS} -o${TMP}/tvdemo3.o -c ${SRC}/tvdemo3.cpp 2>&1 ); run_check $? "${cmd}"
cmd=$(${GXX} ${FLAGS} -o${TMP}/puzzle.o -c ${SRC}/puzzle.cpp 2>&1 ); run_check $? "${cmd}"
cmd=$(${GXX} ${FLAGS} -o${TMP}/calendar.o -c ${SRC}/calendar.cpp 2>&1 ); run_check $? "${cmd}"
cmd=$(${GXX} ${FLAGS} -o${TMP}/calc.o -c ${SRC}/calc.cpp 2>&1 ); run_check $? "${cmd}"
cmd=$(${GXX} ${FLAGS} -o${TMP}/backgrnd.o -c ${SRC}/backgrnd.cpp 2>&1 ); run_check $? "${cmd}"
cmd=$(${GXX} ${FLAGS} -o${TMP}/ascii.o -c ${SRC}/ascii.cpp 2>&1 ); run_check $? "${cmd}"
cmd=$(${GXX} ${FLAGS} -o${TMP}/evntview.o -c ${SRC}/evntview.cpp 2>&1 ); run_check $? "${cmd}"
cmd=$(${GXX} ${FLAGS} -o${TMP}/fileview.o -c ${SRC}/fileview.cpp 2>&1 ); run_check $? "${cmd}"
cmd=$(${GXX} ${FLAGS} -o${TMP}/gadgets.o -c ${SRC}/gadgets.cpp 2>&1 ); run_check $? "${cmd}"
cmd=$(${GXX} ${FLAGS} -o${TMP}/mousedlg.o -c ${SRC}/mousedlg.cpp 2>&1 ); run_check $? "${cmd}"

#cmd=$(${GXX} ${FLAGS} -o${TMP}/puzzle.o -c ${SRC}/puzzle.cpp 2>&1 ); run_check $? "${cmd}"
#cmd=$(${GXX} ${FLAGS} -o${TMP}/calendar.o -c ${SRC}/calendar.cpp 2>&1 ); run_check $? "${cmd}"
#cmd=$(${GXX} ${FLAGS} -o${TMP}/calc.o -c ${SRC}/calc.cpp 2>&1 ); run_check $? "${cmd}"
#cmd=$(${GXX} ${FLAGS} -o${TMP}/backgrnd.o -c ${SRC}/backgrnd.cpp 2>&1 ); run_check $? "${cmd}"
#cmd=$(${GXX} ${FLAGS} -o${TMP}/ascii.o -c ${SRC}/ascii.cpp 2>&1 ); run_check $? "${cmd}"
#cmd=$(${GXX} ${FLAGS} -o${TMP}/evntview.o -c ${SRC}/evntview.cpp 2>&1 ); run_check $? "${cmd}"
#cmd=$(${GXX} ${FLAGS} -o${TMP}/fileview.o -c ${SRC}/fileview.cpp 2>&1 ); run_check $? "${cmd}"
#cmd=$(${GXX} ${FLAGS} -o${TMP}/gadgets.o -c ${SRC}/gadgets.cpp 2>&1 ); run_check $? "${cmd}"
#cmd=$(${GXX} ${FLAGS} -o${TMP}/mousedlg.o -c ${SRC}/mousedlg.cpp 2>&1 ); run_check $? "${cmd}"

# ----------------------------------------
# link diss.exe application ...
Expand Down
1 change: 0 additions & 1 deletion src/formcmds.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#pragma once

// Misc UI commands

const ushort
cmAboutBox = 2000,
cmChgDir = 2001,
Expand Down
Loading

0 comments on commit c12a66d

Please sign in to comment.