backspace and delete key mappings

unix

    Next

  • 1. strptime() get segment corruption in linux
    I want to parse the user inputed date format with strptime() function in Linux. For example,"12,17:30:20" will be explained as day 12, hour 17 etc. And I want to get the exact day. I used the following code and it works well in Solaris,but Segmentation fault in Linux. Could someone help me out? ============================================= #define _XOPEN_SOURCE /* glibc2 needs this */ #include <stdio.h> #include <time.h> int main() { struct tm tm; char buf[255]; strptime("12,17:30:20", "%d", &tm); printf("ok here\n"); strftime(buf, sizeof(buf), "%d %b %Y %H:%M", &tm); puts(buf); return 0; }
  • 2. Unix newbie in class needs help creating make file.
    Hello, I apologize if this may be in the wrong group, but I need assistance creating a makefile in Unix for a class. The source files in the scenario I was given are as follows: main.cpp #include "employee.h" #include "address.h" int main() { printf("program works\n"); } employee.cpp #include "address.h" address.cpp #include <string> employee.h #ifndef EMPLOYEE_H #define EMPLOYEE_H #endif address.h #ifndef ADDRESS_H #define ADDRESS_H #incldue <stdio.h> #endif Based on these, I have created the following make file based on my notes from the class: SHELL = /bin/ksh OBJECTS = main.o employee.o address.o myProgram : $(OBJECTS) g++ -o myProgram $(OBJECTS) main.o : main.cpp employee.h address.h g++ -c main.cpp employee.o : employee.cpp address.h g++ -c employee.cpp address.o : address.cpp g++ -c address.cpp clean : rm myProgram $(OBJECTS) I have tested this with a test script that was given to me, but everything fails, reading "no targets specified and no makefile found." Am I close, so far off, right on, somewhere in between? Thanks for all help in advance. Jay
  • 3. Yacc: Recursion and Empty rules.
    Hi, I have two questions, but first, the code: ... %% start: items items: | items item ; item: ITEM COMMAND ACTION ; %% ... Now this code i've pulled from the oriley lex & yacc book, after studying the text for a while i still dont understand recursion and empty right hand sides properly. 1) What is the behaviour of an empty rule? wouldnt it _ALLWAYS_ match the token stream because yacc would not bother checking the other rules if there is a empty rule ( the logic behind this idea is that if a rule is empty, yacc will not bother checking the stack to reduce, so it will return true no matter what the state and variables on the stack are. ) 2) I'm not understanding how recursion works with yacc. If i had the input stream ITEM COMMAND ACTION, when 'items' rule is evalulated, would'nt it get stuck in a infite loop because it is self-referencing? example of this concept: items -> evaluate first rule, first argument is items, evalulate that, and were back at items again, in a infite loop. How does yacc ever reach item when it gets stuck in a infite loop before it can be evaluated? Thanks in advance.
  • 4. RAW SOCKETS
    Querr crear un cliente y un servidor que se mandaran mensajes mediante sockets en modo raw para aprender sobre el tema. He estado buscando en internet en muchos sitios, pero no he podido averiguar claramente lo que busco. Si alguien me puede pegar un cigo de ejemplo o explicarme los pasos fundamentales, lo agradecer. Un saludo.

backspace and delete key mappings

Postby dmarkh@cfl.rr.com » Sun, 02 Apr 2006 00:09:40 GMT

