Erstes Video Version 0.1

Erreicht:

* Öffnen des Fensters
* Anzeige des Text-Editors
* Laden eines Textes mittels Startparameter
* Prüfung, ob der Text im Editor sich verändert hat beim verlassen
* Falls sich der Text nicht geändert hat, wird das Programm einfach beendet
* Wenn der Text gespeichert werden soll, wird entweder der zuvor geladene Text überschreiben und falls keiner geladen wurde, der Text in die Datei "unbenannt.txt" gespeichert.

Nicht erreicht:

- Falls sich der Text geändert hat, wird nachgefragt, ob der Text gespeichert, nicht gespeichert, oder ob der Vorgang abgebrochen werden soll.
This commit is contained in:
Dany Thinnes 2021-11-25 11:14:40 +01:00
parent 2ef89bb9c9
commit 1d44a208f4
11 changed files with 480 additions and 0 deletions

9
Versionen Normal file
View File

@ -0,0 +1,9 @@
Im ersten Video wird es um Version 0.1 gehen. Folgendes soll dabei erreicht werden:
* Öffnen des Fensters
* Anzeige des Text-Editors
* Laden eines Textes mittels Startparameter
* Prüfung, ob der Text im Editor sich verändert hat beim verlassen
- Falls sich der Text nicht geändert hat, wird das Programm einfach beendet
- Falls sich der Text geändert hat, wird nachgefragt, ob der Text gespeichert, nicht gespeichert, oder ob der Vorgang abgebrochen werden soll.
* Wenn der Text gespeichert werden soll, wird entweder der zuvor geladene Text überschreiben und falls keiner geladen wurde, der Text in die Datei "unbenannt.txt" gespeichert.^@Y*à

BIN
phED Normal file

Binary file not shown.

9
phED.link Normal file
View File

@ -0,0 +1,9 @@
"HD0:StormC/StormC/StormSYS/startups/startup.o"
0,0,0,132,code_68k
1,0,132,48,code_68k
-
3,1,0,16,data
"Projekte:phED/phed.o"
0,0,180,1236,code_68k
1,1,16,16,data
!0,628 ; _main

182
phED.map Normal file
View File

