Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
clean-and-itasks
clm
Commits
89d36a54
Commit
89d36a54
authored
Oct 08, 2003
by
John van Groningen
Browse files
add EdMacintosh folder
parent
2da1d123
Changes
14
Expand all
Hide whitespace changes
Inline
Side-by-side
Clean08IDE/EdMacintosh/CleanIDE.icl
0 → 100644
View file @
89d36a54
module
CleanIDE
;
import
StdInt
,
StdString
,
StdClass
,
StdArray
;
import
deltaTimer
;
from
deltaWindow
import
DrawInActiveWindow
;
from
EdShift
import
shift_selection_right
,
shift_selection_left
;
import
EdFileMenu
,
EdEditMenu
,
EdSearchMenu
,
EdCommandsMenu
,
EdProjectMenu
,
EdOptionsMenu1
,
EdWindowsMenu
,
EdOptionsMenu2
,
EdSysOptions
,
EdProgramState
,
EdDraw
,
EdFiles
,
LinkOptionsDialogue
,
EdCleanSystem
;
::
IOFunction
*
p
:==
p
->
*((
IOState
p
)
->
*(
p
,
IOState
p
));
Start
::
!*
World
->
*
World
;
Start
world
=
world4
;
where
{
(
fullApplicationPath
,
world0
)
=
accFiles
GetFullApplicationPath
world
;
(
editor0
,
world1
)
=
accFiles
(
InitEditor
fullApplicationPath
)
world0
;
(
editor1
,
world2
)
=
accFiles
(
ReadDefaultSettings
editor0
)
world1
;
(
about_dialog
,
world3
)
=
accFiles
(\
f
->
MakeAboutDialog
"Clean Programming Environment"
f
Help
)
world2
;
inistate
=
{
editor
=
editor1
};
about
=
DialogSystem
[
about_dialog
];
(_,
world4
)
=
StartIO
[
about
,
menus
,
timer
:
SystemDependentDevices
]
inistate
SystemDependentInitialIO
world3
;
menus
=
MenuSystem
(
AddSysMenuItem
MFreeID
IFreeID
[
file
,
edit
,
search
,
commands
,
project
,
options
,
windows
]);
file
=
PullDownMenu
MFileID
"File"
Able
[
MenuItem
INewID
"New..."
(
Key
'N'
)
Able
New
,
MenuItem
IOpenID
"Open..."
(
Key
'O'
)
Able
Open
,
MenuItem
ICloseID
"Close"
(
Key
'W'
)
Unable
Close
,
MenuSeparator
,
MenuItem
IOpDefID
"Open Definition..."
(
Key
'D'
)
Able
(
OpenDefOrImp
True
False
)
,
MenuItem
IOpImpID
"Open Implementation..."
(
Key
'I'
)
Able
(
OpenDefOrImp
False
False
)
,
MenuItem
ISwapID
"Open Other"
(
Key
'/'
)
Unable
OpenOther
,
MenuSeparator
,
MenuItem
ISaveID
"Save"
(
Key
'S'
)
Unable
Save
,
MenuItem
ISavesID
"Save As..."
NoKey
Unable
SaveAs
:
IfUnixSystem
[
MenuItem
IReverID
"Revert"
NoKey
Unable
Revert
,
MenuSeparator
,
MenuItem
IQuitID
"Quit"
(
Key
'Q'
)
Able
Quit
]
[
MenuItem
IPrintID
"Print"
(
Key
'P'
)
Unable
Print
,
MenuItem
IReverID
"Revert"
NoKey
Unable
Revert
,
MenuSeparator
,
MenuItem
IQuitID
"Quit"
(
Key
'Q'
)
Able
Quit
]
];
edit
=
PullDownMenu
MEditID
"Edit"
Able
[
MenuItem
IUndoID
"Undo"
(
Key
'Z'
)
Unable
Undo
,
MenuSeparator
,
MenuItem
ICutID
"Cut"
(
Key
'X'
)
Unable
Cut
,
MenuItem
ICopyID
"Copy"
(
Key
'C'
)
Unable
Copy
,
MenuItem
IPasteID
"Paste"
(
Key
'V'
)
Unable
Paste
,
MenuItem
IClearID
"Clear"
NoKey
Unable
Clear
,
MenuSeparator
,
MenuItem
IShiftLeftID
"Shift Left"
(
Key
'['
)
Unable
shift_selection_left
,
MenuItem
IShiftRightID
"Shift Right"
(
Key
']'
)
Unable
shift_selection_right
,
MenuItem
IBalanID
"Balance"
(
Key
'B'
)
Unable
Balance
,
MenuItem
ISelecID
"Select All"
(
Key
'A'
)
Unable
SelectAll
,
MenuSeparator
,
MenuItem
IFormaID
"Format..."
(
Key
'J'
)
Unable
Format
];
search
=
PullDownMenu
MSearcID
"Search"
Able
[
MenuItem
IFindID
"Find..."
(
Key
'F'
)
Unable
Find
,
MenuItem
IFindNID
"Find Next"
(
Key
'G'
)
Unable
(
ShiftKeyModifiedFunction
FindNext
),
MenuItem
IFindSID
"Find Selection"
(
Key
'H'
/*';'*/
)
Unable
(
ShiftKeyModifiedFunction
FindSelection
),
MenuItem
IReplaID
"Replace & Find"
(
Key
'T'
)
Unable
(
ShiftKeyModifiedFunction
ReplaceAndFind
),
MenuSeparator
,
MenuItem
IFindEID
"Find Error"
(
Key
'E'
)
Unable
(
ShiftKeyModifiedFunction
FindError
),
MenuItem
IFindIdID
"Find Def & Imp"
(
Key
'='
)
Unable
FindIdentifier
,
MenuItem
IFindDID
"Find Definition"
(
Key
'L'
)
Unable
(
FindDefOrImp
True
),
MenuItem
IFindIID
"Find Implementation"
(
Key
'M'
)
Unable
(
FindDefOrImp
False
),
MenuSeparator
,
MenuItem
IGotoCID
"Goto Cursor"
NoKey
Unable
GotoCursor
,
MenuItem
IGotoLID
"Goto Line..."
NoKey
Unable
GotoLine
];
commands
=
PullDownMenu
MCommaID
"Commands"
Able
[
MenuItem
ICompiID
"Compile"
(
Key
'K'
)
Unable
Compiler
,
MenuItem
ICheckID
"Check"
(
Key
'Y'
)
Unable
CheckSyntax
,
MenuItem
IGenerID
"Generate Assembly"
NoKey
Unable
GenerateAssembly
,
MenuSeparator
,
MenuItem
IBriUDID
"Bring Up To Date"
(
Key
'U'
)
Unable
BringUpToDate
,
MenuItem
IExecuID
"Run"
(
Key
'R'
)
Unable
Run
];
project
=
PullDownMenu
MProjeID
"Project"
Able
[
MenuItem
INewPrID
"New Project"
NoKey
Unable
NewProject
,
MenuItem
IOpePrID
"Open Project..."
NoKey
Able
OpenProject
,
MenuItem
ISetPrID
"Set Main Module"
NoKey
Unable
SetProject
,
MenuItem
ICloPrID
"Close Project"
NoKey
Unable
CloseProject
,
MenuSeparator
,
MenuItemGroup
IWinPrjID
[]
];
options
=
PullDownMenu
MOptioID
"Options"
Able
[
MenuItem
ICleanID
"Clean Compiler..."
NoKey
Able
CCompiler
,
MenuItem
ICodeGID
"Code Generator..."
NoKey
Able
CodeGenerator
,
MenuItem
ILinkOptionsID
"Link Options..."
NoKey
Unable
LinkOptionsDialogue
,
MenuItem
IAppliID
"Application..."
NoKey
Able
Application
,
MenuItem
IProjeID
"Project Manager..."
NoKey
Able
ProjectManager
,
MenuSeparator
,
MenuItem
IPathsID
"Paths..."
NoKey
Able
Paths
];
windows
=
PullDownMenu
MWindoID
"Windows"
Able
[
MenuItem
INextWID
"Next Window"
(
Key
'\\'
)
Unable
NextWindow
,
MenuItem
IShowCID
"Show Clipboard"
NoKey
Able
ShowClipboard
,
MenuItem
IHelpID
"Help..."
NoKey
Able
Help
,
MenuSeparator
,
MenuItem
ISaveaID
"Save All"
NoKey
Unable
SaveAll
,
MenuItem
IClosaID
"Close All"
NoKey
Unable
CloseAll
,
MenuSeparator
,
MenuItemGroup
IWindoID
[]
];
timer
=
TimerSystem
[
Timer
TimerID
Unable
BlinkRate
BlinkCursor
];
};
ShiftKeyModifiedFunction
::
(
Bool
->
IOFunction
*
p
)
*
p
(
IOState
*
p
)
->
(*
p
,
IOState
*
p
);
ShiftKeyModifiedFunction
f
programState
ioState
#
(
shiftKeyIsDown
,
ioState
)
=
ShiftKeyIsDown
ioState
=
f
shiftKeyIsDown
programState
ioState
;
BlinkCursor
::
!
TimerState
!
ProgState
!
IO
->
ProgIO
;
BlinkCursor
state
prog
=:{
editor
=
ed
=:{
editwindows
}}
io
|
blink
>
0
=
({
prog
&
editor
={
ed
&
editwindows
=
editwindows`
}},
SetTimerInterval
TimerID
blink
io2
);
{
editwindows`
=
SetFrontWindow
front`
editwindows
;
front`
=
{
front
&
wtext
={
front
.
wtext
&
cursorpos
={
cursorpos
&
vis
=
not
cursorpos
.
vis
}}};
}
=
(
prog
,
CloseTimer
TimerID
io2
);
where
{
(_,
front
)
=
GetFrontWindow
editwindows
;
cursorpos
=
front
.
wtext
.
cursorpos
;
metrics
=
front
.
wformat
.
metrics
;
(
blink
,
io2
)
=
GetTimerBlinkInterval
(
DrawInActiveWindow
[
DrawCursor
cursorpos
(
metrics
.
ascent
+
metrics
.
descent
)
metrics
.
lead
]
io
);
}
Clean08IDE/EdMacintosh/CleanIDE.prj
0 → 100644
View file @
89d36a54
This diff is collapsed.
Click to expand it.
Clean08IDE/EdMacintosh/EdCommandsMenu.icl
0 → 100644
View file @
89d36a54
implementation
module
EdCommandsMenu
;
/* The commands of the Command menu */
import
StdBool
;
import
EdProgramState
,
EdProject
,
EdProjectUtils
,
EdPath
,
EdDialogs
,
EdWindows
,
EdSupport
,
EdCleanSystem
,
EdWindowsMenu
;
(
THEN2
)
infixl
;
(
THEN2
)
s
f
:==
f
e1
e2
;
{
(
e1
,
e2
)
=
s
};
::
CompileFun
:==
Pathname
->
Project
->
SetMadeProjectFun
->
ProgState
->
*
(
IO
->
ProgIO
);
::
SetMadeProjectFun`
:==
Pathname
->
Bool
->
Bool
->
ProgState
->
*(
IO
->
ProgIO
);
/*
CompileCHeader :: !ProgState !IO -> ProgIO;
CompileCHeader prog=:{editor={editwindows}} io
# (_,front) = GetFrontWindow editwindows;
# window_path = front.wstate.pathname;
# h_file_name = RemovePath window_path;
# directory_name = window_path % (0,size window_path-1-size h_file_name);
# (prog,io) = CloseWindow "" ErrorWdID prog io;
# ((prog,io),ok) = SaveTheWindows True "" prog io;
| not ok
= (prog,io);
# (h_errors,world) = accFiles (compile_header directory_name (h_file_name % (0,size h_file_name-3))) prog.world;
# prog = {prog & world=world};
= case h_errors of {
[] -> (prog,io);
_ # error_strings = h_errors_to_error_string h_errors;
-> UpdateInfoWindow ErrorWdID (Text_StringsToText error_strings) prog io;
};
h_errors_to_error_string [] = Nil;
h_errors_to_error_string [HError string line:l]
| line<>0
= string +++" [line: "+++toString line+++"]\n" :! h_errors_to_error_string l;
= string +++"\n" :! h_errors_to_error_string l;
*/
// Device function for the Compile Command
Compiler
::
!
ProgState
!
IO
->
ProgIO
;
Compiler
prog
io
=
Process
"compiling"
(
CompileProjectModule
Compilation
)
prog
io
;
CheckSyntax
::
!
ProgState
!
IO
->
ProgIO
;
CheckSyntax
prog
io
=
Process
"checking"
(
CompileProjectModule
SyntaxCheck
)
prog
io
;
// Device function for the Generate Assembly Command
GenerateAssembly
::
!
ProgState
!
IO
->
ProgIO
;
GenerateAssembly
prog
io
=
Process
"generating code"
(
CompileAndGenCodeProjectModule
AsmGeneration
)
prog
io
;
// Device function for the BringUpToDate Command
BringUpToDate
::
!
ProgState
!
IO
->
ProgIO
;
BringUpToDate
prog
io
#
(
prio1
,
ok
)
=
SaveTheWindows
True
"bringing the project up to date"
prog
io
;
|
ok
=
prio1
THEN2
BringProjectUpToDate
uptodatemsg
=
prio1
;
where
{
uptodatemsg
::
Pathname
Bool
Bool
ProgState
IO
->
ProgIO
;
uptodatemsg
path
linked
ok
prog
io
|
linked
||
not
ok
=
(
prog
,
CloseInfo
io
);
=
ShowInfo
True
True
[
"Project Is Up To Date"
]
prog
io
;
};
// Device function for the Execute Command
Run
::
!
ProgState
!
IO
->
ProgIO
;
Run
prog
io
|
ok
=
prio1
THEN2
BringProjectUpToDate
run
;
=
prio1
;
where
{
(
prio1
,
ok
)
=
SaveTheWindows
True
"running"
prog
io
;
run
::
Pathname
Bool
Bool
ProgState
IO
->
ProgIO
;
run
path
linked
ok
prog
io
|
ok
=
RunProgram
path
prog
io1
;
=
(
prog
,
io1
);
where
{
io1
=
CloseInfo
io
;
};
};
/* Auxilary function used by Run to actuallly run the program */
RunProgram
::
!
Pathname
!
ProgState
!
IO
->
ProgIO
;
RunProgram
path
prog
=:{
editor
={
project
}}
io
=
prio0
;
where
{
ao
=
PR_GetApplicationOptions
project
;
(
prio0
,_)
=
Execute
(
UpdateInfoWindow
ErrorWdID
)
path
ao
prog
io
;
};
/* Auxilary function used by Compile and GenerateAssembly to compile / generate code for the
module in the front window */
Process
::
!
String
!
CompileFun
!
ProgState
!
IO
->
ProgIO
;
Process
msg
compile
prog
=:{
editor
={
editwindows
,
project
,
defaults
={
edit
,
cgo
,
ao
,
po
,
linkOptions
}}}
io
|
not
ok
=
(
prog1
,
io1
);
=
CloseWindow
""
ErrorWdID
prog1
io1
THEN2
CloseWindow
""
TypeWdID
THEN2
compile
winpath
project`
setproject
;
where
{
(
prog1
,
io1
,
ok
)
=
savewindows
msg
prog
io
;
project`
|
prj_mod
=
project
;
=
PR_NewProject
winpath
edit
wco
cgo
ao
po
Nil
linkOptions
;
modname
=
GetModuleName
winpath
;
(
prj_mod
,_)
=
PR_GetModuleInfo
modname
project
;
winpath
=
front
.
wstate
.
pathname
;
wco
=
front
.
wstate
.
WinState
.
co
;
(_,
front
)
=
GetFrontWindow
editwindows
;
savewindows
::
!
String
!
ProgState
!
IO
->
(!
ProgState
,
!
IO
,
!
Bool
);
savewindows
msg
prog
io
|
not
ok
=
(
prog1
,
io1
,
False
);
=
(
prog2
,
io1
,
True
);
where
{
prog2
=
{
prog1
&
editor
={
Editor
|
prog1
.
editor
&
project
=
PR_InitProject
}};
(
prio0
,
ok
)
=
SaveTheWindows
True
msg
prog
io
;
(
prog1
,
io1
)
=
prio0
;
};
setproject
::
Bool
Bool
Project
ProgState
IO
->
ProgIO
;
setproject
ok
newpaths
newproject
prog
=:{
editor
}
io
|
prj_mod
=
UpdateProjectWindowAndSaveProjectFile
newproject
prog
io1
;
=
({
prog
&
editor
={
Editor
|
editor
&
project
=
project
}},
io1
);
where
{
io1
=
CloseInfo
io
;
};
};
/* Auxilary function used by Run and BringUpToDate to generate an up to date executable for the
current project / .icl module in the front window */
BringProjectUpToDate
::
!
SetMadeProjectFun`
!
ProgState
!
IO
->
ProgIO
;
BringProjectUpToDate
uptodate
prog
=:{
editor
=
ed
=:{
editwindows
,
project
,
execwdid
,
defaults
={
edit
,
cgo
,
ao
,
po
,
linkOptions
}}}
io
=
CloseWindow
""
ErrorWdID
prog0
io
THEN2
CloseWindow
""
TypeWdID
THEN2
MakeProject
project`
uptodate`
;
where
{
prog0
=
{
prog
&
editor
={
Editor
|
ed
&
project
=
PR_InitProject
}};
project`
|
projectset
=
project
;
=
PR_NewProject
winpath
weo
wco
cgo
ao
po
Nil
linkOptions
;
path
|
projectset
=
MakeExecPathname
root
;
=
MakeExecPathname
winpath
;
winpath
=
mainwd
.
wstate
.
pathname
;
root
=
PR_GetRootPathName
project
;
wco
=
mainwd
.
wstate
.
WinState
.
co
;
weo
=
{
edit
&
eo
=
EW_GetEditOptions
mainwd
};
projectset
=
PR_ProjectSet
project
;
mainwd
=
GetWindow
execwdid
editwindows
;
uptodate`
::
Bool
Bool
Project
ProgState
IO
->
ProgIO
;
uptodate`
compiled
ok
project
prog
io
|
projectset
=
UpdateProjectWindowAndSaveProjectFile
project
prog
io
THEN2
uptodate
path
compiled
ok
=
uptodate
path
compiled
ok
prog
io
;
};
Clean08IDE/EdMacintosh/EdFileMenu.icl
0 → 100644
View file @
89d36a54
implementation
module
EdFileMenu
;
/* The commands of the File menu */
import
StdClass
,
StdString
,
StdInt
,
StdBool
,
StdTuple
,
StdArray
;
import
deltaEventIO
,
deltaWindow
,
deltaDialog
,
deltaFileSelect
,
deltaIOState
;
import
EdProgramState
,
EdWindows
,
EdFiles
,
EdDialogs
,
EdProject
,
EdPath
,
EdTextWindow
,
EdDrawWindow
,
EdMenuItems
,
EdSupport
,
EdDialogs
,
EdLists
,
EdParse
,
EdText
,
EdProjectUtils
;
import
deltaPrintText
;
from
EdCleanSystem
import
QuitCleanCompiler
;
OKID
:==
1
;
CancelID
:==
2
;
// The device function for the New command
New
::
!
ProgState
!
IO
->
ProgIO
;
New
prog
io
#
(
save
,
newname
,
prog
,
io
)
=
EdSelectOutputFile
"Save As:"
"Untitled"
prog
io
;
|
not
save
=
(
prog
,
io
);
#!
newlines
=
prog
.
editor
.
defaults
.
edit
.
eo
.
EditOptions
.
newlines
;
// phew!
#
(
saved
,
io
)
=
accFiles
(
SaveFile
newname
newlines
EmptyText
)
io
;
|
not
saved
=
AlertDialog
[
"The file could not be saved because"
,
"of a file I/O error."
]
prog
io
;
// otherwise
=
OpenEdWindow
newname
EmptyTSel
1
(
NoMixedNewlines
,
newlines
)
EmptyText
prog
io
;
// The device function for the Open command
Open
::
!
ProgState
!
IO
->
ProgIO
;
Open
ps
io0
|
not
open
=
(
ps2
,
io1
);
=
OpenFile
pathname
ps2
io1
;
{}{
(
open
,
pathname
,
ps2
,
io1
)
=
EdSelectInputFile
ps
io0
;
};
OpenFile
::
!
String
!
ProgState
!
IO
->
ProgIO
;
OpenFile
pathname
prog
=:{
editor
=
ed
=:{
editwindows
}}
io
|
is_help
=
HelpFileAlert
prog
io
;
|
exists
=
SetThisWindow
id
EmptyTSel
prog
io
;
|
not
good
=
(
AlertDialog
[
"The file
\"
"
+++
name
+++
"
\"
"
,
"could not be opened."
]
prog
io`
);
=
OpenEdWindow
pathname
EmptyTSel
nrlines
newlines
text
prog
io`
;
{}{
((
good
,
text
,
nrlines
,
newlines
),
io`
)=
accFiles
(
ReadFile
pathname
)
io
;
(
exists
,
id
)
=
IsExistingPathname
pathname
editwindows
;
name
=
RemovePath
pathname
;
is_help
=
name
==
HelpFile
;
};
/* Auxiliary function for the New and Open commands */
OpenEdWindow
::
!
Pathname
!
PartTSel
!
NrLines
(
MixedNewlines
,
!
NewlineConvention
)
!
Text
!
ProgState
!
IO
->
ProgIO
;
OpenEdWindow
pathname
tsel
nrlines
(
mixed
,
newlines
)
text
prog
io
#
(
prog
,
io
)
=
CheckMixedNewlines
pathname
mixed
prog
io
#
((
prog
,
io
),
pos
,
eo
,
co
)
=
GetEdit_and_CompilerOptions
pathname
prog
io
;
=
OpenEditWindow
pathname
pos
{
EditOptions
|
eo
&
newlines
=
newlines
}
co
tsel
nrlines
text
prog
io
;
// The device function for the Open Definition/OpenImplementation command
OpenDefOrImp
::
!
Bool
!
Bool
!
ProgState
!
IO
->
ProgIO
;
OpenDefOrImp
def
moduleNameSelected
pstate
=:{
editor
=
editor
=:{
editwindows
}}
io
|
moduleNameSelected
=
OpenModule
pathname
EmptyTSel
{
pstate
&
editor
=
editor`
}
io
;
|
otherwise
=
OpenModuleDialog
(
if
def
".dcl"
".icl"
)
{
pstate
&
editor
=
editor`
}
io
;
where
{
editor`
=
{
editor
&
editwindows
=
editwindows`
};
pathname
|
def
=
MakeDefPathname
clipString
;
=
MakeImpPathname
clipString
;
(
front`
,
clip
)
=
CopyText
front
selection
;
clipString
=
Singleton
clip
;
editwindows`
=
SetFrontWindow
front`
editwindows
;
(_,
front
)
=
GetFrontWindow
editwindows
;
selection
=
front
.
wtext
.
WinText
.
selection
.
tsel
;
};
POTitleID
:==
10
;
PSCTitleID
:==
10
;
DOpenTitleID
:==
110
;
DOpenEditID
:==
111
;
DOpenFileCancelCID
:==
110
;
DOpenFileOKCID
:==
111
;
OpenModuleDialog
::
String
ProgState
IO
->
ProgIO
;
OpenModuleDialog
string
pstate
io
=
OpenModalDialog
dialog
pstate
io
;
where
{
dialog
=
CommandDialog
POTitleID
"Open Module"
[]
DOpenFileOKCID
[
title
,
edit
,
cancel
,
ok
];
title
=
StaticText
DOpenTitleID
Left
"Open:"
;
edit
=
EditText
DOpenEditID
(
RightTo
DOpenTitleID
)
(
MM
80.0
)
1
string
;
cancel
=
DialogButton
DOpenFileCancelCID
Left
"Cancel"
Able
Cancel
;
ok
=
DialogButton
DOpenFileOKCID
(
RightTo
DOpenFileCancelCID
)
"OK"
Able
OKOpenModule
;
}
OKOpenModule
::
!
DialogInfo
!
ProgState
!
IO
->
ProgIO
;
OKOpenModule
dialog
pstate
io
=
OpenModule
pathname
EmptyTSel
pstate
(
ActivateCurrentWindow
(
CloseActiveDialog
io
));
where
{
pathname
=
GetEditText
DOpenEditID
dialog
;
}
// The device function for the OpenOther command
OpenOther
::
!
ProgState
!
IO
->
ProgIO
;
OpenOther
prog
=:{
editor
={
editwindows
}}
io
=
OpenModule
path`
EmptyTSel
prog
io
;
where
{
path
=
RemovePath
front
.
wstate
.
pathname
;
path`
|
def
=
MakeImpPathname
path
;
=
MakeDefPathname
path
;
def
=
IsDefPathname
path
;
(_,
front
)
=
GetFrontWindow
editwindows
;
};
/* Auxiliary function for the Open Definition and Open Implementation commands */
OpenModule
::
!
Pathname
!
PartTSel
!
ProgState
!
IO
->
ProgIO
;
OpenModule
pathname
tsel
prog
io
=
read_and_open
fullpathname
prog`
io`
;
where
{
((
prog`
,
fullpathname
),
io`
)
=
accFiles
(
GetFullPathname
pathname
prog
)
io
;
read_and_open
::
!
Pathname
!
ProgState
!
IO
->
ProgIO
;
read_and_open
fullpathname
prog
=:{
editor
=
ed
=:{
editwindows
}}
io
|
notondisk
=
(
prog
,
ioa
);
|
exists
=
SetThisWindow
id
tsel
prog
io
|
good
=
OpenEdWindow
fullpathname
tsel
nrlines
newlines
text
prog
io`
;
=
AlertDialog
alertstrings
prog
io`
;
where
{
notondisk
=
fullpathname
==
EmptyPathname
;
(
exists
,
id
)
=
IsExistingPathname
fullpathname
editwindows
;
((
good
,
text
,
nrlines
,
newlines
),
io`
)=
accFiles
(
ReadFile
fullpathname
)
io
;
ioa
=
Alert
io
;
alertstrings
=
[
"The file could not be opened because"
,
"of a file I/O error."
]
};
};
// The device function for the Close command
Close
::
!
ProgState
!
IO
->
ProgIO
;
Close
prog
=:{
editor
={
editwindows
}}
io
|
dialog_present
=
(
prog
,
CloseDialog
DFindIdentID
io`
);
=
CloseWindow
"closing"
wdid
prog
io`
;
where
{
(
dialog_present
,_,
io`
)
=
GetDialogInfo
DFindIdentID
io
;
(
wdid
,_)
=
GetFrontWindow
editwindows
;
};
// The device function for the Save command
Save
::
!
ProgState
!
IO
->
ProgIO
;
Save
prog
=:{
editor
=
ed
=:{
editwindows
}}
io
|
new_window
=
SaveAs
prog
io
;
|
good
=
Saved_UpdateMenuItems
path
prog`
io`
;
=
AlertDialog
[
"The file could not be saved because"
,
"of a file I/O error."
]
prog`
io`
;
where
{
(_,
front
)
=
GetFrontWindow
editwindows
;
(
front`
,_,
text
)
=
GetText
{
front
&
wstate
=
{
front
.
wstate
&
saved
=
True
}};
path
=
front`
.
wstate
.
pathname
;
prog`
=
{
prog
&
editor
={
ed
&
editwindows
=
SetFrontWindow
front`
editwindows
}};
(
good
,
io`
)
=
accFiles
(
SaveFile
path
front`
.
wformat
.
WinFormat
.
newlines
text
)
io
;
new_window
=
RemovePath
(
RemoveSuffix
path
)
==
"Untitled"
;
};
//
// The device function for the Save As command
//
SaveAs
::
!
ProgState
!
IO
->
ProgIO
;
SaveAs
prog
=:{
editor
=
{
editwindows
}}
io
#
(
save
,
path
,
prog
=:{
editor
=
ed
=:{
project
}},
io
)
=
EdSelectOutputFile
"Save As:"
(
RemovePath
oldpath
)
prog
io
;
(
front1
,_,
text
)
=
GetText
front
;
front`
=
{
front1
&
wstate
={
front1
.
wstate
&
saved
=
True
,
pathname
=
path
}};
project`
=
UpdateAfterSavedAs
oldpath
path
project
;
editwindows`
=
SetFrontWindow
front`
editwindows
;
editwindows1
=
SetFrontWindow
front1
editwindows
;
|
not
save
=
(
prog
,
io
);
|
RemovePath
path
==
HelpFile
=
HelpFileAlert
prog
io
;
|
fst
(
IsExistingPathname
path
editwindows
)
&&
(
oldpath
<>
path
)
=
AlertDialog
[
"The file could not be saved because"
,
"there is still another window open on it."
]
prog
io
;
#
(
good
,
io
)
=
accFiles
(
SaveFile
path
front
.
wformat
.
WinFormat
.
newlines
text
)
io
;
|
not
good
=
AlertDialog
[
"The file could not be saved because"
,
"of a file I/O error."
]
{
prog
&
editor
={
ed
&
editwindows
=
editwindows1
}}
io
;
// otherwise
=
Saved_UpdateMenuItems
oldpath
{
prog
&
editor
={
ed
&
editwindows
=
editwindows`
,
project
=
project`
}}
io
;
where
{
(_,
front
)
=
GetFrontWindow
editwindows
;
oldpath
=
front
.
wstate
.
pathname
;
};
// The device function for the Print command
Print
::
!
ProgState
!
IO
->
ProgIO
;
Print
prog
=:{
editor
=
ed
=:{
editwindows
}}
io
|
user_confirmed
=
(
prog2
,
io3
);
=
(
prog1
,
io1
)
where
{
(_,
front
)
=
GetFrontWindow
editwindows
;
(
user_confirmed
,
prog1
,
io1
)
=
evtlConfirm
front
.
wstate
.
wdtype
prog
io
;
({
tabw
,
winfont
})
=
front
.
wformat