Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2004-09

Keyboard unit questions

5 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Alan Mead

I just used the keyboard unit for the first time and it's quite impressive but I have some questions.

Initially, I couldn't link on my old RH 7.2 machine because FPC 1.9.4 couldn't find the GPM libraries. This is probably a stupid question but is there a way that FPC can find libraries better so that I don't have to ln -s /usr/libgpm.so.1 to /usr/libgpm.so? This has happened with other FPC units...

Anyway, isn't GPM a mouse package?!? I didn't consult the unit's source but I don't see any mouse functionality in the docs? Just curious.

And finally, I pasted my little example program below. When I run it in Konsole and it has some funny behavior. Like Shift-F2 is reported as F4 and Control-U is reported as 'SHIFT' ^A and ^E don't seem to have any text associated with them (maybe it's reporting a space?). I wanted to build a simple bash-like command history/editing and I was going to use those but if I cannot read them...

In xterm it's slightly different... for example, ^A does nothing but then the next charcter shows as SHIFT x (e.g., ^Aa shows as 'SHIFT a') and Shift-F2 shows three keys.. 'Key with scancode 6144', 2, and Q while Shift-F3 shows the same scancode and then 2,R.

I tried adding the shift state but that didn't change anything and the shift states don't seem to be read accuractely (control and alt are never read).

Thanks!

-Alan

program readline;
uses keyboard;
  procedure ReadKBD(var S: String);
    var K : TkeyEvent;
    begin
      InitKeyboard;
      Repeat
        K:=GetKeyEvent;
        K:=TranslateKeyEvent(K);
        writeln(KeyEventToString(K));
      Until (GetKeyEventChar(K)='q');
      DoneKeyboard;
    end;
var S:String;
begin
  ReadKBD(S);
end.

-Alan

Reply by email

John Coppens
to Alan Mead
Show quoted text 8 lines
I just used the keyboard unit for the first time and it's quite impressive but I have some questions. Initially, I couldn't link on my old RH 7.2 machine because FPC 1.9.4 couldn't find the GPM libraries. This is probably a stupid question but is there a way that FPC can find libraries better so that I don't have to ln -s /usr/libgpm.so.1 to /usr/libgpm.so? This has happened with other FPC units...

Hi Alan.

Surely someone with more experience will correct me. But for starters:

libgpm.so.1 shouldn't be in /usr - it should be either in usr/lib or usr/local/lib. In that case, your machine will automatically do the link, when it executes ldconfig.

Anyway, isn't GPM a mouse package?!? I didn't consult the unit's source but I don't see any mouse functionality in the docs? Just curious.

GPM is a combination of both - it permits using the mouse to 'paint' parts of text screens and past them as if someone is typing - so it does have something to mouse _and_ keyboard.

Show quoted text 6 lines
And finally, I pasted my little example program below. When I run it in Konsole and it has some funny behavior. Like Shift-F2 is reported as F4 and Control-U is reported as 'SHIFT' ^A and ^E don't seem to have any text associated with them (maybe it's reporting a space?). I wanted to build a simple bash-like command history/editing and I was going to use those but if I cannot read them...

Can't help you there.

John

Show quoted text 40 lines
In xterm it's slightly different... for example, ^A does nothing but then the next charcter shows as SHIFT x (e.g., ^Aa shows as 'SHIFT a') and Shift-F2 shows three keys.. 'Key with scancode 6144', 2, and Q while Shift-F3 shows the same scancode and then 2,R. I tried adding the shift state but that didn't change anything and the shift states don't seem to be read accuractely (control and alt are never read). Thanks! -Alan program readline; uses keyboard; procedure ReadKBD(var S: String); var K : TkeyEvent; begin InitKeyboard; Repeat K:=GetKeyEvent; K:=TranslateKeyEvent(K); writeln(KeyEventToString(K)); Until (GetKeyEventChar(K)='q'); DoneKeyboard; end; var S:String; begin ReadKBD(S); end. -Alan _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Alan Mead
to John Coppens
--- John Coppens wrote 26 lines
On Fri, 10 Sep 2004 08:33:21 -0700 (PDT) Alan Mead wrote: > I just used the keyboard unit for the first time and it's quite > impressive but I have some questions. > > Initially, I couldn't link on my old RH 7.2 machine because FPC 1.9.4 > couldn't find the GPM libraries. This is probably a stupid question > but is there a way that FPC can find libraries better so that I don't > have to ln -s /usr/libgpm.so.1 to /usr/libgpm.so? This has happened > with other FPC units... Hi Alan. Surely someone with more experience will correct me. But for starters: libgpm.so.1 shouldn't be in /usr - it should be either in usr/lib or usr/local/lib. In that case, your machine will automatically do the link, when it executes ldconfig.

