-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.cpp
More file actions
191 lines (176 loc) · 4.31 KB
/
main.cpp
File metadata and controls
191 lines (176 loc) · 4.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
// Copyright 2003 Ashley Wise
// University Of Illinois Urbana-Champaign
// awise@crhc.uiuc.edu
#include <FL/Fl.H>
#include <FL/fl_ask.H>
#include "MainWindow.h"
using namespace AshIDE;
using namespace Assembler;
int main(int argc, char **argv)
{
try
{
sProgramDir = CreateStandardPath(FileName(argv[0]).Path);
Fl::scheme("plastic");
MainWindow::pMainWindow = new MainWindow();
list<string> InputList;
#if defined DEFAULT_LANG_LC3
DefaultLang = Assembler::LangLC3;
#elif defined DEFAULT_LANG_LC3B
DefaultLang = Assembler::LangLC3b;
#else
DefaultLang = Assembler::LangNone;
#endif
for(int i = 1; i < argc; i++)
{
string sFileName(argv[i]);
if(sFileName.size() > 0 && sFileName[0] == '-')
{
//It's a command-line option
if(ToLower(sFileName) == "-lc3b")
DefaultLang = LangLC3b;
else if(ToLower(sFileName) == "-lc3")
DefaultLang = LangLC3;
else
fl_alert("Unrecognized command-line switch %.31s", sFileName.c_str());
continue;
}
else
InputList.push_back(sFileName);
}
for(list<string>::iterator InputIter = InputList.begin(); InputIter != InputList.end(); InputIter++)
{
if(ToLower(InputIter->substr(MIN(InputIter->size(), InputIter->find_last_of('.')))) == ".aprj")
TheMainWindow.OpenProject(*InputIter);
else
TheMainWindow.OpenFile(*InputIter);
}
return Fl::run();
}
catch(const char *sMsg)
{ //*NOTE: MSVC allows "char", but GCC requires "const"
fl_alert("AshIDE caught internal exception:%s", sMsg);
exit(-1);
}
catch(runtime_error e)
{
fl_alert("AshIDE caught internal exception:%s", e.what());
exit(-1);
}
}
/*
The following were used for debugging FLTK bugs to and reporting them on www.fltk.org
class SpecialWindow : public Fl_Double_Window
{
public:
Fl_Button *pB;
Fl_Double_Window *pDWNew;
SpecialWindow(unsigned int w, unsigned int h) : Fl_Double_Window(w, h)
{
pB = new Fl_Button(50,50,200,200);
pB->callback(ButtonCB, this);
end();
callback(CloseCB, this);
show();
}
int handle(int Event)
{
int RetVal = Fl_Double_Window::handle(Event);
switch(Event)
{
case FL_FOCUS:
//*NOTE: Some bug/feature in FLTK causes the Status widget to always get
//the focus instead of the text editor
pB->take_focus();
}
return RetVal;
}
static void CloseCB(Fl_Widget *pW, void *pV)
{
if(pW != pV)
fl_alert("Close baadfood");
//delete ((SpecialWindow *)pW)->pDWNew;
((SpecialWindow *)pW)->hide();
delete (SpecialWindow *)pW;
}
static void ButtonCB(Fl_Widget *pW, void *pV)
{
((SpecialWindow *)pV)->pDWNew = new Fl_Double_Window(200,200);
((SpecialWindow *)pV)->pDWNew->end();
((SpecialWindow *)pV)->pDWNew->callback(CloseNewCB, ((SpecialWindow *)pV)->pDWNew);
((SpecialWindow *)pV)->pDWNew->show();
}
static void CloseNewCB(Fl_Widget *pW, void *pV)
{
if(pW != pV)
fl_alert("CloseNew baadfood");
((Fl_Double_Window *)pW)->hide();
delete (Fl_Double_Window *)pW;
}
};
SpecialWindow *pDWOrig = new SpecialWindow(300, 300);
return Fl::run();
class SpecialEditor : public Fl_Text_Editor
{
public:
Fl_Window *pDlg;
SpecialEditor(unsigned int x, unsigned int y, unsigned int w, unsigned int h) : Fl_Text_Editor(x, y, w, h)
{
pDlg = new Fl_Window(200, 200);
Fl_Button *pB = new Fl_Button(50,50,100,50);
pB->callback(ButtonCB, this);
pDlg->end();
pDlg->callback(CloseDlgCB, this);
pDlg->set_non_modal();
end();
}
void ShowDlg()
{
pDlg->show();
}
static void ButtonCB(Fl_Widget *pW, void *pV)
{
fl_alert("");
}
static void CloseDlgCB(Fl_Widget *pW, void *pV)
{
((SpecialEditor *)pV)->pDlg->hide();
((SpecialEditor *)pV)->parent()->show();
}
};
class SpecialWindow : public Fl_Double_Window
{
public:
Fl_Button *pB;
SpecialEditor *pTE;
SpecialWindow(unsigned int w, unsigned int h) : Fl_Double_Window(w, h)
{
pB = new Fl_Button(50,50,200,50);
pB->callback(ButtonCB, this);
pTE = new SpecialEditor(50, 150, 200, 50);
end();
callback(CloseCB, this);
show();
}
int handle(int Event)
{
int RetVal = Fl_Double_Window::handle(Event);
switch(Event)
{
case FL_FOCUS:
pB->take_focus();
}
return RetVal;
}
static void CloseCB(Fl_Widget *pW, void *pV)
{
//delete ((SpecialWindow *)pW)->pDWNew;
((SpecialWindow *)pW)->hide();
delete (SpecialWindow *)pW;
}
static void ButtonCB(Fl_Widget *pW, void *pV)
{
((SpecialWindow *)pV)->pTE->ShowDlg();
}
};
*/