PDA

View Full Version : Text Editor


SuperTek
March 16th, 2003, 19:44
Iīm making my own text editor in C and i cant figured out something:

How can i know if the user is pressing shift or ctrl? I use Linux so those DOS libraries wonīt work.

jegHegy
March 17th, 2003, 12:42
i think they have their own keycode, but i'm not sure. there are some experienced C programmers here, so expect a real answer from them ^^

nyaa

Exophase
March 17th, 2003, 20:20
Are you using SDL? SDL handles it fine, under the key mod stuff.

- Exo

SuperTek
March 17th, 2003, 22:54
Sometimes I use Allegro but what I really want to know is how to do it using only C Ansi. I think thatīs the better way to learn. But thanks for your post anyway.

ammoQ
March 17th, 2003, 23:31
If you write an X application, it's easy: Both pressing and releasing the Shift or Ctrl-Button creates a KeyPress/KeyRelease Event. If you write a console application, it's hard.

Exophase
March 18th, 2003, 04:56
Originally posted by SuperTek
Sometimes I use Allegro but what I really want to know is how to do it using only C Ansi. I think thatīs the better way to learn. But thanks for your post anyway.

Strictly speaking there isn't a way to do it using ANSI C, because ANSI C doesn't standardize a means for doing so and in general C makes no attempt to have standard library access for many things, including extensive key support (well, there's getch(), but that's no good here). So what I'm what trying to say is that there isn't an ANSI C approach, and that it instead varies entirely on what platform you're programming for. That's why I strongly suggest you stick with something like SDL or yes, Allegro, because then you both make things easier on yourself and gain a lot more portability through the abstraction.

- Exo

Kraelis
March 18th, 2003, 05:10
Today, building everything from scratch isn't practical anymore. takes too long and too darn difficult. I used to have that approach, but when it came to actual formal programming, the time constraints imposed are simply too great to consider reinventing the wheel.