John, thanks for your reply... Sorry, I should have been clearer. And I typed wrong. The library was in /usr/lib but I guess FPC is looking for 'libgpm.so' rather than 'libgpm.so.1' .. it's the '.1' that fools FPC and it's happened before. I don't know if it's a RedHat thing .. because /usr/lib/libgpm.so.1 is, itself, a sim link to something like /usr/lib/libgpm.so.1.18.1.. I gather that's the way that one reconciles having the version number in the shared library while trying to let linkers find the libraries... I just wonder why FPC doesn't understand... Maybe this is considered such a trivial matter to people that can write compilers :) Or maybe this is an incompatibility between Linux distro's and RH just loses?

[snip]

Show quoted text 5 lines
> And finally, I pasted my little example program below. When I run it > in Konsole and it has some funny behavior. Like Shift-F2 is reported > as F4 and Control-U is reported as 'SHIFT' ^A and ^E don't seem

[snip]

Can't help you there.

I've had other programs mis-behave... The command history bits of my favorite text adventure game works fine in console mode but screws things up when I'm in Konsole. I spent a little while goggling around about keyboards and character sets and X ... but X is probably the area of Linux that I know the least and I didn't understand any of the stuff I found.

-Alan

Reply by email

Jonas Maebe
to Alan Mead
Alan Mead wrote
John, thanks for your reply... Sorry, I should have been clearer. And I typed wrong. The library was in /usr/lib but I guess FPC is looking for 'libgpm.so' rather than 'libgpm.so.1' .. it's the '.1' that fools FPC and it's happened before.

It's not FPC, it's the linker. If a package is properly installed, there should always be a .so variant.

Jonas

Reply by email

John Coppens
to Alan Mead: John, thanks for your reply... Sorry, I should have been clearer. And I typed wrong. The…
Show quoted text 13 lines
John, thanks for your reply... Sorry, I should have been clearer. And I typed wrong. The library was in /usr/lib but I guess FPC is looking for 'libgpm.so' rather than 'libgpm.so.1' .. it's the '.1' that fools FPC and it's happened before. I don't know if it's a RedHat thing .. because /usr/lib/libgpm.so.1 is, itself, a sim link to something like /usr/lib/libgpm.so.1.18.1.. I gather that's the way that one reconciles having the version number in the shared library while trying to let linkers find the libraries... I just wonder why FPC doesn't understand... Maybe this is considered such a trivial matter to people that can write compilers :) Or maybe this is an incompatibility between Linux distro's and RH just loses?

If I'm not terribly mistaken, executing ldconfig should generate those links automatically. libgpm.so.1 should automatically generate a libgpm.so if you run it (and you should after installing a new library).

That is, of course if /etc/ld.so.conf contains the directory where libgpm is installed.

an't help you there.

Show quoted text 8 lines
I've had other programs mis-behave... The command history bits of my favorite text adventure game works fine in console mode but screws things up when I'm in Konsole. I spent a little while goggling around about keyboards and character sets and X ... but X is probably the area of Linux that I know the least and I didn't understand any of the stuff I found.

As I said - I can't help you there. I've suffered to get fonts working like I wanted under X. I had quite a few problems getting 'composing' working on the keyboard (te get accented characters). The only thing I can recommend is to read the "Keyboard-and-Console-HOWTO" which is probably installed somewhere on your machine and is quite extensive.

I have seen that Xterm has its own ways with many things, which could cause your differences. Almost any other program will act in a more standard way.

Greetings,
John

Reply by email