packages feed

manatee-terminal 0.0.8 → 0.1.0

raw patch · 8 files changed

+107/−35 lines, 8 filesdep +binarydep +derivedep −gtk-serialized-eventdep ~manatee-coresetup-changedbinary-added

Dependencies added: binary, derive

Dependencies removed: gtk-serialized-event

Dependency ranges changed: manatee-core

Files

Main.hs view
@@ -1,7 +1,7 @@ -- Author:     Andy Stewart <lazycat.manatee@gmail.com> -- Maintainer: Andy Stewart <lazycat.manatee@gmail.com> -- --- Copyright (C) 2010 Andy Stewart, all rights reserved.+-- Copyright (C) 2010 ~ 2011 Andy Stewart, all rights reserved. --  -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by
Manatee/Extension/Terminal.hs view
@@ -1,7 +1,7 @@ -- Author:     Andy Stewart <lazycat.manatee@gmail.com> -- Maintainer: Andy Stewart <lazycat.manatee@gmail.com> -- --- Copyright (C) 2010 Andy Stewart, all rights reserved.+-- Copyright (C) 2010 ~ 2011 Andy Stewart, all rights reserved. --  -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by
Manatee/Extension/Terminal/PageMode.hs view
@@ -1,7 +1,7 @@ -- Author:     Andy Stewart <lazycat.manatee@gmail.com> -- Maintainer: Andy Stewart <lazycat.manatee@gmail.com> -- --- Copyright (C) 2010 Andy Stewart, all rights reserved.+-- Copyright (C) 2010 ~ 2011 Andy Stewart, all rights reserved. --  -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by
Manatee/Extension/Terminal/TerminalBuffer.hs view
@@ -1,7 +1,7 @@ -- Author:     Andy Stewart <lazycat.manatee@gmail.com> -- Maintainer: Andy Stewart <lazycat.manatee@gmail.com> -- --- Copyright (C) 2010 Andy Stewart, all rights reserved.+-- Copyright (C) 2010 ~ 2011 Andy Stewart, all rights reserved. --  -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by@@ -17,22 +17,37 @@ -- along with this program.  If not, see <http://www.gnu.org/licenses/>.  {-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE TemplateHaskell #-} module Manatee.Extension.Terminal.TerminalBuffer where  import Control.Applicative import Control.Concurrent.STM  import DBus.Client hiding (Signal)+import Data.Binary+import Data.DeriveTH import Data.Typeable+import Manatee.Core.Config import Manatee.Core.Types import Manatee.Extension.Terminal.PageMode+import Manatee.Toolkit.General.STM  data TerminalBuffer =      TerminalBuffer {terminalBufferDirectory             :: TVar String                    ,terminalBufferClient                :: Client                    ,terminalBufferPageId                :: PageId-                   ,terminalBufferMode                  :: PageMode}+                   ,terminalBufferMode                  :: PageMode+                   ,terminalBufferState                 :: TVar TerminalState+                   }     deriving Typeable +data TerminalState =+    TerminalState {terminalStateScrolledPosition  :: (Double, Double)}++-- | Init state.+terminalInitState :: TerminalState+terminalInitState =+    TerminalState (0, 0)+ -- | New terminal buffer. terminalBufferNew :: String -> [String] -> Client -> PageId -> CustomizeWrap -> IO TerminalBuffer terminalBufferNew dir _ client pageId _ = @@ -40,5 +55,19 @@                  <*> pure client                  <*> pure pageId                  <*> pure terminalMode+                 <*> newTVarIO terminalInitState                  +-- | Write state.+terminalBufferWriteState :: TerminalBuffer -> FilePath -> IO ()+terminalBufferWriteState buffer path = do+  state <- readTVarIO $ terminalBufferState buffer+  writeConfigPath path state++-- | Read state.+terminalBufferReadState :: TerminalBuffer -> FilePath -> IO ()  +terminalBufferReadState buffer path = do+  state <- readConfigPath path terminalInitState+  writeTVarIO (terminalBufferState buffer) state+  +$(derive makeBinary ''TerminalState) 
Manatee/Extension/Terminal/TerminalView.hs view
@@ -1,7 +1,7 @@ -- Author:     Andy Stewart <lazycat.manatee@gmail.com> -- Maintainer: Andy Stewart <lazycat.manatee@gmail.com> -- --- Copyright (C) 2010 Andy Stewart, all rights reserved.+-- Copyright (C) 2010 ~ 2011 Andy Stewart, all rights reserved. --  -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by@@ -26,14 +26,15 @@ import Data.Text.Lazy (Text) import Data.Typeable import Graphics.UI.Gtk hiding (Statusbar, statusbarNew, get)-import Graphics.UI.Gtk.Gdk.SerializedEvent import Graphics.UI.Gtk.Vte.Vte+import Manatee.Core.Config import Manatee.Core.DBus import Manatee.Core.PageFrame import Manatee.Core.PageView import Manatee.Core.Types import Manatee.Extension.Terminal.TerminalBuffer-import Manatee.Toolkit.Gtk.Gtk+import Manatee.Toolkit.General.STM+import Manatee.Toolkit.Gtk.ScrolledWindow import Paths_manatee_terminal import System.FilePath @@ -56,14 +57,19 @@   pageBufferPackageName _       = fmap takeFileName getDataDir  instance PageView TerminalView where-    pageViewBuffer              = PageBufferWrap . terminalViewBuffer-    pageViewPlugId              = terminalViewPlugId-    pageViewBox                 = pageFrameBox . terminalViewFrame-    pageViewScrolledWindow      = terminalViewScrolledWindow-    pageViewFocus               = widgetGrabFocus . terminalViewView-    pageViewCopy                = terminalViewCopy-    pageViewPaste               = terminalViewPaste-    pageViewHandleKeyAction     = terminalViewHandleKeyAction+    pageViewBuffer               = PageBufferWrap . terminalViewBuffer+    pageViewPlugId               = terminalViewPlugId+    pageViewFrame                = terminalViewFrame+    pageViewLocalKeymap _        = terminalViewLocalKeymap+    pageViewLocalCommandMap _    = terminalViewLocalCommandMap+    pageViewFocus                = widgetGrabFocus . terminalViewView+    pageViewPropagateWidget      = castToWidget . terminalViewView+    pageViewSaveState view       = terminalViewSaveState view Nothing+    pageViewRestoreState view    = terminalViewRestoreState view Nothing+    pageViewWriteState view path = terminalViewSaveState view (Just path)+    pageViewReadState view path  = terminalViewRestoreState view (Just path)+    pageViewCopy                 = terminalViewCopy+    pageViewPaste                = terminalViewPaste  -- | New terminal view. terminalViewNew :: TerminalBuffer -> PagePlugId -> IO TerminalView@@ -85,16 +91,14 @@   -- Return view.   return terminalView --- | Handle key action.-terminalViewHandleKeyAction :: TerminalView -> Text -> SerializedEvent -> IO ()-terminalViewHandleKeyAction view keystoke sEvent = -  case M.lookup keystoke terminalViewKeymap of-    Just action -> action view-    Nothing -> widgetPropagateEvent (terminalViewView view) sEvent+-- | Keymap.+terminalViewLocalKeymap :: Map Text Text+terminalViewLocalKeymap = +  M.fromList []  -- | Keymap.-terminalViewKeymap :: Map Text (TerminalView -> IO ())-terminalViewKeymap = +terminalViewLocalCommandMap :: Map Text (TerminalView -> IO ())+terminalViewLocalCommandMap =    M.fromList []  -- | Terminal view copy.@@ -110,6 +114,32 @@   return True  -- | Scrolled window.-terminalViewScrolledWindow :: TerminalView -> ScrolledWindow  +terminalViewScrolledWindow :: TerminalView -> ScrolledWindow terminalViewScrolledWindow =-    pageFrameScrolledWindow . terminalViewFrame+  pageFrameScrolledWindow . terminalViewFrame++-- | Save state.+terminalViewSaveState :: TerminalView -> Maybe FilePath -> IO ()+terminalViewSaveState view@(TerminalView {terminalViewBuffer     = buffer}) +                      statePath = do+  -- Get scroll position.+  scrolledWindowPosition <- scrolledWindowGetValue (terminalViewScrolledWindow view)++  -- Save state.+  let state = TerminalState scrolledWindowPosition+  case statePath of+    Nothing   -> writeTVarIO (terminalBufferState buffer) state+    Just path -> writeConfigPath path state++-- | Restore state.+terminalViewRestoreState :: TerminalView -> Maybe FilePath -> IO ()+terminalViewRestoreState view@(TerminalView {terminalViewBuffer  = buffer})+                         statePath = do+  bufferState <- readTVarIO (terminalBufferState buffer)+  (TerminalState scrolledWindowPosition) <- +      case statePath of+        Just path -> readConfigPath path bufferState+        Nothing   -> return bufferState++  -- Restore scroll position.+  scrolledWindowSetValue (terminalViewScrolledWindow view) scrolledWindowPosition
Setup.hs view
@@ -1,7 +1,7 @@ -- Author:     Andy Stewart <lazycat.manatee@gmail.com> -- Maintainer: Andy Stewart <lazycat.manatee@gmail.com> -- --- Copyright (C) 2010 Andy Stewart, all rights reserved.+-- Copyright (C) 2010 ~ 2011 Andy Stewart, all rights reserved. --  -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by@@ -19,6 +19,7 @@ import Distribution.Simple import Manatee.Core.Config import Manatee.Core.Types+import Manatee.Toolkit.Cabal.Utils import Manatee.Toolkit.General.List import Manatee.Toolkit.General.Map import Manatee.Extension.Terminal.PageMode@@ -28,7 +29,7 @@ main = defaultMainWithHooks         simpleUserHooks {          -- Update Rule after install successful.-         postInst = \ _ _ _ _ -> do+         postInst = \ _ _ pack_des lbi -> do              -- Update PageTypeRule.              (PageTypeRule typeRule) <- readConfig pageTypeRulePath (PageTypeRule M.empty)              writeConfig pageTypeRulePath (PageTypeRule (M.insert "PageTerminal" "manatee-terminal" typeRule))@@ -39,5 +40,14 @@              -- Update ExtensionGloalKeymap.              (ExtensionGloalKeymap keymap) <- readConfig extensionGlobalKeymapPath (ExtensionGloalKeymap M.empty)              writeConfig extensionGlobalKeymapPath (ExtensionGloalKeymap-                                                    (M.insert "P-n" ("PageTerminal", "Terminal", []) keymap))+                                                    (M.insert "P-n" ("Terminal",+                                                                     ("PageTerminal", "Terminal", [])) keymap))+             -- Update Application info.+             let snapshotPath = getDataFilePath pack_des lbi "data/welcome/snapshot.png"+             (WelcomeApplication apps) <- readConfig welcomeApplicationPath (WelcomeApplication M.empty)+             writeConfig welcomeApplicationPath (WelcomeApplication+                                                 (M.insert +                                                       ("Terminal", snapshotPath)+                                                       ("PageTerminal", "Terminal", [])+                                                       apps))        }
+ data/welcome/snapshot.png view

