added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / workbench / utilities / More / misc.c
blob44a632546384676289ad2677a83bf46a6134ad6f
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 /*********************************************************************************************/
8 #include <intuition/intuition.h>
9 #include <libraries/asl.h>
10 #include <libraries/gadtools.h>
11 #include <proto/exec.h>
12 #include <proto/dos.h>
13 #include <proto/intuition.h>
14 #include <proto/gadtools.h>
15 #include <proto/asl.h>
17 #define CATCOMP_NUMBERS
18 #include "strings.h"
20 #include "global.h"
21 #include "version.h"
23 #include <string.h>
25 const char *versionstring = VERSIONSTR;
27 /*********************************************************************************************/
29 struct Library *AslBase;
31 /*********************************************************************************************/
33 static struct NewMenu nm[] =
35 {NM_TITLE, (STRPTR)MSG_MEN_PROJECT },
36 {NM_ITEM, (STRPTR)MSG_MEN_PROJECT_OPEN },
37 {NM_ITEM, NM_BARLABEL },
38 {NM_ITEM, (STRPTR)MSG_MEN_PROJECT_SAVEAS },
39 {NM_ITEM, NM_BARLABEL },
40 {NM_ITEM, (STRPTR)MSG_MEN_PROJECT_PRINT },
41 {NM_ITEM, (STRPTR)MSG_MEN_PROJECT_ABOUT },
42 {NM_ITEM, NM_BARLABEL },
43 {NM_ITEM, (STRPTR)MSG_MEN_PROJECT_QUIT },
44 {NM_TITLE, (STRPTR)MSG_MEN_NAVIGATION },
45 {NM_ITEM, (STRPTR)MSG_MEN_NAVIGATION_FIND },
46 {NM_ITEM, (STRPTR)MSG_MEN_NAVIGATION_FIND_NEXT },
47 {NM_ITEM, (STRPTR)MSG_MEN_NAVIGATION_FIND_PREV },
48 {NM_ITEM, NM_BARLABEL },
49 {NM_ITEM, (STRPTR)MSG_MEN_NAVIGATION_JUMP },
50 {NM_END}
53 /*********************************************************************************************/
55 void InitMenus(void)
57 struct NewMenu *actnm = nm;
59 for(actnm = nm; actnm->nm_Type != NM_END; actnm++)
61 if (actnm->nm_Label != NM_BARLABEL)
63 ULONG id = (ULONG)actnm->nm_Label;
64 CONST_STRPTR str = MSG(id);
66 if (actnm->nm_Type == NM_TITLE)
68 actnm->nm_Label = str;
69 } else {
70 actnm->nm_Label = str + 2;
71 if (str[0] != ' ') actnm->nm_CommKey = str;
73 actnm->nm_UserData = (APTR)id;
75 } /* if (actnm->nm_Label != NM_BARLABEL) */
77 } /* for(actnm = nm; nm->nm_Type != NM_END; nm++) */
81 /*********************************************************************************************/
83 void MakeMenus(void)
85 menus = CreateMenusA(nm, NULL);
86 if (!menus) Cleanup(MSG(MSG_CANT_CREATE_MENUS));
88 if (!LayoutMenusA(menus, vi, NULL)) Cleanup(MSG(MSG_CANT_CREATE_MENUS));
92 /*********************************************************************************************/
94 void KillMenus(void)
96 if (win) ClearMenuStrip(win);
97 if (menus) FreeMenus(menus);
99 menus = NULL;
102 /*********************************************************************************************/
104 STRPTR GetFile(BOOL open)
106 static UBYTE pathbuffer[300];
107 static UBYTE filebuffer[300];
108 struct FileRequester *req;
109 STRPTR retval = NULL;
111 AslBase = OpenLibrary("asl.library", 39);
112 if (AslBase)
114 filebuffer[299] = 0;
115 pathbuffer[299] = 0;
117 strncpy(filebuffer, FilePart(filenamebuffer), 299);
118 strncpy(pathbuffer, filenamebuffer, 299);
119 *(FilePart(pathbuffer)) = 0;
121 req = AllocAslRequestTags(ASL_FileRequest, ASLFR_TitleText , (IPTR) open ? MSG(MSG_ASL_OPEN_TITLE) : MSG(MSG_ASL_SAVE_TITLE),
122 ASLFR_DoPatterns , TRUE ,
123 ASLFR_InitialFile , (IPTR)filebuffer ,
124 ASLFR_InitialDrawer, (IPTR)pathbuffer ,
125 TAG_DONE);
126 if (req)
128 if (AslRequest(req, NULL))
130 strncpy(filebuffer, req->fr_Drawer, 299);
131 AddPart(filebuffer, req->fr_File, 299);
133 retval = filebuffer;
135 } /* if (AslRequest(req, NULL) */
137 FreeAslRequest(req);
139 } /* if (req) */
141 CloseLibrary(AslBase);
143 } /* if (AslBase) */
145 return retval;
148 /*********************************************************************************************/
150 void About(void)
152 struct EasyStruct es;
154 es.es_StructSize = sizeof(es);
155 es.es_Flags = 0;
156 es.es_Title = MSG(MSG_ABOUT_TITLE);
157 es.es_TextFormat = MSG(MSG_ABOUT);
158 es.es_GadgetFormat = MSG(MSG_CONTINUE);
160 EasyRequest(win, &es, NULL, (IPTR)VERSION,
161 (IPTR)REVISION,
162 (IPTR)DATESTR,
163 (IPTR)"2005-2007",
164 (IPTR)"AROS Development Team");
168 /*********************************************************************************************/