Skip to content

Commit

Permalink
Enabled pango frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
noughtmare authored and ethercrow committed Aug 14, 2016
1 parent aec6acd commit 695acb7
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 41 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Expand Up @@ -9,6 +9,7 @@ addons:
apt:
packages:
- ghc-8.0.1
- libgconf2-dev
sources: hvr-ghc

before_install:
Expand All @@ -17,6 +18,7 @@ before_install:
- export PATH=/opt/ghc/8.0.1/bin:$PATH

install:
- stack install gtk2hs-buildtools
- stack test -j2 --no-run-tests

script:
Expand Down
8 changes: 4 additions & 4 deletions lts.yaml
Expand Up @@ -2,7 +2,8 @@ flags: {}
packages:
- yi-core
- yi-frontend-vty
# - yi-frontend-pango
- yi-frontend-pango
- yi-frontend-pango-gnome
- yi-keymap-cua
- yi-keymap-emacs
- yi-keymap-vim
Expand All @@ -13,9 +14,8 @@ packages:
- yi-language
- yi
extra-deps:
- Hclip-3.0.0.3
- ListLike-4.5
# - gconf-0.13.1.0
resolver: lts-6.9
- gconf-0.13.0.3
resolver: lts-6.10
nix:
shell-file: shell.nix
9 changes: 4 additions & 5 deletions stack.yaml
Expand Up @@ -2,7 +2,8 @@ flags: {}
packages:
- yi-core
- yi-frontend-vty
# - yi-frontend-pango
- yi-frontend-pango
- yi-frontend-pango-gnome
- yi-keymap-cua
- yi-keymap-emacs
- yi-keymap-vim
Expand All @@ -12,10 +13,8 @@ packages:
- yi-ireader
- yi-language
- yi
resolver: nightly-2016-07-31
extra-deps:
- Hclip-3.0.0.3
- ListLike-4.5
# - gconf-0.13.1.0
resolver: nightly-2016-07-28
- gconf-0.13.1.0
nix:
shell-file: shell.nix
20 changes: 20 additions & 0 deletions yi-frontend-pango-gnome/package.yaml
@@ -0,0 +1,20 @@
name: yi-frontend-pango-gnome
version: 0.13.0
synopsis: Gnome support for the Pango frontend of the Yi Editor
maintainer: yi-devel@googlegroups.com
license: GPL-2
github: yi-editor/yi
category: Yi

ghc-options: -Wall

dependencies:
- base >= 4.7 && < 5
- gtk
- gconf
- text

library:
source-dirs: src
exposed-modules:
- Yi.Frontend.Pango.Gnome
Expand Up @@ -4,6 +4,7 @@ module Yi.Frontend.Pango.Gnome(watchSystemFont) where
import Control.Monad
import Graphics.UI.Gtk
import System.Gnome.GConf
import Data.Text

monospaceFontKey :: String
monospaceFontKey = "/desktop/gnome/interface/monospace_font_name"
Expand All @@ -14,7 +15,7 @@ watchSystemFont cb = do
gconfAddDir gconf "/desktop/gnome/interface"
watch gconf monospaceFontKey (cb <=< fontDescriptionFromString)

watch :: GConfValueClass value => GConf -> String -> (value -> IO ()) -> IO ()
watch :: GConf -> String -> (Text -> IO ()) -> IO ()
watch gconf key cb = do
cb =<< gconfGet gconf key
gconfNotifyAdd gconf key $ \key' val -> when (key == key') (cb val)
Expand Down
5 changes: 4 additions & 1 deletion yi-frontend-pango/package.yaml
Expand Up @@ -8,11 +8,14 @@ category: Yi

ghc-options: -Wall -ferror-spans

data-files:
- ../art/*.png
- ../art/*.pdf

dependencies:
- base >= 4.8 && < 5
- containers
- filepath
- gconf
- glib >= 0.13 && < 0.14
- gtk >= 0.13 && < 0.15
- microlens-platform
Expand Down
7 changes: 0 additions & 7 deletions yi-frontend-pango/src/Yi/Frontend/Pango.hs
Expand Up @@ -57,9 +57,6 @@ import Yi.Tab
import Yi.Types (fontsizeVariation, attributes)
import qualified Yi.UI.Common as Common
import Yi.Frontend.Pango.Control (keyTable)
#ifdef GNOME_ENABLED
import Yi.Frontend.Pango.Gnome(watchSystemFont)
#endif
import Yi.Frontend.Pango.Layouts
import Yi.Frontend.Pango.Utils
import Yi.String (showT)
Expand Down Expand Up @@ -226,11 +223,7 @@ startNoMsgGtkHook userHook cfg ch outCh ed = do
let actionCh = outCh . return
tc <- newIORef =<< newCache ed actionCh

#ifdef GNOME_ENABLED
let watchFont = watchSystemFont
#else
let watchFont = (fontDescriptionFromString ("Monospace 10" :: T.Text) >>=)
#endif
watchFont $ updateFont (configUI cfg) fontRef tc status

-- I think this is the correct place to put it...
Expand Down
44 changes: 22 additions & 22 deletions yi-frontend-pango/src/Yi/Frontend/Pango/Control.hs
Expand Up @@ -11,24 +11,24 @@

module Yi.Frontend.Pango.Control (
Control(..)
, ControlM(..)
, Buffer(..)
, View(..)
, Iter(..)
, startControl
, runControl
, controlIO
, liftYi
, getControl
, newBuffer
, newView
, getBuffer
, setBufferMode
, withCurrentBuffer
, setText
, getText
, keyTable
) where
, ControlM(..)
, Buffer(..)
, View(..)
, Iter(..)
, startControl
, runControl
, controlIO
, liftYi
, getControl
, newBuffer
, newView
, getBuffer
, setBufferMode
, withCurrentBuffer
, setText
, getText
, keyTable
) where

import Data.Text (unpack, pack, Text)
import qualified Data.Text as T
Expand Down Expand Up @@ -197,8 +197,8 @@ startNoMsg :: ControlM () -> UIBoot
startNoMsg main config input output ed = do
control <- newEmptyMVar
let wrappedMain = do
output [makeAction $ makeControl control]
void (runControl' main control)
output [makeAction $ makeControl control]
void (runControl' main control)
return (mkUI wrappedMain control)

end :: ControlM ()
Expand Down Expand Up @@ -798,9 +798,9 @@ handleMove view p0 event = do
-- Relies on uiActionCh being synchronous
selection <- liftBase $ newIORef ""
let yiAction = do
txt <- withCurrentBuffer (readRegionB =<< getSelectRegionB)
txt <- withCurrentBuffer (readRegionB =<< getSelectRegionB)
:: YiM R.YiString
liftBase $ writeIORef selection txt
liftBase $ writeIORef selection txt
runAction $ makeAction yiAction
txt <- liftBase $ readIORef selection

Expand Down
2 changes: 1 addition & 1 deletion yi-frontend-pango/src/Yi/Frontend/Pango/Utils.hs
Expand Up @@ -6,7 +6,7 @@ module Yi.Frontend.Pango.Utils where
import Control.Exception (catch, throw)

import Data.Text (append)
import Paths_yi
import Paths_yi_frontend_pango
import System.FilePath
import Graphics.UI.Gtk
import System.Glib.GError
Expand Down

0 comments on commit 695acb7

Please sign in to comment.