Skip to content

Commit

Permalink
Fix whitespace issues (tabs and trailing spaces)
Browse files Browse the repository at this point in the history
  • Loading branch information
liskin committed May 24, 2021
1 parent af90fbe commit 28070ff
Show file tree
Hide file tree
Showing 11 changed files with 94 additions and 97 deletions.
6 changes: 3 additions & 3 deletions Graphics/X11.hs
Expand Up @@ -3,7 +3,7 @@
-- Module : Graphics.X11
-- Copyright : (c) Alastair Reid, 1999-2003
-- License : BSD-style (see the file libraries/base/LICENSE)
--
--
-- Maintainer : libraries@haskell.org
-- Stability : provisional
-- Portability : portable
Expand All @@ -12,11 +12,11 @@
--
-----------------------------------------------------------------------------

module Graphics.X11
module Graphics.X11
( module Graphics.X11.Xlib
) where

import Graphics.X11.Xlib
import Graphics.X11.Xlib

----------------------------------------------------------------
-- End
Expand Down
24 changes: 12 additions & 12 deletions Graphics/X11/ExtraTypes.hs
Expand Up @@ -3,7 +3,7 @@
-- Module : Graphics.X11.ExtraTypes
-- Copyright : (c) Alastair Reid, 1999-2003
-- License : BSD-style (see the file libraries/base/LICENSE)
--
--
-- Maintainer : libraries@haskell.org
-- Stability : unstable
-- Portability : unportable
Expand All @@ -13,24 +13,24 @@
-----------------------------------------------------------------------------

module Graphics.X11.ExtraTypes
(
-- * Types
module Graphics.X11.ExtraTypes.AP,
module Graphics.X11.ExtraTypes.DEC,
module Graphics.X11.ExtraTypes.HP,
module Graphics.X11.ExtraTypes.Sun,
module Graphics.X11.ExtraTypes.XF86,
module Graphics.X11.ExtraTypes.XorgDefault,
) where
(
-- * Types
module Graphics.X11.ExtraTypes.AP,
module Graphics.X11.ExtraTypes.DEC,
module Graphics.X11.ExtraTypes.HP,
module Graphics.X11.ExtraTypes.Sun,
module Graphics.X11.ExtraTypes.XF86,
module Graphics.X11.ExtraTypes.XorgDefault,

) where

import Graphics.X11.ExtraTypes.AP
import Graphics.X11.ExtraTypes.DEC
import Graphics.X11.ExtraTypes.HP
import Graphics.X11.ExtraTypes.Sun
import Graphics.X11.ExtraTypes.XF86
import Graphics.X11.ExtraTypes.XorgDefault

----------------------------------------------------------------
-- End
----------------------------------------------------------------
2 changes: 1 addition & 1 deletion Graphics/X11/ExtraTypes/HP.hsc
@@ -1,5 +1,5 @@
-----------------------------------------------------------------------------
--
--
-- Module : Graphics.X11.ExtraTypes.HP
-- Copyright : (c) Open Group 1987,1998, DEC 1987
-- License : X11 (see below) due to X headers
Expand Down
2 changes: 1 addition & 1 deletion Graphics/X11/Types.hsc
Expand Up @@ -58,7 +58,7 @@ module Graphics.X11.Types
xK_Delete,
xK_Multi_key,

-- SunOS does not define these.
-- SunOS does not define these.
#ifdef XK_Codeinput
xK_Codeinput,
#endif
Expand Down
4 changes: 2 additions & 2 deletions Graphics/X11/Xinerama.hsc
Expand Up @@ -104,10 +104,10 @@ xineramaQueryVersion dpy = wrapPtr2 (cXineramaQueryVersion dpy) go
go True major minor = Just (fromIntegral major, fromIntegral minor)

xineramaQueryScreens :: Display -> IO (Maybe [XineramaScreenInfo])
xineramaQueryScreens dpy =
xineramaQueryScreens dpy =
withPool $ \pool -> do intp <- pooledMalloc pool
p <- cXineramaQueryScreens dpy intp
if p == nullPtr
if p == nullPtr
then return Nothing
else do nscreens <- peek intp
screens <- peekArray (fromIntegral nscreens) p
Expand Down
24 changes: 12 additions & 12 deletions Graphics/X11/Xlib.hs
Expand Up @@ -3,7 +3,7 @@
-- Module : Graphics.X11.Xlib
-- Copyright : (c) Alastair Reid, 1999-2003
-- License : BSD-style (see the file libraries/base/LICENSE)
--
--
-- Maintainer : libraries@haskell.org
-- Stability : provisional
-- Portability : portable
Expand All @@ -19,18 +19,18 @@
--
-----------------------------------------------------------------------------

