added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / workbench / prefs / serial / misc.c
blob0c7292ba04e14095b1ab7174b6224aa134509a87
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
9 /*********************************************************************************************/
11 #include "global.h"
12 #include "version.h"
14 #include <string.h>
16 /*********************************************************************************************/
18 static struct NewMenu nm[] =
20 {NM_TITLE, (STRPTR)MSG_MEN_PROJECT },
21 {NM_ITEM, (STRPTR)MSG_MEN_PROJECT_OPEN },
22 {NM_ITEM, (STRPTR)MSG_MEN_PROJECT_SAVEAS },
23 {NM_ITEM, NM_BARLABEL },
24 {NM_ITEM, (STRPTR)MSG_MEN_PROJECT_QUIT },
25 {NM_TITLE, (STRPTR)MSG_MEN_EDIT },
26 {NM_ITEM, (STRPTR)MSG_MEN_EDIT_DEFAULT },
27 {NM_ITEM, (STRPTR)MSG_MEN_EDIT_LASTSAVED },
28 {NM_ITEM, (STRPTR)MSG_MEN_EDIT_RESTORE },
29 {NM_TITLE, (STRPTR)MSG_MEN_SETTINGS },
30 {NM_ITEM, (STRPTR)MSG_MEN_SETTINGS_CREATEICONS, NULL, CHECKIT | MENUTOGGLE },
31 {NM_END}
34 /*********************************************************************************************/
36 void InitMenus(void)
38 struct NewMenu *actnm = nm;
40 for(actnm = nm; actnm->nm_Type != NM_END; actnm++)
42 if (actnm->nm_Label != NM_BARLABEL)
44 ULONG id = (ULONG)actnm->nm_Label;
45 CONST_STRPTR str = MSG(id);
47 if (actnm->nm_Type == NM_TITLE)
49 actnm->nm_Label = str;
50 } else {
51 actnm->nm_Label = str + 2;
52 if (str[0] != ' ') actnm->nm_CommKey = str;
54 actnm->nm_UserData = (APTR)id;
56 } /* if (actnm->nm_Label != NM_BARLABEL) */
58 } /* for(actnm = nm; nm->nm_Type != NM_END; nm++) */
62 /*********************************************************************************************/
64 void MakeMenus(void)
66 struct TagItem menu_tags[] =
68 {GTMN_NewLookMenus, TRUE},
69 {TAG_DONE }
72 menus = CreateMenusA(nm, NULL);
73 if (!menus) Cleanup(MSG(MSG_CANT_CREATE_MENUS));
75 if (!LayoutMenusA(menus, vi, menu_tags)) Cleanup(MSG(MSG_CANT_CREATE_MENUS));
79 /*********************************************************************************************/
81 void KillMenus(void)
83 if (win) ClearMenuStrip(win);
84 if (menus) FreeMenus(menus);
86 menus = NULL;
89 /*********************************************************************************************/
91 void SetMenuFlags(void)
93 if (win) ClearMenuStrip(win);
94 if (win) ResetMenuStrip(win, menus);
97 /*********************************************************************************************/
99 STRPTR GetFile(CONST_STRPTR title, CONST_STRPTR dir, BOOL savemode)
101 static UBYTE filebuffer[300];
102 struct FileRequester *req;
103 STRPTR retval = NULL;
105 AslBase = OpenLibrary("asl.library", 39);
106 if (AslBase)
108 req = AllocAslRequestTags(ASL_FileRequest, ASLFR_TitleText , (IPTR)title,
109 ASLFR_DoPatterns , TRUE ,
110 ASLFR_InitialDrawer, (IPTR)dir ,
111 ASLFR_DoSaveMode , savemode ,
112 TAG_DONE);
113 if (req)
115 if (AslRequest(req, NULL))
117 strncpy(filebuffer, req->fr_Drawer, 299);
118 AddPart(filebuffer, req->fr_File, 299);
120 retval = filebuffer;
122 } /* if (AslRequest(req, NULL) */
124 FreeAslRequest(req);
126 } /* if (req) */
128 CloseLibrary(AslBase);
130 } /* if (AslBase) */
132 return retval;
135 /*********************************************************************************************/
137 struct Node *FindListNode(struct List *list, WORD which)
139 struct Node *node = NULL;
141 if (which >= 0)
143 for(node = list->lh_Head; node->ln_Succ && which; node = node->ln_Succ, which--)
146 if (!node->ln_Succ) node = NULL;
149 return node;
152 /*********************************************************************************************/
154 void SortInNode(struct List *list, struct Node *node)
156 struct Node *sort, *prev = NULL;
158 ForeachNode(list, sort)
160 if (Stricmp(node->ln_Name, sort->ln_Name) < 0) break;
161 prev = sort;
164 Insert(list, node, prev);
167 /*********************************************************************************************/