Skip to content

Commit 834f363

Browse files
author
3555003
committed
Add project structure and cabal file
git-svn-id: https://svn.science.uu.nl/repos/edu.3555003.wiskunded/trunk@44 46e4088a-c2b5-4d24-90db-838aeec2e325
1 parent 5e99772 commit 834f363

10 files changed

+104
-60
lines changed

JCU.cabal

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: JCU
2+
version: 0.0.1
3+
synopsis: JCU
4+
description: JCU
5+
license: BSD3
6+
license-file: LICENSE
7+
category: Compilers/Interpreters
8+
copyright: (c) 2011 Utrecht University
9+
author: Jurriën Stutterheim
10+
maintainer: Jurriën Stutterheim
11+
stability: provisional
12+
homepage: http://www.cs.uu.nl/wiki/bin/view/Center/JCU
13+
tested-with: GHC == 7.0.3
14+
build-type: Simple
15+
cabal-version: >= 1.2
16+
extra-source-files: Makefile
17+
18+
executable jcu
19+
main-is: GUI.hs
20+
build-depends: base >= 4.3 && < 5, wx >= 0.12, uu-parsinglib >= 2.7.1,
21+
wxcore >= 0.12
22+
other-modules: Prolog
23+
hs-source-dirs: src

Makefile

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ default:
33

44
build:
55
make clean
6-
ghc --make GUI.hs
7-
macosx-app ./GUI
6+
cd src && ghc --make GUI.hs
7+
cd src && macosx-app ./GUI
88