module Graphics.X11.Xlib
( -- * Conventions
-- $conventions
module Graphics.X11.Xlib
( -- * Conventions
-- $conventions

-- * Types
module Graphics.X11.Types,
-- * Types
module Graphics.X11.Types,
-- module Graphics.X11.Xlib.Types,
Display(..), Screen, Visual, GC, SetWindowAttributes, VisualInfo(..),
Point(..), Rectangle(..), Arc(..), Segment(..), Color(..),
Pixel, Position, Dimension, Angle, ScreenNumber, Buffer,
Display(..), Screen, Visual, GC, SetWindowAttributes, VisualInfo(..),
Point(..), Rectangle(..), Arc(..), Segment(..), Color(..),
Pixel, Position, Dimension, Angle, ScreenNumber, Buffer,

-- * X11 library functions
-- * X11 library functions
module Graphics.X11.Xlib.Event,
module Graphics.X11.Xlib.Display,
module Graphics.X11.Xlib.Screen,
Expand All @@ -43,8 +43,8 @@ module Graphics.X11.Xlib
module Graphics.X11.Xlib.Region,
module Graphics.X11.Xlib.Image,
module Graphics.X11.Xlib.Misc,
) where

) where

import Graphics.X11.Types
import Graphics.X11.Xlib.Types
Expand Down
104 changes: 52 additions & 52 deletions Graphics/X11/Xlib/Font.hsc
Expand Up @@ -20,7 +20,7 @@ module Graphics.X11.Xlib.Font(
fontFromGC,
loadQueryFont,
freeFont,
FontStruct,
FontStruct,
fontFromFontStruct,
ascentFromFontStruct,
descentFromFontStruct,
Expand Down Expand Up @@ -55,9 +55,9 @@ type Glyph = Word16
-- | pointer to an X11 @XFontStruct@ structure
newtype FontStruct = FontStruct (Ptr FontStruct)
#if __GLASGOW_HASKELL__
deriving (Eq, Ord, Show, Typeable, Data)
deriving (Eq, Ord, Show, Typeable, Data)
#else
deriving (Eq, Ord, Show)
deriving (Eq, Ord, Show)
#endif

-- Disnae exist: %fun LoadFont :: Display -> String -> IO Font
Expand All @@ -70,7 +70,7 @@ newtype FontStruct = FontStruct (Ptr FontStruct)

-- | interface to the X11 library function @XQueryFont()@.
foreign import ccall unsafe "HsXlib.h XQueryFont"
queryFont :: Display -> Font -> IO FontStruct
queryFont :: Display -> Font -> IO FontStruct

-- Note that this _WILL NOT WORK_ unless you have explicitly set the font.
-- I'm slowly but surely coming to the conclusion that Xlib is a pile of
Expand All @@ -79,40 +79,40 @@ foreign import ccall unsafe "HsXlib.h XQueryFont"
-- | interface to the X11 library function @XGetGCValues()@.
fontFromGC :: Display -> GC -> IO Font
fontFromGC display gc =
allocaBytes #{size XGCValues} $ \ values -> do
throwIfZero "fontFromGC" $
xGetGCValues display gc #{const GCFont} values
#{peek XGCValues,font} values
allocaBytes #{size XGCValues} $ \ values -> do
throwIfZero "fontFromGC" $
xGetGCValues display gc #{const GCFont} values
#{peek XGCValues,font} values
foreign import ccall unsafe "HsXlib.h XGetGCValues"
xGetGCValues :: Display -> GC -> ValueMask -> Ptr GCValues -> IO CInt
xGetGCValues :: Display -> GC -> ValueMask -> Ptr GCValues -> IO CInt

type ValueMask = #{type unsigned long}

-- | interface to the X11 library function @XLoadQueryFont()@.
loadQueryFont :: Display -> String -> IO FontStruct
loadQueryFont display name =
withCString name $ \ c_name -> do
fs <- throwIfNull "loadQueryFont" $ xLoadQueryFont display c_name
return (FontStruct fs)
withCString name $ \ c_name -> do
fs <- throwIfNull "loadQueryFont" $ xLoadQueryFont display c_name
return (FontStruct fs)
foreign import ccall unsafe "HsXlib.h XLoadQueryFont"
xLoadQueryFont :: Display -> CString -> IO (Ptr FontStruct)
xLoadQueryFont :: Display -> CString -> IO (Ptr FontStruct)

-- | interface to the X11 library function @XFreeFont()@.
foreign import ccall unsafe "HsXlib.h XFreeFont"
freeFont :: Display -> FontStruct -> IO ()
freeFont :: Display -> FontStruct -> IO ()
-- %fun XSetFontPath :: Display -> ListString -> IO () using XSetFontPath(arg1,arg2,arg2_size)

fontFromFontStruct :: FontStruct -> Font
fontFromFontStruct (FontStruct fs) = unsafePerformIO $
#{peek XFontStruct,fid} fs
#{peek XFontStruct,fid} fs

ascentFromFontStruct :: FontStruct -> Int32
ascentFromFontStruct (FontStruct fs) = unsafePerformIO $
#{peek XFontStruct,ascent} fs
#{peek XFontStruct,ascent} fs

descentFromFontStruct :: FontStruct -> Int32
descentFromFontStruct (FontStruct fs) = unsafePerformIO $
#{peek XFontStruct,descent} fs
#{peek XFontStruct,descent} fs

-- %prim XGetFontPath :: Display -> IO ListString
--Int r_size;
Expand All @@ -135,58 +135,58 @@ descentFromFontStruct (FontStruct fs) = unsafePerformIO $

-- We marshall this across right away because it's usually one-off info
type CharStruct =
( CInt -- lbearing (origin to left edge of raster)
, CInt -- rbearing (origin to right edge of raster)
, CInt -- width (advance to next char's origin)
, CInt -- ascent (baseline to top edge of raster)
, CInt -- descent (baseline to bottom edge of raster)
-- attributes omitted
)
( CInt -- lbearing (origin to left edge of raster)
, CInt -- rbearing (origin to right edge of raster)
, CInt -- width (advance to next char's origin)
, CInt -- ascent (baseline to top edge of raster)
, CInt -- descent (baseline to bottom edge of raster)
-- attributes omitted
)

peekCharStruct :: Ptr CharStruct -> IO CharStruct
peekCharStruct p = do
lbearing <- #{peek XCharStruct,lbearing} p
rbearing <- #{peek XCharStruct,rbearing} p
width <- #{peek XCharStruct,width} p
ascent <- #{peek XCharStruct,ascent} p
descent <- #{peek XCharStruct,descent} p
return (fromIntegral (lbearing::CShort),
fromIntegral (rbearing::CShort),
fromIntegral (width::CShort),
fromIntegral (ascent::CShort),
fromIntegral (descent::CShort))
lbearing <- #{peek XCharStruct,lbearing} p
rbearing <- #{peek XCharStruct,rbearing} p
width <- #{peek XCharStruct,width} p
ascent <- #{peek XCharStruct,ascent} p
descent <- #{peek XCharStruct,descent} p
return (fromIntegral (lbearing::CShort),
fromIntegral (rbearing::CShort),
fromIntegral (width::CShort),
fromIntegral (ascent::CShort),
fromIntegral (descent::CShort))

-- No need to put this in the IO monad - this info is essentially constant

-- | interface to the X11 library function @XTextExtents()@.
textExtents :: FontStruct -> String -> (FontDirection, Int32, Int32, CharStruct)
textExtents font_struct string = unsafePerformIO $
withCStringLen string $ \ (c_string, nchars) ->
alloca $ \ direction_return ->
alloca $ \ font_ascent_return ->
alloca $ \ font_descent_return ->
allocaBytes #{size XCharStruct} $ \ overall_return -> do
_ <- xTextExtents font_struct c_string (fromIntegral nchars) direction_return
font_ascent_return font_descent_return overall_return
direction <- peek direction_return
ascent <- peek font_ascent_return
descent <- peek font_descent_return
cs <- peekCharStruct overall_return
return (direction, ascent, descent, cs)
withCStringLen string $ \ (c_string, nchars) ->
alloca $ \ direction_return ->
alloca $ \ font_ascent_return ->
alloca $ \ font_descent_return ->
allocaBytes #{size XCharStruct} $ \ overall_return -> do
_ <- xTextExtents font_struct c_string (fromIntegral nchars) direction_return
font_ascent_return font_descent_return overall_return
direction <- peek direction_return
ascent <- peek font_ascent_return
descent <- peek font_descent_return
cs <- peekCharStruct overall_return
return (direction, ascent, descent, cs)
foreign import ccall unsafe "HsXlib.h XTextExtents"
xTextExtents :: FontStruct -> CString -> CInt ->
Ptr FontDirection -> Ptr Int32 -> Ptr Int32 ->
Ptr CharStruct -> IO CInt
xTextExtents :: FontStruct -> CString -> CInt ->
Ptr FontDirection -> Ptr Int32 -> Ptr Int32 ->
Ptr CharStruct -> IO CInt

-- No need to put ths in the IO monad - this info is essentially constant

-- | interface to the X11 library function @XTextWidth()@.
textWidth :: FontStruct -> String -> Int32
textWidth font_struct string = unsafePerformIO $
withCStringLen string $ \ (c_string, len) ->
xTextWidth font_struct c_string (fromIntegral len)
withCStringLen string $ \ (c_string, len) ->
xTextWidth font_struct c_string (fromIntegral len)
foreign import ccall unsafe "HsXlib.h XTextWidth"
xTextWidth :: FontStruct -> CString -> CInt -> IO Int32
xTextWidth :: FontStruct -> CString -> CInt -> IO Int32

-- XTextExtents16 omitted
-- XTextWidth16 omitted
Expand Down
3 changes: 0 additions & 3 deletions X11.cabal
Expand Up @@ -82,8 +82,5 @@ library
include-dirs: include
ghc-options: -funbox-strict-fields -Wall -fno-warn-unused-binds

if impl(ghc >= 7.10)
ghc-options: -fno-warn-tabs

if flag(pedantic)
ghc-options: -Werror
2 changes: 1 addition & 1 deletion configure.ac
Expand Up @@ -9,7 +9,7 @@ else
# Safety check: Ensure that we are in the correct source directory.
AC_CONFIG_SRCDIR([include/HsXlib.h])

AC_CONFIG_HEADERS([include/HsX11Config.h include/X11_extras_config.h])
AC_CONFIG_HEADERS([include/HsX11Config.h include/X11_extras_config.h])

# Check for X11 include paths and libraries
AC_PATH_XTRA
Expand Down
18 changes: 9 additions & 9 deletions doc/HSX11.xml
Expand Up @@ -23,7 +23,7 @@

<!-- Table of contents -->
<toc></toc>

<chapter id="introduction">
<title>Introduction</title>

Expand Down Expand Up @@ -67,7 +67,7 @@

<para>In addition, we chose to take advantage of Haskell's
module system to allow us to drop common prefixes
(<literal>X</literal>, <literal>XA_</literal>, etc.)
(<literal>X</literal>, <literal>XA_</literal>, etc.)
attached to X11 identifiers. For example, we translate
some C functions, constants and types as follows:</para>

Expand Down Expand Up @@ -175,7 +175,7 @@
<entry><function>Arc</function></entry>
<entry><function>(Position,Position,Dimension,Dimension,Int,Int)</function></entry>
</row>

<row>
<entry><function>XColor</function></entry>
<entry><function>Color</function></entry>
Expand Down Expand Up @@ -222,7 +222,7 @@ lookupColor
openDisplay
parseColor
queryBestCursor
queryBestSize
queryBestSize
queryBestStipple
queryBestTile
rotateBuffers
Expand Down Expand Up @@ -270,11 +270,11 @@ XDrawPoints(Display *display,
<para>is given the Haskell type:</para>

<programlisting>
drawPoints :: Display
-> Drawable
-> GC
-> [Point]
-> CoordinateMode
drawPoints :: Display
-> Drawable
-> GC
-> [Point]
-> CoordinateMode
-> IO ()
</programlisting>

Expand Down

0 comments on commit 28070ff

Please sign in to comment.