Skip to content

Commit

Permalink
Package and Module tabs unified
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernando Benavides committed Nov 25, 2009
1 parent 3ac69f4 commit ba4c036
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 35 deletions.
11 changes: 2 additions & 9 deletions hpage.cabal
@@ -1,5 +1,5 @@
name: hpage name: hpage
version: 0.4.6 version: 0.4.7
cabal-version: >=1.6 cabal-version: >=1.6
build-type: Custom build-type: Custom
license: BSD3 license: BSD3
Expand Down Expand Up @@ -49,12 +49,5 @@ Executable hpage
main-is: Main.hs main-is: Main.hs
buildable: True buildable: True
hs-source-dirs: src hs-source-dirs: src
other-modules: other-modules: HPage.GUI.IDs, HPage.GUI.FreeTextWindow, HPage.GUI.Dialogs, HPage.Control, HPage.Server, HPage.Utils.Log
HPage.GUI.IDs,
HPage.GUI.FreeTextWindow,
HPage.GUI.Dialogs,
HPage.Control,
HPage.Server,
HPage.Test.Server,
HPage.Utils.Log
ghc-options: -fwarn-unused-imports -fwarn-missing-fields -fwarn-incomplete-patterns ghc-options: -fwarn-unused-imports -fwarn-missing-fields -fwarn-incomplete-patterns
49 changes: 23 additions & 26 deletions src/HPage/GUI/FreeTextWindow.hs
Expand Up @@ -8,6 +8,8 @@
module HPage.GUI.FreeTextWindow ( gui ) where module HPage.GUI.FreeTextWindow ( gui ) where


-- import Control.Concurrent.Process -- import Control.Concurrent.Process
import Foreign.Ptr
import Foreign.Storable
import System.FilePath import System.FilePath
import System.Directory import System.Directory
import System.IO.Error hiding (try) import System.IO.Error hiding (try)
Expand Down Expand Up @@ -91,7 +93,7 @@ gui =
varModsSel <- varCreate $ -1 varModsSel <- varCreate $ -1
lstModules <- listCtrlEx pnlMs (wxLC_REPORT + wxLC_ALIGN_LEFT + wxLC_NO_HEADER + wxLC_SINGLE_SEL) lstModules <- listCtrlEx pnlMs (wxLC_REPORT + wxLC_ALIGN_LEFT + wxLC_NO_HEADER + wxLC_SINGLE_SEL)
[columns := [("Module", AlignLeft, 200), [columns := [("Module", AlignLeft, 200),
("Origin", AlignLeft, 200)]] ("Origin", AlignLeft, 0)]]
listCtrlSetImageList lstModules images wxIMAGE_LIST_SMALL listCtrlSetImageList lstModules images wxIMAGE_LIST_SMALL


-- Results panel -- Results panel
Expand Down Expand Up @@ -134,12 +136,9 @@ gui =
MouseLeftDClick _ _ -> onCmd "mouseEvent" restartTimer >> propagateEvent MouseLeftDClick _ _ -> onCmd "mouseEvent" restartTimer >> propagateEvent
MouseRightDown _ _ -> onCmd "textContextMenu" textContextMenu MouseRightDown _ _ -> onCmd "textContextMenu" textContextMenu
_ -> propagateEvent] _ -> propagateEvent]
set lstModules [on mouse := \e -> case e of set lstModules [on listEvent := \e -> case e of
MouseRightUp _ _ -> onCmd "moduleContextMenu" moduleContextMenu >> propagateEvent
MouseLeftDClick _ _ -> onCmd "moduleDblClick" moduleDblClick
_ -> propagateEvent,
on listEvent := \e -> case e of
ListItemSelected idx -> varSet varModsSel idx ListItemSelected idx -> varSet varModsSel idx
ListItemRightClick idx -> varSet varModsSel idx >> onCmd "moduleContextMenu" moduleContextMenu
_ -> propagateEvent] _ -> propagateEvent]


