ideoptions.icl 3.22 KB
Newer Older
Diederik van Arkel's avatar
Diederik van Arkel committed
1 2 3 4
implementation module ideoptions

import StdFunc
import StdWindow
5
import StdPStClass
Diederik van Arkel's avatar
Diederik van Arkel committed
6
import IdeState
7
import ioutil, tools
Diederik van Arkel's avatar
Diederik van Arkel committed
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27

ideOptionsDialog :: !*(PSt *General) -> *(PSt *General)
ideOptionsDialog ps
	# (prefs,ps)	= getPrefs ps
	# (wId,ps)		= openId ps
	# (okId,ps)		= openId ps
	# iniSWMark		= toMark prefs.switch_close
	# iniTBMark		= toMark prefs.show_toolbar
	# iniBVMark		= toMark prefs.be_verbose
	# (iniNHIndex,iniCVIndex)
					= case prefs.newline_handling of
						(LeaveAlone NewlineConventionNone)	-> (1,1)
						(LeaveAlone NewlineConventionMac)	-> (1,2)
						(LeaveAlone NewlineConventionUnix)	-> (1,3)
						(LeaveAlone NewlineConventionDos)	-> (1,4)
						(AlwaysUse NewlineConventionNone)	-> (2,1)
						(AlwaysUse NewlineConventionMac)	-> (2,2)
						(AlwaysUse NewlineConventionUnix)	-> (2,3)
						(AlwaysUse NewlineConventionDos)	-> (2,4)
	# iniAWMark		= toMark prefs.altgr_workaround
28
	# (ti,ps)		= toolData prefs ps
29
	# (_,ps)		= openModalDialog Void (ddef iniSWMark iniTBMark iniBVMark iniNHIndex iniCVIndex iniAWMark
30
						ti okId wId) ps
Diederik van Arkel's avatar
Diederik van Arkel committed
31 32 33
	= ps

ddef
34
	iniSWMark iniTBMark iniBVMark iniNHIndex iniCVIndex iniAWMark
35
	ti okId wId
Diederik van Arkel's avatar
Diederik van Arkel committed
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
	= Dialog "IDE Options"
		(	CheckControl
			[("Switch windows",Nothing,iniSWMark,noLS switchSW)
			,("Show toolbar",Nothing,iniTBMark,noLS switchTB)
			,("Verbose diagnostics",Nothing,iniBVMark,noLS switchBV)
			,("AltGr workaround",Nothing,iniAWMark,noLS switchAW)
			] (Columns 1) []
		:+: TextControl "Newline Handling"
			[ControlPos (Left,zero)]
		:+: RadioControl
			[("Leave existing files alone and use given convention for new files",Nothing,noLS (changeNH LeaveAlone))
			,("Always save using given convention",Nothing,noLS (changeNH AlwaysUse))
			]
			(Columns 1)
			(iniNHIndex)
			[ControlPos (Left,zero)]
		:+: TextControl "Newline Convention"
			[ControlPos (Left,zero)]
		:+: RadioControl
			[("Native",Nothing,noLS (changeCV NewlineConventionNone))
			,("Mac",Nothing,noLS (changeCV NewlineConventionMac))
			,("Unix",Nothing,noLS (changeCV NewlineConventionUnix))
			,("Dos",Nothing,noLS (changeCV NewlineConventionDos))
			]
			(Rows 1)
			(iniCVIndex)
			[ControlPos (Left,zero)]
63
		:+: toolOptions ti
Diederik van Arkel's avatar
Diederik van Arkel committed
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
		:+: ButtonControl "OK" [ControlPos (Right,zero), ControlFunction (noLS (closeWindow wId)), ControlId okId]
		) [WindowClose (noLS (closeWindow wId)), WindowId wId, WindowOk okId, WindowCancel okId]

switchAW ps
	# (prefs,ps)	= getPrefs ps
	# prefs			= {prefs & altgr_workaround = not prefs.altgr_workaround}
	= setPrefs prefs ps

switchSW ps
	# (prefs,ps)	= getPrefs ps
	# prefs			= {prefs & switch_close = not prefs.switch_close}
	= setPrefs prefs ps

switchTB ps
	# (prefs,ps)	= getPrefs ps
	# prefs			= {prefs & show_toolbar = not prefs.show_toolbar}
	= setPrefs prefs ps

switchBV ps
	# (prefs,ps)	= getPrefs ps
	# prefs			= {prefs & be_verbose = not prefs.be_verbose}
	= setPrefs prefs ps

changeNH nh ps
	# (prefs,ps)	= getPrefs ps
	# prefs			= {prefs & newline_handling = case prefs.newline_handling of
						(LeaveAlone conv)	-> nh conv
						(AlwaysUse conv)	-> nh conv
					  }
	= setPrefs prefs ps

changeCV cv ps
	# (prefs,ps)	= getPrefs ps
	# prefs			= {prefs & newline_handling = case prefs.newline_handling of
						(LeaveAlone _)	-> LeaveAlone cv
						(AlwaysUse _)	-> AlwaysUse cv
					  }
	= setPrefs prefs ps