@ -0,0 +1,182 @@
Global M68K Construktors
_INIT_0_InitFiles
_INIT_1_DOS_c__DOSBase
_INIT_2_Intuition_c__IntuitionBase
Global M68K Destruktors
_EXIT_5_InitFiles
_EXIT_4_free
_EXIT_2_Intuition_c__IntuitionBase
_EXIT_1_DOS_c__DOSBase
_EXIT_0_Main
No Global PPC Construktors
No Global PPC Destruktors
M68K Code
Hunk #0 ( Far Public ) 7896 Bytes (0x1ed8)
_exit = 132 (0x84) referenced 2 times
File HD0:StormC/StormC/StormSYS/startups/startup.o
_closeLibraries = 180 (0xb4) unused, maybe local
File Projekte:phED/phed.o
_openLibraries = 258 (0x102) unused, maybe local
File Projekte:phED/phed.o
_saveText = 374 (0x176) unused, maybe local
File Projekte:phED/phed.o
_loadText = 454 (0x1c6) unused, maybe local
File Projekte:phED/phed.o
_main = 628 (0x274) referenced 2 times
File Projekte:phED/phed.o
_fopen = 1418 (0x58a) referenced 1 times
File HD0:StormC/StormC/Lib/storm.lib
_fclose = 1576 (0x628) referenced 1 times
File HD0:StormC/StormC/Lib/storm.lib
_setvbuf = 1648 (0x670) referenced 2 times
File HD0:StormC/StormC/Lib/storm.lib
_amigaopen = 1868 (0x74c) referenced 1 times
File HD0:StormC/StormC/Lib/storm.lib
_amigaread = 2840 (0xb18) referenced 4 times
File HD0:StormC/StormC/Lib/storm.lib
_amigareadunget = 3308 (0xcec) referenced 1 times
File HD0:StormC/StormC/Lib/storm.lib
_amigawrite = 3408 (0xd50) referenced 2 times
File HD0:StormC/StormC/Lib/storm.lib
_amigaeof = 3960 (0xf78) referenced 1 times
File HD0:StormC/StormC/Lib/storm.lib
_amigaseek = 3984 (0xf90) referenced 1 times
File HD0:StormC/StormC/Lib/storm.lib
_amigagetc = 4272 (0x10b0) referenced 3 times
File HD0:StormC/StormC/Lib/storm.lib
_amigagetcunget = 4328 (0x10e8) referenced 1 times
File HD0:StormC/StormC/Lib/storm.lib
_amigaungetc = 4360 (0x1108) referenced 1 times
File HD0:StormC/StormC/Lib/storm.lib
_amigaputc = 4392 (0x1128) referenced 1 times
File HD0:StormC/StormC/Lib/storm.lib
_amigaflush = 4452 (0x1164) referenced 6 times
File HD0:StormC/StormC/Lib/storm.lib
_amigaclose = 4684 (0x124c) referenced 1 times
File HD0:StormC/StormC/Lib/storm.lib
_INIT_0_InitFiles = 4808 (0x12c8) unused, maybe local
File HD0:StormC/StormC/Lib/storm.lib
_EXIT_5_InitFiles = 4880 (0x1310) unused, maybe local
File HD0:StormC/StormC/Lib/storm.lib
_memcpy = 4968 (0x1368) referenced 3 times
File HD0:StormC/StormC/Lib/storm.lib
_malloc = 5040 (0x13b0) referenced 4 times
File HD0:StormC/StormC/Lib/storm.lib
_free = 5460 (0x1554) referenced 6 times
File HD0:StormC/StormC/Lib/storm.lib
_EXIT_4_free = 5656 (0x1618) unused, maybe local
File HD0:StormC/StormC/Lib/storm.lib
_realloc = 5776 (0x1690) referenced 1 times
File HD0:StormC/StormC/Lib/storm.lib
_fread = 5892 (0x1704) referenced 1 times
File HD0:StormC/StormC/Lib/storm.lib
_fwrite = 5952 (0x1740) referenced 1 times
File HD0:StormC/StormC/Lib/storm.lib
_strcat = 6004 (0x1774) referenced 1 times
File HD0:StormC/StormC/Lib/storm.lib
_strcmp = 6040 (0x1798) referenced 1 times
File HD0:StormC/StormC/Lib/storm.lib
_strlen = 6096 (0x17d0) referenced 1 times
File HD0:StormC/StormC/Lib/storm.lib
_DoMethod = 6120 (0x17e8) referenced 1 times
File HD0:StormC/StormC/Lib/amiga.lib
_DoSuperMethod = 6140 (0x17fc) unused, maybe local
File HD0:StormC/StormC/Lib/amiga.lib
_CoerceMethod = 6166 (0x1816) unused, maybe local
File HD0:StormC/StormC/Lib/amiga.lib
_CoerceMethodA = 6188 (0x182c) unused, maybe local
File HD0:StormC/StormC/Lib/amiga.lib
_DoMethodA = 6224 (0x1850) unused, maybe local
File HD0:StormC/StormC/Lib/amiga.lib
_DoSuperMethodA = 6244 (0x1864) unused, maybe local
File HD0:StormC/StormC/Lib/amiga.lib
_SetSuperAttrs = 6270 (0x187e) unused, maybe local
File HD0:StormC/StormC/Lib/amiga.lib
main() = 6328 (0x18b8) referenced 2 times
File HD0:StormC/StormC/StormSYS/lib/stormcstartup000.lib
main(int,char **) = 6336 (0x18c0) referenced 2 times
File HD0:StormC/StormC/StormSYS/lib/stormcstartup000.lib
wbmain(WBStartup *) = 6344 (0x18c8) referenced 2 times
File HD0:StormC/StormC/StormSYS/lib/stormcstartup000.lib
_wbmain = 6352 (0x18d0) referenced 2 times
File HD0:StormC/StormC/StormSYS/lib/stormcstartup000.lib
main(int,char *) = 6356 (0x18d4) referenced 1 times
File HD0:StormC/StormC/StormSYS/lib/stormcstartup000.lib
_EXIT_0_Main = 6848 (0x1ac0) unused, maybe local
File HD0:StormC/StormC/StormSYS/lib/stormcstartup000.lib
_INIT_1_DOS_c__DOSBase = 6900 (0x1af4) unused, maybe local
File HD0:StormC/StormC/StormSYS/lib/stormcstartup000.lib
_EXIT_1_DOS_c__DOSBase = 6932 (0x1b14) unused, maybe local
File HD0:StormC/StormC/StormSYS/lib/stormcstartup000.lib
_InitModules = 7000 (0x1b58) referenced 1 times
File HD0:StormC/StormC/StormSYS/lib/stormcstartup000.lib
_CleanupModules = 7076 (0x1ba4) referenced 2 times
File HD0:StormC/StormC/StormSYS/lib/stormcstartup000.lib
_INIT_2_Intuition_c__IntuitionBase = 7140 (0x1be4) unused, maybe local
File HD0:StormC/StormC/StormSYS/lib/stormcstartup000.lib
_EXIT_2_Intuition_c__IntuitionBase = 7172 (0x1c04) unused, maybe local
File HD0:StormC/StormC/StormSYS/lib/stormcstartup000.lib
LibBaseC::LibBaseC(char *,unsigned long,short) = 7248 (0x1c50) referenced 2 times
File HD0:StormC/StormC/StormSYS/lib/stormcstartup000.lib
LibBaseC::~LibBaseC() = 7704 (0x1e18) referenced 2 times
File HD0:StormC/StormC/StormSYS/lib/stormcstartup000.lib
uintmult = 7744 (0x1e40) referenced 2 times
File HD0:StormC/StormC/StormSYS/lib/stormcsupport000.lib
intmult = 7744 (0x1e40) unused, maybe local
File HD0:StormC/StormC/StormSYS/lib/stormcsupport000.lib
___uintmult32 = 7744 (0x1e40) unused, maybe local
File HD0:StormC/StormC/StormSYS/lib/stormcsupport000.lib
___intmult32 = 7744 (0x1e40) unused, maybe local
File HD0:StormC/StormC/StormSYS/lib/stormcsupport000.lib
intdiv = 7776 (0x1e60) unused, maybe local
File HD0:StormC/StormC/StormSYS/lib/stormcsupport000.lib
uintdiv = 7814 (0x1e86) unused, maybe local
File HD0:StormC/StormC/StormSYS/lib/stormcsupport000.lib
lib_div_uint = 7814 (0x1e86) referenced 2 times
File HD0:StormC/StormC/StormSYS/lib/stormcsupport000.lib
___uintdivmod32 = 7814 (0x1e86) unused, maybe local
File HD0:StormC/StormC/StormSYS/lib/stormcsupport000.lib
lib_div_int = 7776 (0x1e60) unused, maybe local
File HD0:StormC/StormC/StormSYS/lib/stormcsupport000.lib
___intdivmod32 = 7776 (0x1e60) unused, maybe local
File HD0:StormC/StormC/StormSYS/lib/stormcsupport000.lib
PowerPC Code
Data
Hunk #1 ( Far Public ) 104 Bytes (0x68)
_SysBase = 0 (0x0) referenced 11 times
File HD0:StormC/StormC/StormSYS/startups/startup.o
_WindowBase = 16 (0x10) unused, maybe local
File Projekte:phED/phed.o
_LayoutBase = 20 (0x14) unused, maybe local
File Projekte:phED/phed.o
_TextFieldBase = 24 (0x18) unused, maybe local
File Projekte:phED/phed.o
_version = 28 (0x1c) unused, maybe local
File Projekte:phED/phed.o
_DOSBase = 32 (0x20) referenced 9 times
File HD0:StormC/StormC/StormSYS/lib/stormcstartup000.lib
_IntuitionBase = 44 (0x2c) referenced 2 times
File HD0:StormC/StormC/StormSYS/lib/stormcstartup000.lib
_not_open__LibBaseC = 48 (0x30) referenced 1 times
File HD0:StormC/StormC/StormSYS/lib/stormcstartup000.lib
___init_table68k = 56 (0x38) referenced 2 times
File <Internal Assembled>
___exit_table68k = 80 (0x50) referenced 1 times
File <Internal Assembled>
BSS
Hunk #2 ( Far Public ) 568 Bytes (0x238)
_errno = 0 (0x0) referenced 1 times
File HD0:StormC/StormC/Lib/storm.lib
END

