Question about character input 
Author Message
 Question about character input

I am working on an text-based application (no GUI involved) and am
wondering if there is a way to get character input back from the user but
replacing each displayed character as it is typed with a '*' - e.g. to hide
a password being typed in.

I figured I could just do a getc, then putc the meta sequence for the
Delete character but it isn't working at all..

Any ideas? I'd love some help and would greatly appreciate a quick example
that shows that this is possible.

Thanks in advance!
Andy

______________________________________________________________________
Posted Via Uncensored-News.Com - Still Only $9.95 - http://www.*-*-*.com/
      <><><><><><><>   The Worlds Uncensored News Source   <><><><><><><><>



Wed, 16 Mar 2005 02:02:44 GMT  
 Question about character input

Quote:

> I am working on an text-based application (no GUI involved) and am
> wondering if there is a way to get character input back from the user but
> replacing each displayed character as it is typed with a '*' - e.g. to hide
> a password being typed in.

> I figured I could just do a getc, then putc the meta sequence for the
> Delete character but it isn't working at all..

> Any ideas? I'd love some help and would greatly appreciate a quick example
> that shows that this is possible.

Hello,

on linux (and other unices) you will need to know terminal escape codes
or use some high level library such as
  termcap or terminfo (it will tell you escape codes for particular terminal)
  curses or ncurses (it will allow very simple windowing in terminal)
  jttui (high level ruby bindings to ncurses library)

jttui password dialog example (just a quick hack):
---------------------------------------
require 'jttui/jttui'
require 'jttui/jttuistd'

JTTui.run do |root|
   d=JTTDialog.new(root, 'Dialog Window', 0, 0, 30, 10,
                    'Example 8 - password dialog')
   d.align=JTTWindow::ALIGN_CENTER
   l=JTTWLabel.new(d, 'Label 1', 0, 0, 40, 1, 'Enter password:')
   p=JTTWEditpass.new(d, 'PWEdit 1', 2, 2, 20, 1,'', true)
   b=JTTWButton.new(d, 'Quit button', 2, 4, 6, 1, '_Quit') {
     JTTWMessagebox.new("You have typed '#{p.editor.text}'", 0, 0, 'Ok').execute
     JTTui.addmessage nil, :close
   }
   [p,b].each{|x| d.addtabstop x}
   d.defaultbutton=b
end
---------------------------------------

JTTui screenshots and download at
http://klokan.sh.cvut.cz/~jtra/

unstable version of Debian GNU/Linux contains JTTui as package
libjttui-ruby

Jakub Travnik,



Thu, 17 Mar 2005 02:45:40 GMT  
 Question about character input

Jakub, I have always considered curses to be a console-oriented windowing
system, can this be used through a socket connection, to create a window
remotely on a terminal connected via telnet to the ruby application (server) ?

Thanks!
Andy


Quote:

> > I am working on an text-based application (no GUI involved) and am
> > wondering if there is a way to get character input back from the user but
> > replacing each displayed character as it is typed with a '*' - e.g. to
> > hide a password being typed in.

> > I figured I could just do a getc, then putc the meta sequence for the
> > Delete character but it isn't working at all..

> > Any ideas? I'd love some help and would greatly appreciate a quick
> > example that shows that this is possible.

> Hello,

> on linux (and other unices) you will need to know terminal escape codes
> or use some high level library such as
>   termcap or terminfo (it will tell you escape codes for particular
> terminal) curses or ncurses (it will allow very simple windowing in
> terminal) jttui (high level ruby bindings to ncurses library)

> jttui password dialog example (just a quick hack):
> ---------------------------------------
> require 'jttui/jttui'
> require 'jttui/jttuistd'

> JTTui.run do |root|
>    d=JTTDialog.new(root, 'Dialog Window', 0, 0, 30, 10,
>                     'Example 8 - password dialog')
>    d.align=JTTWindow::ALIGN_CENTER
>    l=JTTWLabel.new(d, 'Label 1', 0, 0, 40, 1, 'Enter password:')
>    p=JTTWEditpass.new(d, 'PWEdit 1', 2, 2, 20, 1,'', true)
>    b=JTTWButton.new(d, 'Quit button', 2, 4, 6, 1, '_Quit') {
>      JTTWMessagebox.new("You have typed '#{p.editor.text}'", 0, 0,
> 'Ok').execute JTTui.addmessage nil, :close
>    }
>    [p,b].each{|x| d.addtabstop x}
>    d.defaultbutton=b
> end
> ---------------------------------------

> JTTui screenshots and download at
> http://klokan.sh.cvut.cz/~jtra/

> unstable version of Debian GNU/Linux contains JTTui as package
> libjttui-ruby

> Jakub Travnik,




Fri, 18 Mar 2005 06:19:20 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Question regarding character input

2. Character input question

3. TextEdit - How to control character input

4. inputting diamond character

5. animated characters, speech input/output in PB/DLL and PB/CC

6. Can Clarion handle Chinese character Input and output ?

7. animated characters, speech input/output in Clarion

8. Bypass coding when chinese character input?

9. how to input chinese character in clipper

10. Single character input

11. Cannot input Thai character in TkEntry

12. Can't input more than three characters ?

 

 
Powered by phpBB® Forum Software