binary file changed (absent → 93028 bytes)

manatee-terminal.cabal view
@@ -1,9 +1,9 @@ name:			manatee-terminal-version:		0.0.8+version:		0.1.0 Cabal-Version:	>= 1.6 license:		GPL-3 license-file:	LICENSE-copyright:		(c) 2009 ~ 2010 Andy Stewart+copyright:		(c) 2010 ~ 2011 Andy Stewart synopsis:		Terminal Emulator extension for Manatee. description:    manatee-terminal is terminal emulator extension for Manatee (Haskell/Gtk+ Integrated Live Environment)  .@@ -11,7 +11,7 @@  .  VTE widget will replace by MVC design terminal emulator widget in the future, as temporary solution, please make sure command have finish before you close terminal buffer, i warning you. :)  .- Video at (Select 720p HD) at : <http://www.youtube.com/watch?v=weS6zys3U8k> <http://www.youtube.com/watch?v=A3DgKDVkyeM> <http://v.youku.com/v_show/id_XMjI2MDMzODI4.html>+ Video (Select 720p HD) at : <http://www.youtube.com/watch?v=weS6zys3U8k> <http://www.youtube.com/watch?v=A3DgKDVkyeM> <http://v.youku.com/v_show/id_XMjI2MDMzODI4.html>  .  Screenshots at : <http://goo.gl/MkVw>  .@@ -26,16 +26,19 @@ stability:		provisional category:		Manatee, Download Manager, Network -tested-with:	GHC==6.12.3+tested-with:	GHC==7.0.2 build-type:		Custom +data-dir: ""+data-files: data/welcome/snapshot.png+ Source-Repository head   type:         darcs   location:     http://patch-tag.com/r/AndyStewart/manatee-terminal    Library-     build-depends: base >= 4 && < 5, manatee-core >= 0.0.8, dbus-client >= 0.3 && < 0.4, stm >= 2.1.2.0,-                    containers >= 0.3.0.0, gtk-serialized-event >= 0.12.0, gtk >= 0.12.0, vte >= 0.12.0,+     build-depends: base >= 4 && < 5, manatee-core >= 0.1.0, dbus-client >= 0.3 && < 0.4, stm >= 2.1.2.0,+                    containers >= 0.3.0.0, gtk >= 0.12.0, vte >= 0.12.0, derive, binary,                     text >= 0.7.1.0, filepath, unix      exposed-modules:          Manatee.Extension.Terminal