![](/i/fill.gif) |
![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Fredrik Eriksson wrote:
> http://msdn.microsoft.com/en-us/library/ms682088.aspx
Oh. My. God.
I literally can't believe this... I just wrote and compiled a C program
that calls the Win32 API directly, AND IT FRIGGIN WORKED!! 0_0
*dies*
I would never have believed it was possible... I was sure it would
blue-screen the machine or crash spectacularly, but no, it actually
worked properly. (AND, best of all, it IS possible to change the colour
of just some characters in a console window. I wasn't sure it could be
done.)
I was a little shocked to discover that I already have the necessary C
header files. And, obviously, it took a litle while to figure out how to
make my Haskell compiler compile raw C files instead of Haskell programs.
The hardest part was figuring out what "warning: function foo() defined
implicitly" means. Apparently it means you spelt the function's name
wrong, so the compiler couldn't find it in the header file. This also
causes the linker to make rude comments.
But once you get over all of these things... my God, I made a direct OS
call and *didn't* crash the OS. Astonishing!
I think I need to go sit down...
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Invisible wrote:
> Oh. My. God.
>
> I literally can't believe this... I just wrote and compiled a C program
> that calls the Win32 API directly, AND IT FRIGGIN WORKED!! 0_0
>
> *dies*
..and it only took you twelve minutes!
*Falls_over_in_amazement*
John
--
"Eppur si muove" - Galileo Galilei
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Doctor John wrote:
> ..and it only took you twelve minutes!
> *Falls_over_in_amazement*
Really? Gee, it seemed like much longer than that to me...
The hard part, of course, is writing some Haskell bindings. ;-) In
particular, I cannot for the life of me figure out how to get at
symbolic constant names. :-(
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
On Wed, 20 Aug 2008 16:20:17 +0100, Invisible wrote:
> In
> particular, I cannot for the life of me figure out how to get at
> symbolic constant names. :-(
In C? Look at #define
Jim
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
On Wed, 20 Aug 2008 17:20:17 +0200, Invisible <voi### [at] dev null> wrote:
> The hard part, of course, is writing some Haskell bindings. ;-) In
> particular, I cannot for the life of me figure out how to get at
> symbolic constant names. :-(
If you are looking for 'FOREGROUND_BLUE' and the like, they are defined in
'WinCon.h'. There you will also find the structure definitions relevant to
the console subsystem.
--
FE
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
>> In
>> particular, I cannot for the life of me figure out how to get at
>> symbolic constant names. :-(
>
> In C? Look at #define
I meant how to get that stuff into Haskell.
It seems Haskell provides a magical command which somehow lets you call
a C function as if it's a Haskell function, assuming you can find a
header file that contains the C function you're after. (I literally have
*no idea* how the linker finds the actual code...) However, there seems
to be no way to import constants. In fact, every Haskell binding I've
looked at has these hard-coded in the Haskell source code rather than
imported, so I've just waded through a few KB of header files tracking
down all the #defines and their literal values.
And you know what?
I just ported my program to Haskell, AND IT STILL WORKS CORRECTLY! 0_0
This is an unprecidented level of success. It seems I can actually call
any C function I have a header file for. Wow.
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Fredrik Eriksson wrote:
> NT-based console windows do not support colour escape codes. Only 16-bit
> applications (running under NTVDM) can use colour escapes.
So this doesn't work?
http://www.windowsnetworking.com/kbase/WindowsTips/Windows2000/UserTips/Miscellaneous/CommandInterpreterAnsiSupport.html
--
Darren New / San Diego, CA, USA (PST)
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
On Wed, 20 Aug 2008 17:43:05 +0200, Darren New <dne### [at] san rr com> wrote:
> Fredrik Eriksson wrote:
>> NT-based console windows do not support colour escape codes. Only
>> 16-bit applications (running under NTVDM) can use colour escapes.
>
> So this doesn't work?
>
>
http://www.windowsnetworking.com/kbase/WindowsTips/Windows2000/UserTips/Miscellaneous/CommandInterpreterAnsiSupport.html
"the command.com shell interpreter"
"Any DOS applications you run in this command shell will now have ANSI
support."
--
FE
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
>>> NT-based console windows do not support colour escape codes. Only
>>> 16-bit applications (running under NTVDM) can use colour escapes.
>>
>> So this doesn't work?
>>
>>
http://www.windowsnetworking.com/kbase/WindowsTips/Windows2000/UserTips/Miscellaneous/CommandInterpreterAnsiSupport.html
>>
>
> "the command.com shell interpreter"
>
> "Any DOS applications you run in this command shell will now have ANSI
> support."
I've tried things like this several times before, and it's never worked
for me...
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Fredrik Eriksson wrote:
> On Wed, 20 Aug 2008 17:20:17 +0200, Invisible <voi### [at] dev null> wrote:
>> The hard part, of course, is writing some Haskell bindings. ;-) In
>> particular, I cannot for the life of me figure out how to get at
>> symbolic constant names. :-(
>
> If you are looking for 'FOREGROUND_BLUE' and the like, they are defined
> in 'WinCon.h'. There you will also find the structure definitions
> relevant to the console subsystem.
Yes. I eventually tracked those down.
Also, apparently STD_OUTPUT_HANDLE is -10, not 10. >_<
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |