GithubHelp home page GithubHelp logo

batterseapower / ansi-terminal Goto Github PK

View Code? Open in Web Editor NEW
16.0 5.0 4.0 458 KB

Simple Haskell ANSI terminal support, with Windows compatibility

Home Page: http://batterseapower.github.com/ansi-terminal

License: BSD 3-Clause "New" or "Revised" License

Shell 2.90% Haskell 97.10%

ansi-terminal's Introduction

ANSI Terminal

For all information on this package, please consult the homepage

ansi-terminal's People

Contributors

23skidoo avatar batterseapower avatar ekmett avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ansi-terminal's Issues

exception when using inside Notepad++ embedded console

Hi, Max!

I'm trying to use Notepad++ as my IDE for Haskell. And I'm having problems with ansi-terminal working within the console window that Notepad++ provides. I'm getting
* Exception: getConsoleScreenBufferInfo: invalid argument (* Exception: : hPutChar: invalid argument (invalid character)

I didn't use much of ansi-terminal API yet, just clearScreen and setCursorPosition for now.

Sorry if all these have an obvious resolution, I'm new to Haskell. And don't hesitate to ask if you need any details to fix this

Linking msvcrt into mingw programs is not supported.

Since GHC is using mingw on windows, it is incorrect to also link msvcrt into the same executable. This in theory could cause problems for haskell programs as well, but it certainly breaks hsc2hs: if a program depends on ansi-terminal, using hsc2hs in such a program will make it unbuildable. The executables generated by hsc2hs will link msvcrt (due to ansi-terminal) and segfault on startup (since they are compiled with mingw and linking the mingw runtime). This makes darcs unbuildable on windows if you enable testing (i.e. we can't run tests due to this problem).

error

Importing the library does not work

$ ghc Main.hs

Main.o: In function `skH_info':
(.text+0x1a9): undefined reference to `__stginit_ansizmterminalzm0zi5zi5_SystemziConsoleziANSI_'
collect2: ld returned 1 exit status

$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 6.12.3

$ cabal install ansi-terminal -v
/usr/bin/ghc --numeric-version
looking for package tool: ghc-pkg near compiler in /usr/bin
found package tool in /usr/bin/ghc-pkg
/usr/bin/ghc-pkg --version
/usr/bin/ghc --supported-languages
Reading installed packages...
/usr/bin/ghc-pkg dump --global
/usr/bin/ghc-pkg dump --user
Reading available packages...
Resolving dependencies...
selecting ansi-terminal-0.5.5 (hackage) and discarding ansi-terminal-0.1, 0.2,
0.2.1, 0.3.0, 0.3.1, 0.4.0, 0.5.0, 0.5.1, 0.5.2, 0.5.3, 0.5.4, unix-2.0 and
2.2.0.0
selecting unix-2.4.0.2 (installed or hackage) and discarding unix-2.3.0.0,
2.3.1.0, 2.3.2.0, 2.4.0.0, 2.4.0.1, 2.4.1.0, 2.4.2.0 and 2.5.0.0
selecting base-3.0.3.2 (installed) and 4.2.0.2 (installed) and discarding
syb-0.1.0.0, 0.1.0.1, 0.1.0.2, 0.1.0.3, 0.2, 0.2.1, 0.2.2, 0.3, 0.3.1, 0.3.2,
0.3.3, 0.3.4, 0.3.5 and 0.3.6
selecting ghc-prim-0.2.0.0 (installed)
selecting integer-gmp-0.2.0.1 (installed)
selecting rts-1.0 (installed)
selecting syb-0.1.0.2 (installed)
In order, the following would be installed:
ansi-terminal-0.5.5 (new package)
Downloading ansi-terminal-0.5.5...
Downloaded to
/home/te/.cabal/packages/hackage.haskell.org/ansi-terminal/0.5.5/ansi-terminal-0.5.5.tar.gz
Extracting
/home/te/.cabal/packages/hackage.haskell.org/ansi-terminal/0.5.5/ansi-terminal-0.5.5.tar.gz
to /tmp/ansi-terminal-0.5.58519...
Configuring ansi-terminal-0.5.5...
Flags chosen: example=False, splitbase=True
Dependency base ==4.2.0.2: using base-4.2.0.2
Dependency unix ==2.4.0.2: using unix-2.4.0.2
Using Cabal-1.8.0.2 compiled by ghc-6.12
Using compiler: ghc-6.12.3
Using install prefix: /home/te/.cabal
Binaries installed in: /home/te/.cabal/bin
Libraries installed in: /home/te/.cabal/lib/ansi-terminal-0.5.5/ghc-6.12.3
Private binaries installed in: /home/te/.cabal/libexec
Data files installed in: /home/te/.cabal/share/ansi-terminal-0.5.5
Documentation installed in: /home/te/.cabal/share/doc/ansi-terminal-0.5.5
Using alex version 2.3.3 found on system at: /usr/bin/alex
Using ar found on system at: /usr/bin/ar
No c2hs found
No cpphs found
No ffihugs found
Using gcc version 4.5.2 found on system at: /usr/bin/gcc
Using ghc version 6.12.3 found on system at: /usr/bin/ghc
Using ghc-pkg version 6.12.3 found on system at: /usr/bin/ghc-pkg
No greencard found
Using haddock version 2.6.1 found on system at: /usr/bin/haddock
Using happy version 1.18.4 found on system at: /usr/bin/happy
No hmake found
Using hsc2hs version 0.67 found on system at: /usr/bin/hsc2hs
No hscolour found
No hugs found
No jhc found
Using ld found on system at: /usr/bin/ld
No lhc found
No lhc-pkg found
No nhc98 found
Using pkg-config version 0.25 found on system at: /usr/bin/pkg-config
Using ranlib found on system at: /usr/bin/ranlib
Using strip found on system at: /usr/bin/strip
Using tar found on system at: /bin/tar
Creating dist/build (and its parents)
Creating dist/build/autogen (and its parents)
Preprocessing library ansi-terminal-0.5.5...
Preprocessing executables for ansi-terminal-0.5.5...
Building ansi-terminal-0.5.5...
Building library...
Creating dist/build (and its parents)
/usr/bin/ghc --make -package-name ansi-terminal-0.5.5 -hide-all-packages -fbuilding-cabal-package -i -idist/build -i. -idist/build/autogen -Idist/build/autogen -Idist/build -optP-DUNIX -optP-Iincludes -optP-include -optPdist/build/autogen/cabal_macros.h -odir dist/build -hidir dist/build -stubdir dist/build -package-id base-4.2.0.2-10bdacb430274706a59728e237e2bfb3 -package-id unix-2.4.0.2-8b7fb1ebcdcb8db413d44db018f084d7 -O -Wall -XCPP -XForeignFunctionInterface System.Console.ANSI System.Console.ANSI.Unix System.Console.ANSI.Common
[1 of 3] Compiling System.Console.ANSI.Common ( System/Console/ANSI/Common.hs, dist/build/System/Console/ANSI/Common.o )
[2 of 3] Compiling System.Console.ANSI.Unix ( System/Console/ANSI/Unix.hs, dist/build/System/Console/ANSI/Unix.o )
[3 of 3] Compiling System.Console.ANSI ( System/Console/ANSI.hs, dist/build/System/Console/ANSI.o )
Linking...
/usr/bin/ar -r dist/build/libHSansi-terminal-0.5.5.a dist/build/System/Console/ANSI.o dist/build/System/Console/ANSI/Unix.o dist/build/System/Console/ANSI/Common.o
/usr/bin/ar: creating dist/build/libHSansi-terminal-0.5.5.a
/usr/bin/ld -x -r -o dist/build/HSansi-terminal-0.5.5.o dist/build/System/Console/ANSI.o dist/build/System/Console/ANSI/Unix.o dist/build/System/Console/ANSI/Common.o
/usr/bin/ghc --abi-hash -package-name ansi-terminal-0.5.5 -hide-all-packages -fbuilding-cabal-package -i -idist/build -i. -idist/build/autogen -Idist/build/autogen -Idist/build -optP-DUNIX -optP-Iincludes -optP-include -optPdist/build/autogen/cabal_macros.h -odir dist/build -hidir dist/build -stubdir dist/build -package-id base-4.2.0.2-10bdacb430274706a59728e237e2bfb3 -package-id unix-2.4.0.2-8b7fb1ebcdcb8db413d44db018f084d7 -O -Wall -XCPP -XForeignFunctionInterface System.Console.ANSI
Registering ansi-terminal-0.5.5...
/usr/bin/ghc-pkg update - --package-conf=dist/package.conf.inplace
directory dist/doc/html/ansi-terminal does exist: False
Creating /home/te/.cabal/share/doc/ansi-terminal-0.5.5 (and its parents)
Installing LICENSE to /home/te/.cabal/share/doc/ansi-terminal-0.5.5/LICENSE
Installing library in /home/te/.cabal/lib/ansi-terminal-0.5.5/ghc-6.12.3
Creating /home/te/.cabal/lib/ansi-terminal-0.5.5/ghc-6.12.3/System/Console
(and its parents)
Creating
/home/te/.cabal/lib/ansi-terminal-0.5.5/ghc-6.12.3/System/Console/ANSI (and
its parents)
Installing dist/build/System/Console/ANSI.hi to
/home/te/.cabal/lib/ansi-terminal-0.5.5/ghc-6.12.3/System/Console/ANSI.hi
Installing dist/build/System/Console/ANSI/Unix.hi to
/home/te/.cabal/lib/ansi-terminal-0.5.5/ghc-6.12.3/System/Console/ANSI/Unix.hi
Installing dist/build/System/Console/ANSI/Common.hi to
/home/te/.cabal/lib/ansi-terminal-0.5.5/ghc-6.12.3/System/Console/ANSI/Common.hi
Creating /home/te/.cabal/lib/ansi-terminal-0.5.5/ghc-6.12.3 (and its parents)
Installing dist/build/libHSansi-terminal-0.5.5.a to
/home/te/.cabal/lib/ansi-terminal-0.5.5/ghc-6.12.3/libHSansi-terminal-0.5.5.a
Creating /home/te/.cabal/lib/ansi-terminal-0.5.5/ghc-6.12.3 (and its parents)
Installing dist/build/HSansi-terminal-0.5.5.o to
/home/te/.cabal/lib/ansi-terminal-0.5.5/ghc-6.12.3/HSansi-terminal-0.5.5.o
/usr/bin/ghc --abi-hash -package-name ansi-terminal-0.5.5 -hide-all-packages -fbuilding-cabal-package -i -idist/build -i. -idist/build/autogen -Idist/build/autogen -Idist/build -optP-DUNIX -optP-Iincludes -optP-include -optPdist/build/autogen/cabal_macros.h -odir dist/build -hidir dist/build -stubdir dist/build -package-id base-4.2.0.2-10bdacb430274706a59728e237e2bfb3 -package-id unix-2.4.0.2-8b7fb1ebcdcb8db413d44db018f084d7 -O -Wall -XCPP -XForeignFunctionInterface System.Console.ANSI
Registering ansi-terminal-0.5.5...
/usr/bin/ghc-pkg update - --user

Missing C library: kernel32

Hi Max,

Sorry if this is something well-understood, but my Google-fu fails me. I received a support request from somebody trying to use my program GenI, which depends on test-framework and consequently ansi-terminal.

What they said follows. Any advice about debugging steps I could ask them to do? I don't know enough about Windows to know what to say.


 $ cabal install GenI
 Resolving dependencies...
 Configuring ansi-terminal-0.5.5...
 cabal.exe: Missing dependency on a foreign library:
 * Missing C library: kernel32
 This problem can usually be solved by installing the system package that
 provides this library (you may need the "-dev" version). If the library is
 already installed but in a non-standard location then you can use the flags
 --extra-include-dirs= and --extra-lib-dirs= to specify where it is.
 cabal.exe: Error: some packages failed to install:
 GenI-0.20.2 depends on ansi-terminal-0.5.5 which failed to install.
 ansi-terminal-0.5.5 failed during the configure step. The exception was:
 ExitFailure 1
 ansi-wl-pprint-0.6.3 depends on ansi-terminal-0.5.5 which failed to install.
 test-framework-0.2.4 depends on ansi-terminal-0.5.5 which failed to install.
 test-framework-hunit-0.2.6 depends on ansi-terminal-0.5.5 which failed to
 install.
 test-framework-quickcheck-0.2.7 depends on ansi-terminal-0.5.5 which failed to
 install.

This dll is very much there in C:\Windows\System32 and I also tried giving its path in --extra-include-dirs and --extra-lib-dirs but it still didn't work.

Allow more colours?

Hi, I am just wondering why this package only support limited colours? Thanks ๐Ÿ˜„

getConsoleCursorInfo exception w/ hideCursor on Windows

This bug seems to only occur in some relatively specific circumstances -- we've been able to reproduce it reliably by ssh-ing into a cygwin shell running on windows:

Reproduction:

  • ssh into a cygwin ssh server running on windows (32-bit XP, 32-bit Vista and 64-bit Vista all exhibit this problem, we haven't tested others.)
  • start up ghci (ghcii.sh -- 6.10.4 and 6.12.1 both exhibit the bug, haven't tested others.)
  • load the System.Console.ANSI module: (:m + System.Console.ANSI)
  • invoke hideCursor. This should result in: *** Exception: getConsoleCursorInfo: invalid argument (The handle is invalid.)

This happens as either an unprivileged user or as administrator, so we do not believe it is related to the cygwin bug discussed here, although the reproduction is similar. (This bug also pre-dated cygwin 1.7.) This bug does not happen when logged in directly to a windows system, although you can ssh to localhost to reproduce it.

This came up because it prevents test-framework from running on windows build slaves that are activated via ssh-ing into a cygwin server. (even using --plain to reduce the test-framework output is insufficient, since the cursor is still hidden.) I think hideCursor (and other functions that may trigger this bug) should return error values instead of throwing exceptions.

Here's a complete log of a ghci session that triggers the bug:

hudson@corona ~
$ ghcii.sh 
GHCi, version 6.12.1: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package ffi-1.0 ... linking ... done.
Prelude> :m + System.Console.ANSI
Prelude System.Console.ANSI> hideCursor
Loading package bytestring-0.9.1.5 ... linking ... done.
Loading package Win32-2.2.0.1 ... linking ... done.
Loading package ansi-terminal-0.5.2 ... linking ... done.
*** Exception: getConsoleCursorInfo: invalid argument (The handle is invalid.)
Prelude System.Console.ANSI> 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.