Commit af9b4495 authored by Diederik van Arkel's avatar Diederik van Arkel

convert to 2.0 import syntax + minor extensions

parent a6e0ebd7
......@@ -21,16 +21,11 @@ definition module EdAction
* EdAction.dcl: performing editor Actions
*/
from EdSelection import Position, ColumnNr, LineNr
from EdText import TextFragment, StrictList
//1.3
from EdText import String
//3.1
import EdMonad, EdMovement
import EdCommon
from EdActionType import Action
import EdMonad, EdMovement
import EdCommon
from EdSelection import :: Position
from EdText import :: TextFragment
from EdActionType import :: Action
performAction :: Action -> EditMonad (PSt PLocState) nothing
......
......@@ -17,9 +17,9 @@ definition module EdActionType
// permission.
//*********************************************************************************
import StdOverloaded
import EdMovement
from EdText import TextFragment
import StdOverloaded
import EdMovement
from EdText import :: TextFragment
:: Action
= Move Movement
......
......@@ -20,7 +20,7 @@ implementation module EdActionType
import StdOverloaded, StdArray, StdInt, StdString, StdChar, StdList
import StrictList
import EdMovement
from EdText import TextFragment
from EdText import :: TextFragment
:: Action
= Move Movement
......
......@@ -4,13 +4,10 @@
definition module EdFile
from StdFile import FileSystem, Files
//1.3
from StdString import String
//3.1
from EdText import Text
from StdFile import class FileSystem
from EdText import :: Text
import StdError, StdMaybe
from UtilNewlinesFile import NewlineConvention
from UtilNewlinesFile import :: NewlineConvention
readText :: !String !*env -> ((Error Text,NewlineConvention,Bool), !*env) | FileSystem env
writeText :: !String !NewlineConvention !Text !*env -> (Maybe String, !*env) | FileSystem env
......
definition module EdFind
import StdString, StdMaybe
from StrictList import StrictList
import StdMaybe
from StrictList import :: StrictList
import EdSelection
simpleLineSearch ::
......
......@@ -4,13 +4,13 @@
definition module EdKeyMapping
from StdFile import Files
from StdPSt import PSt, IOSt
from StdIOCommon import KeyboardState, SpecialKey, KeyState, Modifiers
from StdMaybe import Maybe
from StdOverloaded import ==, toString, fromString
from EdActionType import Action
from EdMonad import EditMonad, EditState, StateM
from StdFile import :: Files
from StdPSt import :: PSt
from StdIOCommon import :: KeyboardState, :: SpecialKey
from StdMaybe import :: Maybe
from StdOverloaded import class ==, class toString, class fromString
from EdActionType import :: Action
//from EdMonad import EditMonad, EditState, StateM
:: KeyMapping
......
......@@ -4,10 +4,10 @@
definition module EdKeyboard
from StdIOCommon import KeyboardState, KeyState, SpecialKey, Modifiers, IsRepeatKey, IdFun
from StdPSt import PSt, IOSt
from EdState import EditorState
from EdKeyMapping import KeyMapping
from StdIOCommon import :: KeyboardState
from StdPSt import :: PSt
//from EdState import EditorState
from EdKeyMapping import :: KeyMapping
import EdMonad, StdMaybe
import EdCommon
......
......@@ -6,7 +6,7 @@ implementation module EdKeyboard
import StdClass, StdBool, StdArray, StdInt, StdChar, StdTuple, StdList, StdMisc
import StdIOCommon, StdWindow, StdPSt
import EdVisualText, EdVisualCursor,
import EdVisualText, EdVisualCursor, EdSelection,
EdAction, EdKeyMapping, EdState, StrictList
import EdActionType
......
......@@ -4,12 +4,8 @@
definition module EdLineText
from StrictList import StrictList
from EdPosition import LineNr
//1.3
from StdString import String
//3.1
from StrictList import :: StrictList
from EdPosition import :: LineNr
:: Text
:: TextFragment
......
......@@ -6,7 +6,7 @@ implementation module EdLineText
import StdString, StdClass, StdInt, StdList, StdBool, StdFunc, StdArray, StdTuple
import StrictList
from EdPosition import LineNr
from EdPosition import :: LineNr
import syncol
import Platform
......
......@@ -4,15 +4,8 @@
definition module EdLook
from StdPicture import Picture
from StdIOCommon import SelectState, UpdateState, ViewFrame, UpdateArea,
Rectangle, Point2
from StdPicture import FontName, FontSize, FontStyle,
FontDef, FontMetrics, Font
//1.3
from StdString import String
//3.1
from StdPSt import PSt, IOSt
from StdPicture import :: Picture
from StdIOCommon import :: SelectState, :: UpdateState
import EdMonad
editWindowLook :: EditState SelectState !UpdateState -> (!*Picture -> *Picture)
......
......@@ -7,7 +7,7 @@ implementation module EdLook
import StdInt, StdBool, StdClass
import StdIOCommon
import StdPicture
import EdVisualText, EdVisualCursor, EdVisualLineNr
import EdVisualText, EdVisualCursor, EdVisualLineNr, EdSelection
// editWindowLook: updating the affected areas is done by updating
// each of the rectangles.
......
......@@ -4,10 +4,10 @@
definition module EdMessage
from StdId import Id,RId,Ids
from StdPSt import PSt, IOSt
from StdReceiver import Receiver2, R2Id, Receiver2Function, ReceiverAttribute
from EdMonad import EditState, EditMonad, StateM
from StdId import class Ids
from StdPSt import :: PSt
from StdReceiver import :: Receiver2
from EdMonad import :: EditState, :: EditMonad, :: StateM
:: EditId
:: Message
......
......@@ -4,22 +4,19 @@
definition module EdMonad
//1.3
from StdString import String
//3.1
from StdPicture import Font, FontMetrics, Colour
from StdPSt import PSt, IOSt
from StdId import Id
from StdPicture import Picture
from StdClipboard import ClipboardItem
from StdOverloaded import ==, toString
from StdMaybe import Maybe
from StdPicture import :: Font, :: FontMetrics, :: Colour
from StdPSt import :: PSt, :: IOSt
from StdId import :: Id
from StdPicture import :: Picture
from StdClipboard import :: ClipboardItem
from StdOverloaded import class ==, class toString
from StdMaybe import :: Maybe
import StateMonad
from UtilNewlinesFile import NewlineConvention
from UtilNewlinesFile import :: NewlineConvention
from EdText import Text, StrictList, TextFragment
from EdSelection import Selection, Position, ColumnNr, LineNr
from EdText import :: Text, :: StrictList, :: TextFragment
from EdSelection import :: Selection, :: Position, :: ColumnNr, :: LineNr
:: TabSize :== Int
......@@ -135,7 +132,7 @@ pathNameToWindowTitle :: !String -> String
pathNameToWindowTitle` :: !String -> String
//-- P4
from StdIOBasic import Point2
from StdIOBasic import :: Point2
getTimerId :: EditMonad .env Id
getToolPt :: EditMonad .env Point2
......
......@@ -21,8 +21,8 @@ definition module EdMouse
* EdMouse.dcl: handling mouse events
*/
from StdIOCommon import MouseState, Point2, Modifiers
from StdPSt import PSt, IOSt
from StdIOCommon import :: MouseState
from StdPSt import :: PSt
import EdMonad, EdCommon
editWindowMouse :: MouseState (!EditState, !PSt PLocState) -> (EditState, PSt PLocState)
......
......@@ -4,8 +4,8 @@
definition module EdMovement
from StdClass import ==, toString, fromString
from EdSelection import Position, ColumnNr, LineNr
from StdClass import class ==, class toString, class fromString
from EdSelection import :: Position, :: ColumnNr, :: LineNr
import EdMonad
:: Movement
......
......@@ -6,7 +6,7 @@ implementation module EdMovement
import StdMisc, StdInt, StdTuple, StdArray, StdChar, StdBool, StdList, StdFunc
import StdIOCommon, StdPSt
import EdMonad, EdVisualText
import EdMonad, EdVisualText, EdSelection
:: Movement
= LineUp
......
......@@ -4,7 +4,7 @@
definition module EdPosition
from StdClass import <, ==
from StdClass import class <, class ==
:: Position
= { col :: ColumnNr
......
......@@ -5,7 +5,7 @@
definition module EdSelection
import EdPosition
from EdLineText import Text
from EdLineText import :: Text
:: Selection
= { start :: Position
......
......@@ -4,12 +4,12 @@
definition module EdState
from StdId import Id
from StdPSt import PSt, IOSt
from StdMaybe import Maybe
from EdKeyMapping import KeyMapping
from EdMonad import EditState
from EdMessage import EditId
from StdId import :: Id
from StdPSt import :: PSt
from StdMaybe import :: Maybe
from EdKeyMapping import :: KeyMapping
//from EdMonad import EditState
from EdMessage import :: EditId
class Editor env
where
......
......@@ -4,13 +4,9 @@
definition module EdTab
//1.3
from StdString import String
//3.1
from StdIOCommon import Point2
from StdPicture import Picture
from StdPicture import Font, FontMetrics, FontName, FontSize, FontStyle, FontDef
from EdMonad import FontInfo, TabSize, NewTabSize, SyntaxColours, Colour
from StdIOCommon import :: Point2
from StdPicture import :: Picture
from EdMonad import :: FontInfo
splitAtTabs :: !String -> .[String]
// splitAtTabs: splits a string into several strings that were
......
......@@ -4,11 +4,9 @@
definition module EdText
//1.3
from StdString import String
//3.1
import StdMaybe
from EdSelection import Selection, Position, ColumnNr, LineNr
from EdSelection import :: Selection, :: Position, :: ColumnNr, :: LineNr
import EdLineText
getTextFragment :: !Selection !Text -> (!TextFragment, !Text)
......
......@@ -21,9 +21,10 @@ definition module EdVisualCursor
* EdVisualCursor.dcl: visual operations on the cursor and selections
*/
from StdIOCommon import ViewFrame, Rectangle, Point2
from StdIOCommon import :: ViewFrame, :: Rectangle, :: Point2
import EdMonad, EdMovement
vUpdateCursor :: !Bool !Position !Int !FontInfo !Text !ViewFrame ![Rectangle]
-> (*Picture -> *Picture)
// vUpdateCursor: updates the cursor
......
......@@ -2,15 +2,13 @@ definition module EdVisualText
// EdVisualText.dcl: visual operations on texts
from StdIOCommon import ViewFrame, Rectangle, Point2, ViewDomain
from EdText import TextFragment, StrictList, stringsToString,
from StdIOCommon import :: ViewFrame, :: Rectangle, :: Point2, :: ViewDomain
from EdText import :: TextFragment, :: StrictList, stringsToString,
getTextFragment, stringToStrings, getLine, textLength,
newText, emptyText, stringsToText, updateLine, lastLineNr
from StdPicture import Picture, FontName, FontSize, FontStyle, FontDef
from StdPicture import :: Picture, :: FontName
import EdMonad
//1.3
from StdString import String
//3.1
vUpdateText :: !FontInfo !Text !ViewFrame ![Rectangle] -> (*Picture -> *Picture)
// vUpdateText: updates the text in the rectangles within
......
......@@ -6,7 +6,7 @@ implementation module EdVisualText
import StdClass, StdFunc, StdArray, StdInt, StdMisc, StdList
import StdIOCommon, StdPicture, StdPSt, StdWindow
import EdText, EdTab, StrictList, EdMonad
import EdText, EdTab, StrictList, EdMonad, EdSelection
//-- util
......
......@@ -4,16 +4,12 @@
definition module EdWindow
//1.3
from StdString import String
//3.1
from StdWindow import Title, WindowAttribute
from StdPSt import PSt, IOSt
from StdId import Id
from StdPicture import Font
from StdIOCommon import MouseState
from EdText import Text
from EdState import EditorState,Editor
from StdWindow import :: Title, :: WindowAttribute
from StdPSt import :: PSt
from StdId import :: Id
from StdPicture import :: Font
from EdText import :: Text
from EdState import class Editor
import EdMonad, StdIOBasic, StdMaybe
......
......@@ -22,12 +22,12 @@ definition module EdClient
*/
import StdMaybe, StdId, StdPSt, StdPicture, StdPrint
from EdState import Editor, EditorState
from EdMessage import EditId, EditAction
from EdLineText import Text
from EdState import class Editor, :: EditorState
from EdMessage import :: EditId, :: EditAction
from EdLineText import :: Text
import EdPosition
from EdSelection import Selection, emptySelection, lineSelection
from EdMonad import UndoState, EditMonad, EditState, StateM, getPathName
from EdSelection import :: Selection, emptySelection, lineSelection
from EdMonad import :: UndoState, :: EditMonad, :: EditState, :: StateM, getPathName
import IdeState
isEditWin :: Id *(PSt *l) -> *(Bool,*PSt *l) | Editor l
......
definition module EdCommon
import EdMonad
from IdeState import General
from IdeState import :: General
:: *PLocState :== General
......
......@@ -5,10 +5,7 @@ import StrictList
import IdeState
import PmParse, PmPath
import StdMenuElement
from search import sr_find_def_imp_sel,FindBoxInfo,Pathname,SearchType,ExtListBoxId,MessageIn,MessageOut,SearchImports
from EdMovement import selectWordAt
from EdVisualCursor import vChangeSelectionTo
import search, EdMovement, EdVisualCursor
:: *PLocState :== General
......
......@@ -18,10 +18,10 @@ definition module IDE
//*********************************************************************************
import StdPSt
from PmTypes import Modulename
from PmTypes import :: Modulename
//import PmProject
from EdClient import Selection, Position, ColumnNr, LineNr
from EdClient import :: Selection, :: Position, :: ColumnNr, :: LineNr
from IdeState import General
from IdeState import :: General
OpenModule :: !.Modulename !.Selection !*(PSt General) -> *PSt General
......@@ -27,7 +27,7 @@ implementation module IDE
//=> License : xxxxx
//=>*********************************************************************************
import StdArray, StdEnum, StdFunc, StdMisc, StdTuple
import StdArray, StdEnum, StdFunc, StdMisc, StdTuple, StdOrdList
import StdFileSelect,StdMenu,StdMenuReceiver,StdProcess, StdPStClass
import ExtNotice
import UtilIO
......@@ -41,7 +41,7 @@ from finder import sr_find, sr_find_next, sr_find_sel, sr_rep_find, sr_goto_curs
from finder import sr_goto_line, sr_goto_selection
from edoptions import defaultFontAndTabs, optionsKeyMapping, editColours
from EdClient import EditAction, isEditWin, msgGetPathName,msgSelectAll
from EdClient import :: EditAction, isEditWin, msgGetPathName,msgSelectAll
from EdClient import emptySelection, sendToActiveWindow, msgGetSelection
from EdClient import msgUndo,msgPaste,msgCopy,msgCut,msgClear,msgBalance,msgDetab
import prefix, tools
......@@ -73,6 +73,10 @@ Start world
(mEdUndoId,world) = openId world
(mMdEdOptId,world) = openId world
// check for PrefsDir existence here...
// check for EnvsDir existence here...
// check for TooltempDir existence here...
# prefspath = MakeFullPathname PrefsDir PrefsFileName//applicationpath PrefsFileName
#! (prefs,world) = openPrefs prefspath world
......@@ -774,6 +778,7 @@ where
( EditControl (if openImp ".icl" ".dcl") (PixelWidth 200) 1
[ ControlId textId
, ControlKeyboard filterReturnKeys Able (\_ -> noLS (dfun True))
// , ControlActivate (noLS (setControlSelection))
]
:+: ButtonControl "Cancel"
[ ControlPos (Left,zero)
......@@ -904,6 +909,7 @@ editMenu altgr_workaround mEditId editRecId mFileSaveId mFileRevertId {mn_und, m
// Wrap...
// :+: MenuItem "Wrap1320" [MenuShortKey '`', MenuFunction (noLS wrap_preprocessor)]
// ...Wrap
:+: MenuItem "Defs..." [MenuShortKey '`', MenuFunction (noLS popup_funs)]
)
[ MenuId (mEditId)
]
......@@ -962,6 +968,76 @@ ed_Balance ps
# (_,ps) = sendToActiveWindow msgBalance ps
= mb_update_undoinfo ps
//== x-perimental
import EdLineText, StrictList, EdClient
popup_funs ps
# (ret,ps) = sendToActiveWindow gettext ps
| isNothing ret = ps
# text = fromJust ret
# text = textToStrings text
# text = slToList text
# text = {t \\ t <- text}
# (defs,ps) = accFiles (FindDefinesInText text) ps
# defs = cleanup defs
# defs = purge_and_reverse [] defs
# defs = sortBy sort defs
# (_,ps) = openMenu Void (PopUpMenu (ListLS [toMenuItem d \\ d <- defs])) ps
= ps
where
cleanup defs
= case defs of
[] -> []
[DefFun "definition" _:defs] -> cleanup defs
[DefFun "implementation" _:defs] -> cleanup defs
[DefFun "module" _:defs] -> cleanup defs
[DefFun "system" _:defs] -> cleanup defs
[def:defs] -> [def:cleanup defs]
sort (DefType id1 _) (DefType id2 _) = id1 < id2
sort (DefType _ _) _ = True
sort _ (DefType _ _) = False
sort (DefClass id1 _) (DefClass id2 _) = id1 < id2
sort (DefClass _ _) _ = True
sort _ (DefClass _ _) = False
sort (DefInst cl1 id1 _)(DefInst cl2 id2 _) | cl1 == cl2 = id1 < id2
= cl1 < cl2
sort (DefInst _ _ _) _ = True
sort _ (DefInst _ _ _) = False
sort (DefFun id1 _) (DefFun id2 _) = id1 < id2
sort (DefFun _ _) _ = True
sort _ (DefFun _ _) = False
sort _ _ = abort "IDE:sort called with unknown constructor\n"
toMenuItem (DefFun id ln) = MenuItem (id) [MenuFunction (menfun ln)]
toMenuItem (DefType id ln) = MenuItem (":: "+++.id) [MenuFunction (menfun ln)]
toMenuItem (DefClass id ln) = MenuItem ("class "+++.id) [MenuFunction (menfun ln)]
toMenuItem (DefInst cl id ln) = MenuItem ("instance "+++.cl+++." "+++.id) [MenuFunction (menfun ln)]
menfun ln (ls,ps)
# (_,ps) = sendToActiveWindow (msgScrollToLine ln) ps
= (ls,ps)
gettext =
getText >>>= \text ->
return text
purge_and_reverse :: [Def] [Def] -> [Def]
purge_and_reverse acc []
= acc
purge_and_reverse [] [h:t]
= purge_and_reverse [h] t
purge_and_reverse [a:as] [d:ds]
| same a d
= purge_and_reverse [d:as] ds
= purge_and_reverse [d,a:as] ds
same (DefFun l _) (DefFun l` _) = l == l`
same (DefType l _) (DefType l` _) = l == l`
same (DefClass l _) (DefClass l` _) = l == l`
same (DefInst l m _) (DefInst l` m` _) = l == l` && m == m`
same _ _ = False
//==== 13/20 transition hack...
// Wrap...
/*
......
......@@ -24,8 +24,8 @@ import EdState
import PmProject
import PmPrefs
import flextextcontrol
from PmAbcMagic import ABCCache
from PmFileInfo import FileInfoCache
from PmAbcMagic import :: ABCCache
from PmFileInfo import :: FileInfoCache
import PmEnvironment
import conswin
......
......@@ -484,7 +484,7 @@ setPrefix s ps = appPLoc (\p=:{prefix}->{p & prefix = removeDup [s:prefix]}) ps
//-- batch build support
from StdProcess import closeProcess
from StdPStClass import FileSystem
from StdPStClass import class FileSystem, instance FileSystem PSt
import logfile, set_return_code
getInteract :: !*(PSt *General) -> (!Bool,!*PSt *General)
......
definition module balance
from EdText import Text,LineNr,Selection,Position,ColumnNr
from EdText import :: Text, :: LineNr, :: Selection
// Text_Balance returns the Selection of the smallest piece of balanced text surrounding
// the cursor or the current selection.
......
......@@ -3,8 +3,8 @@ definition module conswin
// The 'Console' window...
import StdPSt, StdId, StdWindowDef
from EdMonad import EditState, SyntaxColours, EditMonad, StateM
from PmPrefs import ConPrefs
from EdMonad import :: EditState, :: EditMonad, :: StateM
from PmPrefs import :: ConPrefs
:: ConsWinInfo
......
......@@ -6,7 +6,7 @@ import EdLook, EdMessage, EdVisualText, EdWindow
import EdMouse, EdKeyboard
from StrictList import slFromList
from UtilStrictLists import StrictListToList,List,IsEmptyList,:!
from UtilStrictLists import StrictListToList,:: List(:!),IsEmptyList
import IDE,IdeState,IdePlatform
......
definition module edfiles
//1.3
from StdString import String
//3.1
from StdId import Id
from StdPSt import PSt, IOSt
from IdeState import General
from EdClient import Editor, EditorState, Selection, Position, ColumnNr, LineNr
from StdId import :: Id
from StdPSt import :: PSt
from IdeState import :: General
from EdClient import :: Selection
//from EdClient import Editor, EditorState, Selection, Position, ColumnNr, LineNr
ed_ask_save_all :: !Bool (*(PSt General) -> *PSt General) !*(PSt General) -> *PSt General
// cycle through modified edit windows asking user if they should be saved
......
......@@ -469,6 +469,12 @@ ed_save_as ps
# error = fromJust reply
| isJust error
= okNotice ["Save as failed:",fromJust error] ps
# (prefs,ps) = getPrefs ps
# cols = if (IsDefPathname pathname) (prefs.defcols) (if (IsImpPathname pathname) (prefs.impcols) (prefs.syncols))
# (_,ps) = message win (appFontInfo (fi_update cols)) ps
# ps = appPIO (updateWindow win Nothing) ps