88
phED.¶ Normal file
View File

@ -0,0 +1,88 @@
Storm Shell Project (0013)
Settings (Start)
C/C++ Environment
"StormC:include"
"Projekte:Include_H"
Includepath (End)
0 "" 80
0 "objects"
C/C++ Preprozessor
Defines (End)
1 1 1
C/C++ Options
0 1 1 2 0 0 0 0 0 0 0 0 0 0 0
C/C++ Optimizer
6
C/C++ Warnings
1 1 1 1 1 1 0 1
Assembler
0 ""
0 "CON://640/200/Storm Assembler/AUTO/WAIT/SCREEN StormScreen"
0 0
0 1 60 0 1 0 0 20 0
Sets (End)
0 1 0 0 0 2 1 0 0
1 1 1 1 0 0 0 0 0
1 0
0 0 0 0 0
Linker
0 0 "PROGDIR:startup.o" 0 0 1 0 1 0 0
"StormC:lib" 0 "StormC:lib/logfile" 0 0 0
0 "_WizardSurface"
0 0 50 0 50 0 50 0 0
0 0 0 0 0 0 0 0
Run
30 "" "" "" 0
""
1 "CON://400/180/Storm Console/AUTO/WAIT/SCREEN StormScreen" "RAM:Output" "RAM:Input"
1 0
0 0 0 "" ""
Settings (End)
File
1 "phed.c"
"phed.c"
"Projekte:phED/phed-init.h"
Storm Shell Project (Dependencies)
"phed.o" "phed.debug"
""
"phed.o" "phed.debug"
Section
1 1 100
File
2 "phed-init.h"
"phed-init.h"
Storm Shell Project (Dependencies)
"" ""
""
File
2 "phed-file.h"
Storm Shell Project (Dependencies)
"" ""
""
Section
2 1 95
File
10 "phED"
"phED"
Storm Shell Project (Dependencies)
"" ""
""
"phED.link"
Section
10 1 40
File
5 "storm.lib"
"storm.lib"
Storm Shell Project (Dependencies)
"" ""
""
File
5 "amiga.lib"
"amiga.lib"
Storm Shell Project (Dependencies)
"" ""
""
Section
5 1 -50
Storm Shell Project (End)

