diff --git a/Versionen b/Versionen index d15d8e4..01c7ebe 100644 --- a/Versionen +++ b/Versionen @@ -4,6 +4,12 @@ Im ersten Video wird es um Version 0.1 gehen. Folgendes soll dabei erreicht werd * 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*à \ No newline at end of file +* 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. + +Zweites Video Ziele: + +* Fehlerbereinigung +* Falls sich der Text geändert hat, wird nachgefragt, ob der Text gespeichert, nicht gespeichert, oder ob der Vorgang abgebrochen werden soll. +* Name vom geladenen Text wird im Titel angezeigt +- Stern hinter Name, wenn der Text sich geändert hat \ No newline at end of file diff --git a/phED b/phED index 6e07fcf..0e6ba26 100644 Binary files a/phED and b/phED differ diff --git a/phED.link b/phED.link index a1b895b..5306a30 100644 --- a/phED.link +++ b/phED.link @@ -4,6 +4,6 @@ - 3,1,0,16,data "Projekte:phED/phed.o" -0,0,180,1236,code_68k -1,1,16,16,data -!0,628 ; _main +0,0,180,1972,code_68k +1,1,16,24,data +!0,864 ; _main diff --git a/phED.map b/phED.map index 0c6aebc..56dd4b0 100644 --- a/phED.map +++ b/phED.map @@ -1,11 +1,15 @@ Global M68K Construktors _INIT_0_InitFiles _INIT_1_DOS_c__DOSBase + _INIT_2_MathIEEEDoubBas_c__MathIeeeDoubBasBase _INIT_2_Intuition_c__IntuitionBase + _INIT_5_InitStdIOFiles Global M68K Destruktors + _EXIT_5_InitStdIOFiles _EXIT_5_InitFiles _EXIT_4_free _EXIT_2_Intuition_c__IntuitionBase + _EXIT_2_MathIEEEDoubBas_c__MathIeeeDoubBasBase _EXIT_1_DOS_c__DOSBase _EXIT_0_Main No Global PPC Construktors @@ -14,134 +18,194 @@ No Global PPC Destruktors M68K Code - Hunk #0 ( Far Public ) 7896 Bytes (0x1ed8) + Hunk #0 ( Far Public ) 16192 Bytes (0x3f40) _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 + _openLibraries = 282 (0x11a) unused, maybe local File Projekte:phED/phed.o - _saveText = 374 (0x176) unused, maybe local + _saveText = 428 (0x1ac) unused, maybe local File Projekte:phED/phed.o - _loadText = 454 (0x1c6) unused, maybe local + _loadText = 522 (0x20a) unused, maybe local File Projekte:phED/phed.o - _main = 628 (0x274) referenced 2 times + _requesterNew = 692 (0x2b4) unused, maybe local File Projekte:phED/phed.o - _fopen = 1418 (0x58a) referenced 1 times + _OpenRequesterTags = 746 (0x2ea) unused, maybe local + File Projekte:phED/phed.o + _beendenReq = 804 (0x324) unused, maybe local + File Projekte:phED/phed.o + _main = 864 (0x360) referenced 2 times + File Projekte:phED/phed.o + _fopen = 2154 (0x86a) referenced 1 times File HD0:StormC/StormC/Lib/storm.lib - _fclose = 1576 (0x628) referenced 1 times + _fclose = 2312 (0x908) referenced 1 times File HD0:StormC/StormC/Lib/storm.lib - _setvbuf = 1648 (0x670) referenced 2 times + _fflush = 2384 (0x950) referenced 1 times File HD0:StormC/StormC/Lib/storm.lib - _amigaopen = 1868 (0x74c) referenced 1 times + _setvbuf = 2468 (0x9a4) referenced 3 times File HD0:StormC/StormC/Lib/storm.lib - _amigaread = 2840 (0xb18) referenced 4 times + _amigaopen = 2688 (0xa80) referenced 1 times File HD0:StormC/StormC/Lib/storm.lib - _amigareadunget = 3308 (0xcec) referenced 1 times + _amigaread = 3660 (0xe4c) referenced 7 times File HD0:StormC/StormC/Lib/storm.lib - _amigawrite = 3408 (0xd50) referenced 2 times + _amigareadunget = 4128 (0x1020) referenced 1 times File HD0:StormC/StormC/Lib/storm.lib - _amigaeof = 3960 (0xf78) referenced 1 times + _amigawrite = 4228 (0x1084) referenced 5 times File HD0:StormC/StormC/Lib/storm.lib - _amigaseek = 3984 (0xf90) referenced 1 times + _amigaeof = 4780 (0x12ac) referenced 4 times File HD0:StormC/StormC/Lib/storm.lib - _amigagetc = 4272 (0x10b0) referenced 3 times + _amigaseek = 4804 (0x12c4) referenced 4 times File HD0:StormC/StormC/Lib/storm.lib - _amigagetcunget = 4328 (0x10e8) referenced 1 times + _amigagetc = 5092 (0x13e4) referenced 6 times File HD0:StormC/StormC/Lib/storm.lib - _amigaungetc = 4360 (0x1108) referenced 1 times + _amigagetcunget = 5148 (0x141c) referenced 1 times File HD0:StormC/StormC/Lib/storm.lib - _amigaputc = 4392 (0x1128) referenced 1 times + _amigaungetc = 5180 (0x143c) referenced 4 times File HD0:StormC/StormC/Lib/storm.lib - _amigaflush = 4452 (0x1164) referenced 6 times + _amigaputc = 5212 (0x145c) referenced 4 times File HD0:StormC/StormC/Lib/storm.lib - _amigaclose = 4684 (0x124c) referenced 1 times + _amigaflush = 5272 (0x1498) referenced 9 times File HD0:StormC/StormC/Lib/storm.lib - _INIT_0_InitFiles = 4808 (0x12c8) unused, maybe local + _amigaclose = 5504 (0x1580) referenced 4 times File HD0:StormC/StormC/Lib/storm.lib - _EXIT_5_InitFiles = 4880 (0x1310) unused, maybe local + _INIT_0_InitFiles = 5628 (0x15fc) unused, maybe local File HD0:StormC/StormC/Lib/storm.lib - _memcpy = 4968 (0x1368) referenced 3 times + _EXIT_5_InitFiles = 5700 (0x1644) unused, maybe local File HD0:StormC/StormC/Lib/storm.lib - _malloc = 5040 (0x13b0) referenced 4 times + _memcpy = 5788 (0x169c) referenced 3 times File HD0:StormC/StormC/Lib/storm.lib - _free = 5460 (0x1554) referenced 6 times + _malloc = 5860 (0x16e4) referenced 4 times File HD0:StormC/StormC/Lib/storm.lib - _EXIT_4_free = 5656 (0x1618) unused, maybe local + _free = 6280 (0x1888) referenced 6 times File HD0:StormC/StormC/Lib/storm.lib - _realloc = 5776 (0x1690) referenced 1 times + _EXIT_4_free = 6476 (0x194c) unused, maybe local File HD0:StormC/StormC/Lib/storm.lib - _fread = 5892 (0x1704) referenced 1 times + _realloc = 6596 (0x19c4) referenced 1 times File HD0:StormC/StormC/Lib/storm.lib - _fwrite = 5952 (0x1740) referenced 1 times + _formatted_out = 7188 (0x1c14) referenced 1 times File HD0:StormC/StormC/Lib/storm.lib - _strcat = 6004 (0x1774) referenced 1 times + _printf = 9176 (0x23d8) referenced 1 times File HD0:StormC/StormC/Lib/storm.lib - _strcmp = 6040 (0x1798) referenced 1 times + _fread = 9228 (0x240c) referenced 1 times File HD0:StormC/StormC/Lib/storm.lib - _strlen = 6096 (0x17d0) referenced 1 times + _fwrite = 9288 (0x2448) referenced 1 times File HD0:StormC/StormC/Lib/storm.lib - _DoMethod = 6120 (0x17e8) referenced 1 times + _INIT_5_InitStdIOFiles = 9340 (0x247c) unused, maybe local + File HD0:StormC/StormC/Lib/storm.lib + _EXIT_5_InitStdIOFiles = 9606 (0x2586) unused, maybe local + File HD0:StormC/StormC/Lib/storm.lib + _strcpy = 9652 (0x25b4) referenced 1 times + File HD0:StormC/StormC/Lib/storm.lib + _strcat = 9680 (0x25d0) referenced 1 times + File HD0:StormC/StormC/Lib/storm.lib + _strcmp = 9716 (0x25f4) referenced 1 times + File HD0:StormC/StormC/Lib/storm.lib + _strlen = 9772 (0x262c) referenced 5 times + File HD0:StormC/StormC/Lib/storm.lib + _signed_out = 9796 (0x2644) referenced 1 times + File HD0:StormC/StormC/Lib/storm.lib + _signed_out_l = 10454 (0x28d6) referenced 1 times + File HD0:StormC/StormC/Lib/storm.lib + _unsigned_out = 10544 (0x2930) referenced 1 times + File HD0:StormC/StormC/Lib/storm.lib + _unsigned_out_l = 11140 (0x2b84) referenced 2 times + File HD0:StormC/StormC/Lib/storm.lib + _char_out = 11668 (0x2d94) referenced 1 times + File HD0:StormC/StormC/Lib/storm.lib + _string_out = 11808 (0x2e20) referenced 1 times + File HD0:StormC/StormC/Lib/storm.lib + _DoMethod = 12000 (0x2ee0) referenced 1 times File HD0:StormC/StormC/Lib/amiga.lib - _DoSuperMethod = 6140 (0x17fc) unused, maybe local + _DoSuperMethod = 12020 (0x2ef4) unused, maybe local File HD0:StormC/StormC/Lib/amiga.lib - _CoerceMethod = 6166 (0x1816) unused, maybe local + _CoerceMethod = 12046 (0x2f0e) unused, maybe local File HD0:StormC/StormC/Lib/amiga.lib - _CoerceMethodA = 6188 (0x182c) unused, maybe local + _CoerceMethodA = 12068 (0x2f24) unused, maybe local File HD0:StormC/StormC/Lib/amiga.lib - _DoMethodA = 6224 (0x1850) unused, maybe local + _DoMethodA = 12104 (0x2f48) referenced 1 times File HD0:StormC/StormC/Lib/amiga.lib - _DoSuperMethodA = 6244 (0x1864) unused, maybe local + _DoSuperMethodA = 12124 (0x2f5c) unused, maybe local File HD0:StormC/StormC/Lib/amiga.lib - _SetSuperAttrs = 6270 (0x187e) unused, maybe local + _SetSuperAttrs = 12150 (0x2f76) unused, maybe local File HD0:StormC/StormC/Lib/amiga.lib - main() = 6328 (0x18b8) referenced 2 times + _floor = 12208 (0x2fb0) referenced 1 times + File HD0:StormC/StormC/StormSYS/lib/math000.lib + _frexp = 12232 (0x2fc8) referenced 1 times + File HD0:StormC/StormC/StormSYS/lib/math000.lib + _double_out = 12900 (0x3264) referenced 1 times + File HD0:StormC/StormC/StormSYS/lib/math000.lib + main() = 14380 (0x382c) referenced 2 times File HD0:StormC/StormC/StormSYS/lib/stormcstartup000.lib - main(int,char **) = 6336 (0x18c0) referenced 2 times + main(int,char **) = 14388 (0x3834) referenced 2 times File HD0:StormC/StormC/StormSYS/lib/stormcstartup000.lib - wbmain(WBStartup *) = 6344 (0x18c8) referenced 2 times + wbmain(WBStartup *) = 14396 (0x383c) referenced 2 times File HD0:StormC/StormC/StormSYS/lib/stormcstartup000.lib - _wbmain = 6352 (0x18d0) referenced 2 times + _wbmain = 14404 (0x3844) referenced 2 times File HD0:StormC/StormC/StormSYS/lib/stormcstartup000.lib - main(int,char *) = 6356 (0x18d4) referenced 1 times + main(int,char *) = 14408 (0x3848) referenced 1 times File HD0:StormC/StormC/StormSYS/lib/stormcstartup000.lib - _EXIT_0_Main = 6848 (0x1ac0) unused, maybe local + _EXIT_0_Main = 14900 (0x3a34) unused, maybe local File HD0:StormC/StormC/StormSYS/lib/stormcstartup000.lib - _INIT_1_DOS_c__DOSBase = 6900 (0x1af4) unused, maybe local + _INIT_1_DOS_c__DOSBase = 14952 (0x3a68) unused, maybe local File HD0:StormC/StormC/StormSYS/lib/stormcstartup000.lib - _EXIT_1_DOS_c__DOSBase = 6932 (0x1b14) unused, maybe local + _EXIT_1_DOS_c__DOSBase = 14984 (0x3a88) unused, maybe local File HD0:StormC/StormC/StormSYS/lib/stormcstartup000.lib - _InitModules = 7000 (0x1b58) referenced 1 times + _InitModules = 15052 (0x3acc) referenced 1 times File HD0:StormC/StormC/StormSYS/lib/stormcstartup000.lib - _CleanupModules = 7076 (0x1ba4) referenced 2 times + _CleanupModules = 15128 (0x3b18) referenced 2 times File HD0:StormC/StormC/StormSYS/lib/stormcstartup000.lib - _INIT_2_Intuition_c__IntuitionBase = 7140 (0x1be4) unused, maybe local + _INIT_2_Intuition_c__IntuitionBase = 15192 (0x3b58) unused, maybe local File HD0:StormC/StormC/StormSYS/lib/stormcstartup000.lib - _EXIT_2_Intuition_c__IntuitionBase = 7172 (0x1c04) unused, maybe local + _EXIT_2_Intuition_c__IntuitionBase = 15224 (0x3b78) unused, maybe local File HD0:StormC/StormC/StormSYS/lib/stormcstartup000.lib - LibBaseC::LibBaseC(char *,unsigned long,short) = 7248 (0x1c50) referenced 2 times + LibBaseC::LibBaseC(char *,unsigned long,short) = 15300 (0x3bc4) referenced 3 times File HD0:StormC/StormC/StormSYS/lib/stormcstartup000.lib - LibBaseC::~LibBaseC() = 7704 (0x1e18) referenced 2 times + LibBaseC::~LibBaseC() = 15756 (0x3d8c) referenced 3 times File HD0:StormC/StormC/StormSYS/lib/stormcstartup000.lib - uintmult = 7744 (0x1e40) referenced 2 times + _INIT_2_MathIEEEDoubBas_c__MathIeeeDoubBasBase = 15796 (0x3db4) unused, maybe local + File HD0:StormC/StormC/StormSYS/lib/stormcstartup000.lib + _EXIT_2_MathIEEEDoubBas_c__MathIeeeDoubBasBase = 15828 (0x3dd4) unused, maybe local + File HD0:StormC/StormC/StormSYS/lib/stormcstartup000.lib + uintmult = 15868 (0x3dfc) referenced 2 times File HD0:StormC/StormC/StormSYS/lib/stormcsupport000.lib - intmult = 7744 (0x1e40) unused, maybe local + intmult = 15868 (0x3dfc) unused, maybe local File HD0:StormC/StormC/StormSYS/lib/stormcsupport000.lib - ___uintmult32 = 7744 (0x1e40) unused, maybe local + ___uintmult32 = 15868 (0x3dfc) unused, maybe local File HD0:StormC/StormC/StormSYS/lib/stormcsupport000.lib - ___intmult32 = 7744 (0x1e40) unused, maybe local + ___intmult32 = 15868 (0x3dfc) unused, maybe local File HD0:StormC/StormC/StormSYS/lib/stormcsupport000.lib - intdiv = 7776 (0x1e60) unused, maybe local + intdiv = 15900 (0x3e1c) unused, maybe local File HD0:StormC/StormC/StormSYS/lib/stormcsupport000.lib - uintdiv = 7814 (0x1e86) unused, maybe local + uintdiv = 15938 (0x3e42) unused, maybe local File HD0:StormC/StormC/StormSYS/lib/stormcsupport000.lib - lib_div_uint = 7814 (0x1e86) referenced 2 times + lib_div_uint = 15938 (0x3e42) referenced 3 times File HD0:StormC/StormC/StormSYS/lib/stormcsupport000.lib - ___uintdivmod32 = 7814 (0x1e86) unused, maybe local + ___uintdivmod32 = 15938 (0x3e42) unused, maybe local File HD0:StormC/StormC/StormSYS/lib/stormcsupport000.lib - lib_div_int = 7776 (0x1e60) unused, maybe local + lib_div_int = 15900 (0x3e1c) referenced 2 times File HD0:StormC/StormC/StormSYS/lib/stormcsupport000.lib - ___intdivmod32 = 7776 (0x1e60) unused, maybe local + ___intdivmod32 = 15900 (0x3e1c) unused, maybe local + File HD0:StormC/StormC/StormSYS/lib/stormcsupport000.lib + Neg64 = 16020 (0x3e94) referenced 1 times + File HD0:StormC/StormC/StormSYS/lib/stormcsupport000.lib + ___neg64 = 16020 (0x3e94) unused, maybe local + File HD0:StormC/StormC/StormSYS/lib/stormcsupport000.lib + SDiv64 = 16028 (0x3e9c) referenced 1 times + File HD0:StormC/StormC/StormSYS/lib/stormcsupport000.lib + UDiv64 = 16068 (0x3ec4) referenced 1 times + File HD0:StormC/StormC/StormSYS/lib/stormcsupport000.lib + ___uintdivmod64 = 16068 (0x3ec4) unused, maybe local + File HD0:StormC/StormC/StormSYS/lib/stormcsupport000.lib + ___intdivmod64 = 16028 (0x3e9c) unused, maybe local + File HD0:StormC/StormC/StormSYS/lib/stormcsupport000.lib + UMod64 = 16168 (0x3f28) referenced 1 times + File HD0:StormC/StormC/StormSYS/lib/stormcsupport000.lib + ___uintmod64 = 16168 (0x3f28) unused, maybe local + File HD0:StormC/StormC/StormSYS/lib/stormcsupport000.lib + SMod64 = 16180 (0x3f34) referenced 1 times + File HD0:StormC/StormC/StormSYS/lib/stormcsupport000.lib + ___intmod64 = 16180 (0x3f34) unused, maybe local File HD0:StormC/StormC/StormSYS/lib/stormcsupport000.lib PowerPC Code @@ -150,26 +214,34 @@ PowerPC Code Data - Hunk #1 ( Far Public ) 104 Bytes (0x68) + Hunk #1 ( Far Public ) 584 Bytes (0x248) _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 + _RequesterBase = 24 (0x18) unused, maybe local File Projekte:phED/phed.o - _version = 28 (0x1c) unused, maybe local + _TextFieldBase = 28 (0x1c) unused, maybe local File Projekte:phED/phed.o - _DOSBase = 32 (0x20) referenced 9 times + _std__out = 40 (0x28) referenced 3 times + File HD0:StormC/StormC/Lib/storm.lib + _std__in = 128 (0x80) referenced 2 times + File HD0:StormC/StormC/Lib/storm.lib + _std__err = 216 (0xd8) referenced 2 times + File HD0:StormC/StormC/Lib/storm.lib + _DOSBase = 496 (0x1f0) referenced 10 times File HD0:StormC/StormC/StormSYS/lib/stormcstartup000.lib - _IntuitionBase = 44 (0x2c) referenced 2 times + _IntuitionBase = 508 (0x1fc) referenced 2 times File HD0:StormC/StormC/StormSYS/lib/stormcstartup000.lib - _not_open__LibBaseC = 48 (0x30) referenced 1 times + _not_open__LibBaseC = 512 (0x200) referenced 1 times File HD0:StormC/StormC/StormSYS/lib/stormcstartup000.lib - ___init_table68k = 56 (0x38) referenced 2 times + _MathIeeeDoubBasBase = 516 (0x204) referenced 5 times + File HD0:StormC/StormC/StormSYS/lib/stormcstartup000.lib + ___init_table68k = 520 (0x208) referenced 2 times File - ___exit_table68k = 80 (0x50) referenced 1 times + ___exit_table68k = 552 (0x228) referenced 1 times File BSS diff --git a/phED.¶ b/phED.¶ index bce8f09..930c7bd 100644 --- a/phED.¶ +++ b/phED.¶ @@ -43,6 +43,8 @@ File 1 "phed.c" "phed.c" "Projekte:phED/phed-init.h" +"Projekte:phED/phed-file.h" +"Projekte:phED/phed-req.h" Storm Shell Project (Dependencies) "phed.o" "phed.debug" "" @@ -57,6 +59,13 @@ Storm Shell Project (Dependencies) "" File 2 "phed-file.h" +"phed-file.h" +Storm Shell Project (Dependencies) +"" "" +"" +File +2 "phed-req.h" +"phed-req.h" Storm Shell Project (Dependencies) "" "" "" diff --git a/phed-file.h b/phed-file.h index f7f8738..b955d00 100644 --- a/phed-file.h +++ b/phed-file.h @@ -4,6 +4,7 @@ void saveText(char *name, UBYTE *buffer) if(fp = fopen(name, "w")) { + buffer[strlen(buffer)] = '\0'; fwrite(buffer, sizeof(char), strlen(buffer), fp); fclose(fp); @@ -22,16 +23,18 @@ UBYTE *loadText(char *name) { char tmp[1025]; - int read = 1; + int read; - while(read > 0) + while(1) { read = fread(tmp, 1, 1024, fp); + tmp[read] = '\0'; + buffer = (char *) realloc(buffer, strlen(buffer) + read + 1); strcat(buffer, tmp); - buffer[strlen(buffer)+1] = '\0'; + buffer[strlen(buffer)] = '\0'; if(read < 1024) break; } diff --git a/phed-init.h b/phed-init.h index abf36c7..407c4ff 100644 --- a/phed-init.h +++ b/phed-init.h @@ -1,5 +1,6 @@ struct Library *WindowBase = NULL, *LayoutBase = NULL, + *RequesterBase = NULL, *TextFieldBase = NULL; void closeLibraries() @@ -7,6 +8,7 @@ void closeLibraries() if(WindowBase) CloseLibrary((struct Library *) WindowBase); if(TextFieldBase) CloseLibrary((struct Library *) TextFieldBase); if(LayoutBase) CloseLibrary((struct Library *) LayoutBase); + if(RequesterBase) CloseLibrary((struct Library *) RequesterBase); } @@ -20,7 +22,10 @@ BOOL openLibraries() { if(LayoutBase = (struct Library *) OpenLibrary("gadgets/layout.gadget", 0L)) { - ret = TRUE; + if(RequesterBase = (struct Library *) OpenLibrary("requester.class", 0L)) + { + ret = TRUE; + } } } } diff --git a/phed-req.h b/phed-req.h new file mode 100644 index 0000000..bc95f5d --- /dev/null +++ b/phed-req.h @@ -0,0 +1,32 @@ +Object *requesterNew(char *titel) +{ + Object *obj; + + obj = RequesterObject, + REQ_TitleText, titel, + EndMember; + + return obj; +} + +ULONG OpenRequesterTags(Object *obj, struct Window *win, ULONG Tag1, ...) +{ + struct orRequest msg[1]; + + msg->MethodID = RM_OPENREQ; + msg->or_Window = win; + msg->or_Screen = NULL; + msg->or_Attrs = (struct TagItem *)&Tag1; + + return DoMethodA(obj, (Msg)msg); +} + +ULONG beendenReq(char *text, Object *obj, struct Window *win) +{ + return OpenRequesterTags( obj, + win, + REQ_Type, REQTYPE_INFO, + REQ_BodyText, text, + REQ_GadgetText, "_Ja|_Nein|_Abbruch", + TAG_DONE); +} \ No newline at end of file diff --git a/phed.c b/phed.c index eca306a..1ee49f2 100644 --- a/phed.c +++ b/phed.c @@ -8,17 +8,20 @@ #include #include #include +#include #include #include +#include #include #include "phed-init.h" #include "phed-file.h" +#include "phed-req.h" -const char *version = "$VER: phED Version 0.1"; +static const char *version = "$VER: phED Version 0.2"; enum { @@ -31,27 +34,37 @@ int main(int argc, char *argv[]) struct Window *window; struct Gadget *gadgets[GID_LAST]; - Object *Win_Object; + Object *Win_Object, *beenden_object; ULONG signal, result; ULONG done = FALSE; - APTR text; - - char *buf; + char *buf, *titel; - if(argc > 0) + if(argc > 1) { - buf = loadText(argv[1]); + titel = (char *) malloc(strlen(argv[1])); + strcpy(titel, argv[1]); + titel[strlen(argv[1])] = '\0'; - text = &buf; + buf = loadText(argv[1]); } + else + { + titel = (char *) malloc(strlen("phED")); + strcpy(titel, "phED"); + titel[strlen("phED")] = '\0'; + + buf = (char *) malloc(0); + } if(openLibraries()) { + beenden_object = requesterNew("Beenden"); + Win_Object = WindowObject, WA_ScreenTitle, "Projekt Hirnfrei", - WA_Title, "phED", + WA_Title, titel, WA_SizeGadget, TRUE, WA_DepthGadget, TRUE, WA_DragBar, TRUE, @@ -74,7 +87,7 @@ int main(int argc, char *argv[]) { if(window = (struct Window *) RA_OpenWindow(Win_Object)) { - ULONG wait, changed; + ULONG wait, changed, ret; UBYTE *buffer; GetAttr(WINDOW_SigMask, Win_Object, &signal); @@ -88,30 +101,59 @@ int main(int argc, char *argv[]) { while((result = RA_HandleInput(Win_Object, NULL)) != WMHI_LASTMSG) { - switch(result) + switch(result & WMHI_CLASSMASK) { 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); + ret = beendenReq("\033cDer Text wurde verändert!\n\nSoll der Text gespeichert werden?", beenden_object, window); + + if(ret == 1) + { + buffer = (UBYTE *) DoGadgetMethod(gadgets[GID_TEXTEDITOR], window, NULL, GM_TEXTEDITOR_ExportText, NULL); - if(!argv[1]) saveText("unbenannt.txt", buffer); - else saveText(argv[1], buffer); + if(!argv[1]) saveText("unbenannt.txt", buffer); + else saveText(argv[1], buffer); + done = TRUE; + } + if(ret == 2) + { + done = TRUE; + } + if(ret == 0) + { + done = FALSE; + } } - - done = TRUE; + else done = TRUE; break; + + case WMHI_GADGETUP: + { + switch(result & WMHI_GADGETMASK) + { + case GID_TEXTEDITOR: + GetAttr(GA_TEXTEDITOR_HasChanged, gadgets[GID_TEXTEDITOR], &changed); + + if(changed == 1) printf("Geändert\n"); + if(changed == 0) printf("Nicht geändert\n"); + + break; + } + } } } } } } + DisposeObject(beenden_object); DisposeObject(Win_Object); } } closeLibraries(); + if(titel) free(titel); if(buf) free(buf); } \ No newline at end of file diff --git a/phed.debug b/phed.debug index 59167b0..afe6479 100644 Binary files a/phed.debug and b/phed.debug differ diff --git a/phed.o b/phed.o index b2efb5c..8c01f1f 100644 Binary files a/phed.o and b/phed.o differ diff --git a/unbenannt.txt b/unbenannt.txt index 7074200..299fd95 100644 --- a/unbenannt.txt +++ b/unbenannt.txt @@ -1 +1 @@ -Das ist doch doof \ No newline at end of file +Hello you bang bang! \ No newline at end of file