I have read much on the subject of these 2 keys. Yet I have not been
able to do what I need to do. I need the backspace key to generate
0x08(^H)  and the delete key to generate 0x7f(del) during the execution
of a single  application. On all my linux boxes the backspace generates
0x7f(^?) and the del key generates  ^[[3~. I need to be able to change
that before I execute my program then change it back when my
application is done.  stty does NOT do the job nor does my application
use termdef. I have found a little expect script that does do what I
need. I execute "script program" and the keys come out like I want.

#!/usr/bin/expect

eval spawn -noecho $argv

interact {
 \177        {send "\010"}
 "\033\[3~"  {send "\177"}

However I am really looking for basic Linux commands that can be
executed from the bash shell that will do the same thing or a method of
making my application do it from within its self.

Thanks and regards
Mark


Re: backspace and delete key mappings

Postby Michael Paoli » Sun, 02 Apr 2006 09:01:44 GMT



Ah, ... entire "religious wars" can be started over what those keys
"should" generate, and what the UNIX erase, kill, and interrupt
characters should be.  Fortunately these can be changed at system-wide
default levels (at least for the most part), or per user/session, or
even within application(s).

You do mention LINUX, but you didn't mention what architecture and
distribution/version.  Some of this can vary significantly depending
on hardware.  E.g. on PA-RISC, x86 ("AT", "PS/2", or "USB"), SPARC,
etc. hardware, the "answers" may be rather significantly different.

You also don't mention if this is under X11, or not, and if under X11,
if any particular terminal emulation (e.g. xterm(1)) is being used.

I'll provide some hopefully useful hints/pointers.  These may not
cover 100% of what you're after, but hopefully provide at least useful
starting points and information on areas to investigate further.

First there's the console keyboard itself.  For typical x86 hardware
under LINUX (peeking at my Debian GNU/Linux 3.1 system - note that I
also don't strictly adhere to Debian Keyboard Policy[1]), here's at
least part of what I have in my /etc/init.d/local-keymap.sh:
        echo '

            keymaps 0-2,4-6,8-9,12

            #make the Backspace key generate BackSpace
            keycode 14 = BackSpace

            #make control-shift-/ i.e. control-? generate Delete
            shift control keycode 53 = Delete

            #make the Delete key generate Delete
            keycode 111 = Delete

        ' |
        /bin/loadkeys

Then there are matters such as X11.  My ~/.Xdefaults includes, at
least in part:
XTerm*ttyModes: erase ^H
*VT100.Translations: #override ~Meta <Key>Home: string("\033OH")\n\
                               <Key>End: string("\033OF")

Footnotes/references:
1.  http://www.**--****.com/ #s9.8
stty(1)
loadkeys(1)
dumpkeys(1)
showkey(1)  http://www.**--****.com/ 
xmodmap(1)
xkeycaps(1)
xterm(1)
xev(1)
apropos keyboard | fgrep -v '(3'
LSB:  http://www.**--****.com/ 


Re: backspace and delete key mappings

Postby Jordan Abel » Sun, 02 Apr 2006 09:49:36 GMT



Why do you need bs=^H del=^? - that seems like a poor assumption to make 
on the part of your application. what application is this?

Re: backspace and delete key mappings

Postby dmarkh@cfl.rr.com » Sun, 02 Apr 2006 17:54:07 GMT

Thanks. These are generally SuSE-9 and 10 boxes. X86 and X86-64. As I
said I have read much on this subject and have read about all these
things. The first method is global so I can't use that. The Xdefaults
method won't work because the program is "mostly" being executed from a
normal linux console without X. stty just does not do the job. "stty
erase "^h" doesn't change  what the backspace key generates anymore and
does not help with the del key.

I thought I could just create a termcap or terminfo entry for a
"custom" terminal type. Then just setterm -term custom. This does not
seem to work either. It almost seems like the termcap and terminfo
stuff is just there for "looks" and actually does nothing these days.

You mention "from within applications"???

Thanks
Mark


Re: backspace and delete key mappings

Postby dmarkh@cfl.rr.com » Sun, 02 Apr 2006 18:02:59 GMT

The application is an emulation of a leagacy computer that had an rs232
port for it's console usually with a dumb terminal connected. Every
dumb terminal ever connected to it sent ^h for backspace and ^? for
delete. Perhaps it was a poor assumption, on the part of the developers
of that platform (of which I played a very small part), that there
could ever be such a fuss over these 2 keys in the future.


Re: backspace and delete key mappings

Postby dmarkh@cfl.rr.com » Sun, 02 Apr 2006 19:27:33 GMT

I forgot to mention that when I do run the app under X and kde's
konsole,  and change the terminal type  to konsoles' internal vt420pc
emulation all is fine and the 2 keys are what I need them 2 be. I
wonder how konsole is doing it?

Mark


Re: backspace and delete key mappings

Postby dmarkh@cfl.rr.com » Sat, 08 Apr 2006 20:04:28 GMT

Surely this must be possible. Can no one help me?

Thanks
Mark


Re: backspace and delete key mappings

Postby Chuck Dillon » Tue, 11 Apr 2006 23:34:36 GMT




If you do... (stty erase ^h;yourapp) your app should see the affect. 
Is this not working?

You need to find separate solutions for the console case versus the X 
case.  Stty should provide a solution to the console case.  X resource 
settings and stty should enable you to deal with the X case.

-- ced



-- 
Chuck Dillon
Senior Software Engineer
NimbleGen Systems Inc.

Re: backspace and delete key mappings

Postby Michael Paoli » Wed, 12 Apr 2006 18:41:56 GMT



Use the source, Luke.  Seriously, you're talking about Open Source
software.  Read/research the source code and/or applicable
documentation as necessary.  There are answers there to be found.
Surely if X11 clients and showkey(1) can map keys as you desire and/or
grab key codes before they're translated into characters, it certainly
can be done.  The xkeycaps(1) man page also covers a fair bit of
information about ... "S.u.S.E. ship their systems with broken
keyboard settings by default" ... but perhaps that portion of the
xkeycaps(1) man page isn't included in the SuSE distribution.

And other semi-related random tidbit, I recently also added this to my
~/.Xdefaults file:
*backarrowKeyIsErase: false

Also, learn to include at least minimal relevant quoting for context,
otherwise in many cases someone will see your posting and have no idea
what you're talking about, e.g. your:


provides essentially no relevant context.
See:
 http://www.**--****.com/ 
etc.

references:






strace(1)
gdb(1)
etc.


Similar Threads:

1.Backspace and Delete key mappings

I have read much on the subject of these 2 keys. Yet I have not been
able to do what I need to do. I need the backspace key to generate
0x08(^H)  and the delete key to generate 0x7f(del) during the execution
of a single  application. On all my linux boxes the backspace generates
0x7f(^?) and the del key generates  ^[[3~. I need to be able to change
that before I execute my program then change it back when my
application is done.  stty does NOT do the job nor does my application
use termdef. I have found a little expect script that does do what I
need. I execute "script program" and the keys come out like I want.

#!/usr/bin/expect

eval spawn -noecho $argv

interact {
 \177        {send "\010"}
 "\033\[3~"  {send "\177"}

However I am really looking for basic Linux commands that can be
executed from the bash shell that will do the same thing or a method of
making my application do it from within its self.

Thanks and regards
Mark

2.backspace and delete keys using SSH

I'm having an annoying problem using F-Secure SSH on an AIX 4.3.3
machine.
When logged in via SSH the backspace key doesn't erase the character
shown on screen, it just backspaces over the top, even though AIX
recognises that the character HAS been deleted.  (NB this all works
fine via telnet.)

It doesn't seem to make any difference whether I set the emulator so
that Backspace sends Delete or vice versa, and nothing I have tried
using "stty erase" seems to help either!

I think this may to do with the SSH client rather than AIX tbh, but
does anyone have any idea how to fix it?

Many thanks

David

3.(Somewhat OT) How to fix backspace/delete key in OS/X (Mac)

Yes, this is OT, but it is also a FAQ here.  People having problems with
their backspace key(s).

Anyway, recently started using OS/X on a MacBook.  Use ssh from 'Terminal' to
connect to shell account.  When I hit "delete", it generates: [3~
Now, note that I am well aware of solutions involving "stty erase ...",
but that's not optimal.  The right way to fix this sort of thing is to
fix what character the key sends, not to kludge the remote system to
accept whatever the key currently sends.

Note also that the key generates the right code (127) when hit locally,
but for some reason is translated when sent to ssh.

Has anyone else solved this problem?

4.(Sorta back on topic: 'screen') How to fix backspace/delete key in OS/X (Mac)

In article < XXXX@XXXXX.COM >,
Bill Marcum  < XXXX@XXXXX.COM > wrote:
>On Wed, 15 Aug 2007 06:45:54 +0000 (UTC), Kenny McCormack 
>  < XXXX@XXXXX.COM > wrote:
>>
>>
>> Yes, this is OT, but it is also a FAQ here.  People having problems with
>> their backspace key(s).
>>
>> Anyway, recently started using OS/X on a MacBook.  Use ssh from 'Terminal' to
>> connect to shell account.  When I hit "delete", it generates: [3~
>> Now, note that I am well aware of solutions involving "stty erase ...",
>> but that's not optimal.  The right way to fix this sort of thing is to
>> fix what character the key sends, not to kludge the remote system to
>> accept whatever the key currently sends.
>>
>> Note also that the key generates the right code (127) when hit locally,
>> but for some reason is translated when sent to ssh.
>>
>> Has anyone else solved this problem?
>>
>Does the OSX terminal offer any choice as to what terminal it emulates?

It emulates xterm-color.  This is what I get if I do: echo $TERM
locally, and it is also what I get on the remote end.

Aha!  I just discovered something.  The problem is 'screen'.  The
problem only occurs when I am in 'screen' on the remote machine (which is
all the time...).  If I don't go into 'screen', then the key works
correctly.  So, I think 'screen' must be doing some kind of mapping.

How to fix *that*???

Note: I've used 'screen' for years now (consider it indispensable), but I:
1) Have never used a lot of its arcane features.
2) Don't understand about 2/3 of the man page.

5.'/' become backspace and backspace key insert '~'

I ssh to a solaris 10 computer from a FC6 computer.
The keyboard behave properly when login as root:

root# stty
speed 38400 baud; -parity
rows = 23; columns = 80; ypixels = 0; xpixels = 0;
eol =  eol2 =  swtch < ;
brkint -inpck -istrip icrnl -ixon onlcr tab3
echo echoe echok echoctl echoke iexten

The keyboard behave improperly when login as non-root:
The '/' key acts as the backspace key.
The backspace key insert '~'.
-bash-3.00$ stty
speed 38400 baud; -parity
rows = 23; columns = 84; ypixels = 0; xpixels = 0;
erase = /; eol = ; eol2 = ; swtch < ;
brkint -inpck -istrip icrnl -ixon imaxbel onlcr tab3
echo echoe echok echoctl echoke iexten

$ bash -version
GNU bash, version 3.00.16(1)-release (sparc-sun-solaris2.10)
Copyright (C) 2004 Free Software Foundation, Inc.

Please help to fix it.
Thanks.

6. Backspace Delete in Linux

7. Backspace and Delete in vi.

8. Delete/backspace on command line



Return to unix

 

Who is online

Users browsing this forum: No registered users and 22 guest