43
phed-file.h Normal file
View File

@ -0,0 +1,43 @@
void saveText(char *name, UBYTE *buffer)
{
FILE *fp;
if(fp = fopen(name, "w"))
{
fwrite(buffer, sizeof(char), strlen(buffer), fp);
fclose(fp);
}
}
UBYTE *loadText(char *name)
{
FILE *fp;
char *buffer;
buffer = (char *) malloc(0);
if(fp = fopen(name, "r"))
{
char tmp[1025];
int read = 1;
while(read > 0)
{
read = fread(tmp, 1, 1024, fp);
buffer = (char *) realloc(buffer, strlen(buffer) + read + 1);
strcat(buffer, tmp);
buffer[strlen(buffer)+1] = '\0';
if(read < 1024) break;
}
fclose(fp);
}
return buffer;
}

31
phed-init.h Normal file
View File

@ -0,0 +1,31 @@
struct Library *WindowBase = NULL,
*LayoutBase = NULL,
*TextFieldBase = NULL;
void closeLibraries()
{
if(WindowBase) CloseLibrary((struct Library *) WindowBase);
if(TextFieldBase) CloseLibrary((struct Library *) TextFieldBase);
if(LayoutBase) CloseLibrary((struct Library *) LayoutBase);
}
BOOL openLibraries()
{
BOOL ret = FALSE;
if(WindowBase = (struct Library *) OpenLibrary("window.class", 0L))
{
if(TextFieldBase = (struct Library *) OpenLibrary("gadgets/texteditor.gadget", 0L))
{
if(LayoutBase = (struct Library *) OpenLibrary("gadgets/layout.gadget", 0L))
{
ret = TRUE;
}
}
}
if(!ret) closeLibraries();
return ret;
}