99
clean:
10-
rm -rf GUI GUI.app/ *.hi *.o
10+
rm -rf src/GUI src/GUI.app/ src/*.hi src/*.o
1111

1212
run:
13-
open ./GUI.app
13+
open src/GUI.app

Setup.hs

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import Distribution.Simple
2+
main = defaultMain

CLI.hs src/CLI.hs

File renamed without changes.

src/EnableGUI.hs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module EnableGUI(enableGUI) where
2+
3+
import Data.Int
4+
import Foreign
5+
6+
type ProcessSerialNumber = Int64
7+
8+
foreign import ccall "GetCurrentProcess" getCurrentProcess :: Ptr ProcessSerialNumber -> IO Int16
9+
foreign import ccall "_CGSDefaultConnection" cgsDefaultConnection :: IO ()
10+
foreign import ccall "CPSEnableForegroundOperation" cpsEnableForegroundOperation :: Ptr ProcessSerialNumber -> IO ()
11+
foreign import ccall "CPSSignalAppReady" cpsSignalAppReady :: Ptr ProcessSerialNumber -> IO ()
12+
foreign import ccall "CPSSetFrontProcess" cpsSetFrontProcess :: Ptr ProcessSerialNumber -> IO ()
13+
14+
enableGUI = alloca $ \psn -> do
15+
getCurrentProcess psn
16+
cgsDefaultConnection
17+
cpsEnableForegroundOperation psn
18+
cpsSignalAppReady psn
19+
cpsSetFrontProcess psn

GUI.hs src/GUI.hs

+56-56
Original file line numberDiff line numberDiff line change
@@ -15,50 +15,50 @@ main = start gui
1515
-- TODO: Investigate using a Panel
1616
gui :: IO ()
1717
gui = do -- Application frame
18-
f <- frame [text := "Prolog in Haskell"]
19-
sw <- scrolledWindow f [ style := wxVSCROLL
20-
, scrollRate := sz 20 20
21-
, clientSize := sz 800 500 ]
22-
vlogic <- variable [ value := [] ]
23-
rows <- variable [ value := [] ]
24-
file <- variable [ value := "" ]
25-
rules <- textCtrl f []
26-
query <- textEntry f [ text := "ouder(X,ama)" ]
27-
output <- textCtrl f []
28-
rbox <- singleListBox f []
29-
-- TODO: Get rid of cvas completely. Figure out how the positioning stuff
30-
-- works first.
31-
cvas <- panel sw [ clientSize := sz 800 500 ]
32-
mfile <- menuPane [text := "&File"]
33-
mopen <- menuItem mfile [ text := "&Open\tCtrl+O"
34-
, help := "Open a Prolog file"
35-
, on command := onOpen f rules file ]
36-
msave <- menuItem mfile [ text := "&Save\tCtrl+S"
37-
, help := "Save a Prolog file"
38-
, on command := onSave f rules file ]
39-
msaveas <- menuItem mfile [ text := "&Save As\tCtrl+Shift+S"
40-
, help := "Save As a Prolog file"
41-
, on command := onSaveAs f rules file ]
42-
mquit <- menuQuit mfile [ text := "&Quit"
43-
, help := "Quit the program"
44-
, on command := close f ]
45-
mquery <- menuPane [text := "Query" ]
46-
mrun <- menuItem mquery [ text := "&Run\tCtrl+R"
47-
, help := "Run the query"
48-
, on command := onRun vlogic rules query output ]
49-
addbtn <- button f [ text := "Add"
50-
, on command := onAdd sw rows vlogic
51-
]
52-
run <- button f [ text := "Run!"
53-
, on command := onRun vlogic rules query output ]
54-
set sw [ layout := column 5 [hfill $ widget cvas]
55-
, clientSize := sz 500 300 ]
56-
set f [ menuBar := [mfile, mquery]
57-
, layout := column 5 [ boxed "Enter rules and queries, press Run and be amazed!"
58-
(overGrid sw rules query output run rbox)
59-
]
60-
, clientSize := sz 1000 700 ]
61-
onAdd sw rows vlogic -- Adds initial text field
18+
f <- frame [text := "Prolog in Haskell"]
19+
sw <- scrolledWindow f [ style := wxVSCROLL
20+
, scrollRate := sz 20 20
21+
, clientSize := sz 800 500 ]
22+
vlogic <- variable [ value := [] ]
23+
rows <- variable [ value := [] ]
24+
file <- variable [ value := "" ]
25+
rules <- textCtrl f []
26+
query <- textEntry f [ text := "ouder(X,ama)" ]
27+
output <- textCtrl f []
28+
rbox <- singleListBox f []
29+
-- TODO: Get rid of cvas completely. Figure out how the positioning stuff
30+
-- works first.
31+
cvas <- panel sw [ clientSize := sz 800 500 ]
32+
mfile <- menuPane [text := "&File"]
33+
mopen <- menuItem mfile [ text := "&Open\tCtrl+O"
34+
, help := "Open a Prolog file"
35+
, on command := onOpen f rules file ]
36+
msave <- menuItem mfile [ text := "&Save\tCtrl+S"
37+
, help := "Save a Prolog file"
38+
, on command := onSave f rules file ]
39+
msaveas <- menuItem mfile [ text := "&Save As\tCtrl+Shift+S"
40+
, help := "Save As a Prolog file"
41+
, on command := onSaveAs f rules file ]
42+
mquit <- menuQuit mfile [ text := "&Quit"
43+
, help := "Quit the program"
44+
, on command := close f ]
45+
mquery <- menuPane [text := "Query" ]
46+
mrun <- menuItem mquery [ text := "&Run\tCtrl+R"
47+
, help := "Run the query"
48+
, on command := onRun vlogic rules query output ]
49+
addbtn <- button f [ text := "Add"
50+
, on command := onAdd sw rows vlogic
51+
]
52+
run <- button f [ text := "Run!"
53+
, on command := onRun vlogic rules query output ]
54+
set sw [ layout := column 5 [hfill $ widget cvas]
55+
, clientSize := sz 500 300 ]
56+
set f [ menuBar := [mfile, mquery]
57+
, layout := column 5 [ boxed "Enter rules and queries, press Run and be amazed!"
58+
(overGrid sw rules query output run rbox)
59+
]
60+
, clientSize := sz 1000 700 ]
61+
onAdd sw rows vlogic -- Adds initial text field
6262

6363
drawRows :: (Form w1, Valued w, Dimensions w1) => w1 -> w [LogicRow] -> IO ()
6464
drawRows sw rows = do
@@ -78,10 +78,10 @@ onAdd sw rows vlogic = do
7878

7979
disableRow :: LogicRow -> IO ()
8080
disableRow (LogicRow _ _ (RowControls t o h d)) = do
81-
set t [enabled := False]
82-
set o [enabled := False]
83-
set h [enabled := False]
84-
set d [enabled := False]
81+
set t [enabled := False]
82+
set o [enabled := False]
83+
set h [enabled := False]
84+
set d [enabled := False]
8585

8686
data RowType = TermRow | RuleRow
8787

@@ -168,17 +168,17 @@ popRow sw rows = do
168168

169169
enableRow :: LogicRow -> IO ()
170170
enableRow (LogicRow _ _ (RowControls t o h d)) = do
171-
set t [enabled := True]
172-
set o [enabled := True]
173-
set h [enabled := True]
174-
set d [enabled := True]
171+
set t [enabled := True]
172+
set o [enabled := True]
173+
set h [enabled := True]
174+
set d [enabled := True]
175175

176176
hideCtrls :: LogicRow -> IO ()
177177
hideCtrls (LogicRow _ _ (RowControls t o h d)) = do
178-
set t [visible := False]
179-
set o [visible := False]
180-
set h [visible := False]
181-
set d [visible := False]
178+
set t [visible := False]
179+
set o [visible := False]
180+
set h [visible := False]
181+
set d [visible := False]
182182

183183
-- TODO: See if we can use container instead of widget for the inner bunch of
184184
-- fields. This might enable actual scrolling.

Prolog.hs src/Prolog.hs

File renamed without changes.

accept.png src/accept.png

File renamed without changes.

delete.png src/delete.png

File renamed without changes.

help.png src/help.png

File renamed without changes.

0 commit comments

Comments
 (0)