How to getCh on MS Windows command line?

Previous Topic Next Topic
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view

How to getCh on MS Windows command line?

Ahn, Ki Yung
What I mean by getCh is the non-buffered non-echoed version of getChar,
which Hugs used to provided as an extension but not any more.

Is there any way to have a non-buffered non-echoed single character
input function on MS Windows command line using only the libraries in
the MS Windows distribution packages of either GHC or Hugs?

The reason to why this is important for me is because I am translating
Graham Hutton's "Programming in Haskell" into Korean (soon to be
published), which illustrates interactive programming with the example
of a calculator that responds instantly for every keystroke of numbers
and arithmetic operations running on text mode.  It is very important to
consider the readers who only have access to MS Windows systems, because
Korean OS market share is completely skewed towards MS Windows for very
embarrassing reasons that I do not even want to mention.  And, isn't GHC
developed in MSR anyway?  :-)

I remember that this is an old problem for both of the two most widely
used Haskell implementation, Hugs and GHC.

In ghc 6.8 getChar had a bit strange behavior.  As far as I remember it
always worked as if it were NoBuffering.  Fortunately, in the recently
released ghc 6.10, this has been fixed.  We now actually have to set the
buffering mode to NoBuffering with hSetBufferring to get the
non-buffered behavior of getChar.  But, it still isn't working on MS

In Hugs, hSetBuffering neither works on Unix terminal nor on MS Windows
command line.  Surprisingly, it works in WinHugs.  However, I cannot use
WinHugs for my purpose because the interactive calculator example in the
book also uses beep characters and ANSI codes which do not work in WinHugs.

Thanks for any hacks or suggestions,

  Ahn, Ki Yung

Hugs-Users mailing list
[hidden email]
Reply | Threaded
Open this post in threaded view

Re: [Haskell-cafe] How to getCh on MS Windows command line?

Bulat Ziganshin-2
흐壹o 鉅,

工賊嫂, 膠墮將奄 굅, 껐갭, 맏굡별9 죌, 闔u 破訂佯

> 羸受 I 張灑 戌 銳遷h 稶 淸e 全縡醇連奄抑 全縡憶寥抑 墮膣旭n 湞 銳遷矮枳
> 婆芋h 흽奧 出抑 剃 倧貞藕抑 修 灑 予輒塡旭n 醇t 全t 灑y 獐鎭.

괼 派姪s 烈r 張 彧 預屎

銳凸藕鴨狙矮r = 一厭M ⓦ嶢.說碇퇀蹴) 伸銳諜h
烈鎭遇n 勖卒蛭 娠刷l 軸愴蓮 ㏂禎旭.h 銳諜熬
   伸銳諜h 볶 IO 촁塼

껍 暢踐祝蓮侄蹟工鴨 彩昻n 膠찢連奄彧g

全t 輒彩抑

낟 出e 彧輒賑辛. i 鴨鳶迹輒稔 鎭張將奄 淸受 i 矮d 臆蓮辛 闔u 赤抑 淸稶
投陂 倧汀飡稔 郁 投s 巴淸 蒼張 撓奧 墮膣旭災 醇t i 埃材t 鎭張橓r

눔 淸掩e 闇姮 郁's 全t 墮朕 矮進 剃 彧彩刷l 說檍 怒狸鎭 其嫂奄, 銳t
倧彦塡疊壹抑 一奠x 勖淞e 灑d 彧彩刷l 撓奧/預c 淸奄e

쭤彩 鎭詣進差
 찢藺t                            奬雩剃봔蹙受.槃詣塡僥樗午誦怡薪m

Hugs-Users mailing list
[hidden email]