-- Menu bar... -- Menu bar...
Expand Down Expand Up @@ -259,34 +258,27 @@ gui =
refreshPage, savePageAs, savePage, openPage, refreshPage, savePageAs, savePage, openPage,
pageChange, copy, cut, paste, pageChange, copy, cut, paste,
justFind, justFindNext, justFindPrev, findReplace, justFind, justFindNext, justFindPrev, findReplace,
textContextMenu, moduleContextMenu, moduleDblClick, textContextMenu, moduleContextMenu,
restartTimer, killTimer, restartTimer, killTimer,
loadPackage, loadModules, importModules, loadModulesByName, loadModulesByNameFast, reloadModules, loadPackage, loadModules, importModules, loadModulesByName, loadModulesByNameFast, reloadModules,
configure, openHelpPage :: HPS.ServerHandle -> GUIContext -> IO () configure, openHelpPage :: HPS.ServerHandle -> GUIContext -> IO ()


moduleDblClick model guiCtx@GUICtx{guiWin = win, guiModules = (varModsSel, lstModules)} =
do
pointWithinWindow <- windowGetMousePosition win
i <- listCtrlHitTest lstModules pointWithinWindow 0
varSet varModsSel i
loadModulesByNameFast model guiCtx

moduleContextMenu model guiCtx@GUICtx{guiWin = win, guiModules = (varModsSel, lstModules)} = moduleContextMenu model guiCtx@GUICtx{guiWin = win, guiModules = (varModsSel, lstModules)} =
do do
contextMenu <- menuPane []
pointWithinWindow <- windowGetMousePosition win pointWithinWindow <- windowGetMousePosition win
i <- listCtrlHitTest lstModules pointWithinWindow 0 i <- varGet varModsSel
contextMenu <- menuPane []
case i of case i of
(-1) -> return () (-1) ->
do
return ()
i -> i ->
do do
itm <- get lstModules $ item i itm <- get lstModules $ item i
debugIO ("the item", itm) debugIO ("the item", itm)
case itm of case itm of
[_, "Package"] -> [_, "Package"] ->
do menuAppend contextMenu wxId_HASK_LOAD_FAST "&Load" "Load Module" False
varSet varModsSel i
menuAppend contextMenu wxId_HASK_LOAD_FAST "&Load" "Load Module" False
[modname, _] -> [modname, _] ->
appendBrowseMenu contextMenu modname appendBrowseMenu contextMenu modname
other -> other ->
Expand Down Expand Up @@ -573,14 +565,19 @@ refreshPage model guiCtx@GUICtx{guiWin = win,
-- Refresh the modules lists -- Refresh the modules lists
--NOTE: we know 0 == "imported" / 1 == "interpreted" / 2 == "compiled" / 3 == "package" images --NOTE: we know 0 == "imported" / 1 == "interpreted" / 2 == "compiled" / 3 == "package" images
--TODO: move that to some kind of constants or so --TODO: move that to some kind of constants or so
let ims' = map (\m -> (0, m)) ims let ims' = map (\m -> (0, [m, "Imported"])) ims
ms' = map (\m -> (if HP.modInterpreted m then 1 else 2, HP.modName m)) ms ms' = map (\m -> if HP.modInterpreted m
pms' = map (\m -> (3, m)) $ flip filter pms $ \pm -> any (\xm -> HP.modName xm == pm) ms then (1, [HP.modName m, "Interpred"])
else (2, [HP.modName m, "Compiled"])) ms
pms' = map (\m -> (3, [m, "Package"])) $
flip filter pms $ \pm -> all (\xm -> HP.modName xm /= pm) ms
allms = zip [0..] (ims' ++ ms' ++ pms') allms = zip [0..] (ims' ++ ms' ++ pms')
debugIO ("allms", allms)
itemsDelete lstModules itemsDelete lstModules
(flip mapM) allms $ \(idx, (img, m)) -> (flip mapM) allms $ \(idx, (img, m@(mn:_))) ->
listCtrlInsertItemWithLabel lstModules idx m img >> listCtrlInsertItemWithLabel lstModules idx mn img >>
set lstModules [item idx := [m]] set lstModules [item idx := m]
varSet varModsSel $ -1


-- Refresh the current text -- Refresh the current text
set txtCode [text := t] set txtCode [text := t]
Expand Down

0 comments on commit ba4c036

Please sign in to comment.