117
phed.c Normal file
View File

@ -0,0 +1,117 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/intuition.h>
#include <proto/window.h>
#include <proto/layout.h>
#include <proto/texteditor.h>
#include <reaction/reaction_macros.h>
#include <classes/window.h>
#include <gadgets/texteditor.h>
#include "phed-init.h"
#include "phed-file.h"
const char *version = "$VER: phED Version 0.1";
enum
{
GID_TEXTEDITOR = 0,
GID_LAST
};
int main(int argc, char *argv[])
{
struct Window *window;
struct Gadget *gadgets[GID_LAST];
Object *Win_Object;
ULONG signal, result;
ULONG done = FALSE;
APTR text;
char *buf;
if(argc > 0)
{
buf = loadText(argv[1]);
text = &buf;
}
if(openLibraries())
{
Win_Object = WindowObject,
WA_ScreenTitle, "Projekt Hirnfrei",
WA_Title, "phED",
WA_SizeGadget, TRUE,
WA_DepthGadget, TRUE,
WA_DragBar, TRUE,
WA_CloseGadget, TRUE,
WA_Activate, TRUE,
WA_Width, 400,
WA_Height, 400,
WINDOW_ParentGroup, HGroupObject,
StartVGroup,
StartMember, gadgets[GID_TEXTEDITOR] = TextEditorObject,
GA_ID, GID_TEXTEDITOR,
GA_RelVerify, TRUE,
GA_TEXTEDITOR_Contents, (APTR) buf,
EndMember,
End,
EndMember,
EndWindow;
if(Win_Object)
{
if(window = (struct Window *) RA_OpenWindow(Win_Object))
{
ULONG wait, changed;
UBYTE *buffer;
GetAttr(WINDOW_SigMask, Win_Object, &signal);
while(!done)
{
wait = Wait(signal|SIGBREAKF_CTRL_C);
if(wait & SIGBREAKF_CTRL_C) done = TRUE;
else
{
while((result = RA_HandleInput(Win_Object, NULL)) != WMHI_LASTMSG)
{
switch(result)
{
case WMHI_CLOSEWINDOW:
GetAttr(GA_TEXTEDITOR_HasChanged, gadgets[GID_TEXTEDITOR], &changed);
if(changed)
{
buffer = (UBYTE *) DoGadgetMethod(gadgets[GID_TEXTEDITOR], window, NULL, GM_TEXTEDITOR_ExportText, NULL);
if(!argv[1]) saveText("unbenannt.txt", buffer);
else saveText(argv[1], buffer);
}
done = TRUE;
break;
}
}
}
}
}
DisposeObject(Win_Object);
}
}
closeLibraries();
if(buf) free(buf);
}

BIN
phed.debug Normal file

Binary file not shown.

BIN
phed.o Normal file

Binary file not shown.

1
unbenannt.txt Normal file
View File

@ -0,0 +1 @@
Das ist doch doof