sciTe editor IRB window getting double characters

Has any one had a problem with the latest release of Ruby and the included
sciTE editor. When I open the irb screen, every character I type shows up
twice, except the backspace which only wipes one character. If I type a=b,
the screen shows aa==bb. Do I have something set up wrong? The rest of the
sciTE windows work fine, its just the built in irb.

Are you on Windows? I've had anamolies with Ruby/irb with another editor
(JEdit), no diagnosis or fix, and had to give up and go to a separate window
for command-line irb.

"soxinbox" <faker@yahoo.com> wrote in message
news:jdbke.15939$tM3.1564@twister.nyroc.rr.com...

···

Has any one had a problem with the latest release of Ruby and the included
sciTE editor. When I open the irb screen, every character I type shows up
twice, except the backspace which only wipes one character. If I type a=b,
the screen shows aa==bb. Do I have something set up wrong? The rest of the
sciTE windows work fine, its just the built in irb.

Here's some solutions for scite configuration mistakes from another list:
---------->
Hello,

today I installed Ruby per 1.8.2-14 final and tried to adapt scite
like it was before (previous version installed per
1.8.0-10), according to the tips documented on:

(Old ruby.properties file contained:

  if PLAT_WIN
    command.go.*.rb=cmd /c ruby $(FileNameExt) < con: > con:
  command.go.subsystem.*.rb=1
  command.go.*.rbw=rubyw $(FileNameExt)
  command.go.subsystem.*.rbw=1
    command.compile.*.rb=cmd /c ruby -d -r debug $(FileNameExt) < con: > con:
  command.compile.subsystem.*.rb=1
  command.compile.*.rbw=rubyw -d -r debug $(FileNameExt)
  command.compile.subsystem.*.rbw=1
    command.build.*.rb=cmd /c ruby myscript.rb $(FileNameExt) < con: > con:
  command.build.subsystem.*.rb=1
)

The advantage of the above setting was: stdin/out in a DOS-Box, error
output in output pane of SciTE.

1.)

As there were many enhancements in SciTE, I first tried to use it
out-of-the-box with the following script:

···

----------------
puts "Hello"
x = gets
puts "Got: " + x

gets # keep DOS box open until <return>
----------------

it doesn't work successfully:

A DOS-Box is opened but does not write any output or take any input.

I tried:

a) Clicking into the output pane (which gains focus then).
Now you can type in some string, enter return two times and all
output is shown then.
=> You have to insert '$stdout.flush' after each 'puts' line to get
output shown immediately in the output pane (but the DOS box is a dead
window only).

Also:
b) Changing the subsystem to '0' makes the script work in the output pane
(no DOS-Box is opened), but output is again shown only after the last 'gets',
as it is buffered.
You have to insert '$stdout.flush' here too after each 'puts' line.
Also the cursor stays in the code pane and focus must be changed by
explicitly clicking into the output pane.
    
c) Changing the 'go' command to :
command.go.*.rb=cmd /c ruby $(FileNameExt) < con: > con:
which worked pretty fine in 1.8.0-10, but doesn't work at all

d)
SOLUTION: is to simply change the subsystem to '2'. An extra Window is
opened and all works as expected.

BUT: When having errors (you can e.g. force a syntax error), error
output is not sent to output pane, like it was in
my documented setting in the 1.8.0-10
installation.

2.) IRB - new command in SciTE now

Starting irb with the command setup as in ruby.properties opens the irb prompt
in the scite output pane, but every input is echoed double.
This way working is very annoying.

Seems that the subsystem command is wrong:
        command.3.subsystem.*.rb=1
instead of:
        command.subsystem.3.*.rb=1
(*rbw too)

Then setting subsystem to '2' ...
    command.subsystem.3.*.rb=2
... opens IRB in own window and all is perfect.

Another try, keeping subsystem with '0' and setting command.quiet.3.*.rb=1
starts IRB in output pane, but NO output is displayed at all.
So starting it in separate window is the only way.

3.) Starting Debugger - unfortunately missing in the properties:

command.name.4.*.rb=Debug
command.4.*.rb=ruby -d -r debug $(FileNameExt)
command.subsystem.4.*.rb=2
command.name.4.*.rbw=Debug
command.4.*.rbw= ruby -d -r debug $(FileNameExt)
command.subsystem.4.*.rbw=2

Starts the script in the debugger in a separate window. Works fine.
The command for *.rbw is exactly the same as for *.rb, as i/o has to work
identically for debugging.

4.) Help: The path is not adapted on installation.
My installation dir is: D:\MyData\Ruby

But the setting after installation was:
command.help.*.rb=$(CurrentWord)!C:\Ruby\ProgrammingRuby.chm
command.help.subsystem.*.rb=4
command.help.*.rbw=$(CurrentWord)!C:\Ruby\ProgrammingRuby.chm
command.help.subsystem.*.rbw=4

(Yes, I know, this problem should be reported separately)
---------

On 5/22/05, soxinbox <faker@yahoo.com> wrote:

Has any one had a problem with the latest release of Ruby and the included
sciTE editor. When I open the irb screen, every character I type shows up
twice, except the backspace which only wipes one character. If I type a=b,
the screen shows aa==bb. Do I have something set up wrong? The rest of the
sciTE windows work fine, its just the built in irb.

Yes, XP, I should have included that in the original post.
I couldn't get Debugger going in Freeride, couldn't get copy paste working
in freeRide's IRB, so I dropped back to sciTe and hit this bug. I just want
a decent environment to develop Ruby code on a windows box. I am very
frustrated
Sad to here that Jedit has problems also, guess that's another one to cross
off my list of potential solutions.

"itsme213" <itsme213@hotmail.com> wrote in message
news:1Ovke.121739$h6.95724@tornado.texas.rr.com...

···

Are you on Windows? I've had anamolies with Ruby/irb with another editor
(JEdit), no diagnosis or fix, and had to give up and go to a separate
window
for command-line irb.

"soxinbox" <faker@yahoo.com> wrote in message
news:jdbke.15939$tM3.1564@twister.nyroc.rr.com...

Has any one had a problem with the latest release of Ruby and the
included
sciTE editor. When I open the irb screen, every character I type shows up
twice, except the backspace which only wipes one character. If I type
a=b,
the screen shows aa==bb. Do I have something set up wrong? The rest of
the
sciTE windows work fine, its just the built in irb.

David Boyd:

a) Clicking into the output pane (which gains focus then).
Now you can type in some string, enter return two times and all output is shown then.

    The way that SciTE's output pane works is that it has two file handles open: one writing to the subprocess and one reading from it. Characters typed are added to the buffer and then written to the write pipe.

    Data from the read pipe is added to the display when it is received. Programs often buffer output differently when writing to a pipe (maximum buffering) and writing to a console (line buffering) as a console implies a human interacting with the program who needs to see prompts. SciTE has no way to stop the subprocess buffering data (there is no equivalent of a pseudo-terminal on Windows) except for invocation options. Some programs such as Python have flags (-u) to turn off buffering. For other languages, there is often a call like C's setvbuf that can be used to change buffering on a stream.

You have to insert '$stdout.flush' here too after each 'puts' line.
Also the cursor stays in the code pane and focus must be changed by
explicitly clicking into the output pane.

    SciTE can not see that the subprocess wants to read input. There could be an option to switch focus when running particular applications but for many commands like build it is better for the focus to stay in the editor pane. A focus switching option also needs to handle whether to return focus to the edit pane after command completion.

SOLUTION: is to simply change the subsystem to '2'. An extra Window is opened and all works as expected.

    Subsystem 2 is ShellExecute which has its own set of idiosyncrasies.

Starting irb with the command setup as in ruby.properties opens the irb prompt
in the scite output pane, but every input is echoed double.

    This means that irb is echoing input. The ordering of the events in SciTE make it difficult to change from the SciTE end. SciTE is performing the character write upon receiving the SCN_CHARADDED notification where the character has already been added to the buffer. The reason it uses SCN_CHARADDED is because it is sent for cooked characters after processing commands.

    It may be possible to switch to reading key events and sending through to the subprocess while running a command but this would be a lot of work.

    The biggest problem with SciTE's output pane for many is that it interprets command characters. For example, typing ab[Backspace]c sends the three characters abc through to the subprocess although the pane shows ac. It has been proposed that there could be a line buffering option where SciTE would build up a whole line and only send it when Enter is pressed to handle this.

    SciTE's output pane is not clever: the original goal in making it interactive was to be able to respond to CVS prompts. Possible changes will often make other scenarios fail so should be implemented as options. As the output pane is currently sufficient for my needs, I won't be working on improvements.

    Neil

Thanks, I'll add this stuff to the One-Click installer's version of scite in the next release.

Curt

PS
   You might also want to try the built-in IRB in fxri (you'll find it in the start menu.

David Boyd wrote:

···

Here's some solutions for scite configuration mistakes from another list:
---------->
Hello,

today I installed Ruby per 1.8.2-14 final and tried to adapt scite
like it was before (previous version installed per
1.8.0-10), according to the tips documented on:
http://www.rubygarden.org/ruby?SciTEAndStdinStdout

(Old ruby.properties file contained:

  if PLAT_WIN
    command.go.*.rb=cmd /c ruby $(FileNameExt) < con: > con:
  command.go.subsystem.*.rb=1
  command.go.*.rbw=rubyw $(FileNameExt)
  command.go.subsystem.*.rbw=1
    command.compile.*.rb=cmd /c ruby -d -r debug $(FileNameExt) < con: > con:
  command.compile.subsystem.*.rb=1
  command.compile.*.rbw=rubyw -d -r debug $(FileNameExt)
  command.compile.subsystem.*.rbw=1
    command.build.*.rb=cmd /c ruby myscript.rb $(FileNameExt) < con: > con:
  command.build.subsystem.*.rb=1
)

The advantage of the above setting was: stdin/out in a DOS-Box, error
output in output pane of SciTE.

1.)

As there were many enhancements in SciTE, I first tried to use it
out-of-the-box with the following script:
----------------
puts "Hello"
x = gets puts "Got: " + x

gets # keep DOS box open until <return>
----------------

it doesn't work successfully:

A DOS-Box is opened but does not write any output or take any input.

I tried:

a) Clicking into the output pane (which gains focus then).
Now you can type in some string, enter return two times and all output is shown then.
=> You have to insert '$stdout.flush' after each 'puts' line to get output shown immediately in the output pane (but the DOS box is a dead
window only).

Also:
b) Changing the subsystem to '0' makes the script work in the output pane (no DOS-Box is opened), but output is again shown only after the last 'gets',
as it is buffered.
You have to insert '$stdout.flush' here too after each 'puts' line.
Also the cursor stays in the code pane and focus must be changed by
explicitly clicking into the output pane.
    c) Changing the 'go' command to :
command.go.*.rb=cmd /c ruby $(FileNameExt) < con: > con:
which worked pretty fine in 1.8.0-10, but doesn't work at all

d)
SOLUTION: is to simply change the subsystem to '2'. An extra Window is opened and all works as expected.

BUT: When having errors (you can e.g. force a syntax error), error
output is not sent to output pane, like it was in
my documented setting in the 1.8.0-10
installation.

2.) IRB - new command in SciTE now

Starting irb with the command setup as in ruby.properties opens the irb prompt
in the scite output pane, but every input is echoed double.
This way working is very annoying.

Seems that the subsystem command is wrong:
        command.3.subsystem.*.rb=1
instead of:
        command.subsystem.3.*.rb=1
(*rbw too)

Then setting subsystem to '2' ...
    command.subsystem.3.*.rb=2
... opens IRB in own window and all is perfect.

Another try, keeping subsystem with '0' and setting command.quiet.3.*.rb=1 starts IRB in output pane, but NO output is displayed at all.
So starting it in separate window is the only way.

3.) Starting Debugger - unfortunately missing in the properties:

command.name.4.*.rb=Debug
command.4.*.rb=ruby -d -r debug $(FileNameExt)
command.subsystem.4.*.rb=2
command.name.4.*.rbw=Debug
command.4.*.rbw= ruby -d -r debug $(FileNameExt)
command.subsystem.4.*.rbw=2

Starts the script in the debugger in a separate window. Works fine.
The command for *.rbw is exactly the same as for *.rb, as i/o has to work identically for debugging.

4.) Help: The path is not adapted on installation. My installation dir is: D:\MyData\Ruby

But the setting after installation was:
command.help.*.rb=$(CurrentWord)!C:\Ruby\ProgrammingRuby.chm
command.help.subsystem.*.rb=4
command.help.*.rbw=$(CurrentWord)!C:\Ruby\ProgrammingRuby.chm
command.help.subsystem.*.rbw=4

(Yes, I know, this problem should be reported separately)
---------

On 5/22/05, soxinbox <faker@yahoo.com> wrote:

Has any one had a problem with the latest release of Ruby and the included
sciTE editor. When I open the irb screen, every character I type shows up
twice, except the backspace which only wipes one character. If I type a=b,
the screen shows aa==bb. Do I have something set up wrong? The rest of the
sciTE windows work fine, its just the built in irb.

Neil,

Thanks for explanations. I found the changes suggested in the
bug-post fixed SciTE's Ruby related behavior enough for me to try to
continue to use it. As you say, I may find other problems now, but
I'll complain about those later. I just want a usable editor that
does a little bit more than Notepad.

Will any of those changes make it through the bug process and to the
current distribution of the ruby.properties file? Here they are for
those that don't want to wade through the bug-fix post I copied
(thanks to the original poster) and provided previously:

________________copy below here

# Define SciTE settings for Ruby files.

filter.ruby=Ruby (.rb,.rbw)|*.rb;*.rbw|

lexer.*.rb;*.rbw=ruby

file.patterns.rb=*.rb;*.rbw

keywordclass.ruby=__FILE__ and def end in or self unless __LINE__ begin \
defined? ensure module redo super until BEGIN break do false next rescue \
then when END case else for nil retry true while alias class elsif if \
not return undef yield
keywords.$(file.patterns.rb)=$(keywordclass.ruby)

statement.indent.*.rb=
statement.end*.rb=
statement.lookback.*.rb=1
block.start.*.rb=10

comment.block.ruby=#~

# ruby styles
# White space
style.ruby.0=fore:#808080
# Comment
style.ruby.1=fore:#007F00,$(font.comment)
# Number
style.ruby.2=fore:#007F7F
# String
style.ruby.3=fore:#7F007F,$(font.monospace)
# Single quoted string
style.ruby.4=fore:#7F007F,$(font.monospace)
# Keyword
style.ruby.5=fore:#00007F,bold
# Triple quotes
# style.ruby.6=fore:#7F0000
# Triple double quotes
style.ruby.7=fore:#7F0000
# Class name definition
style.ruby.8=fore:#0000FF,bold
# Function or method name definition
style.ruby.9=fore:#007F7F,bold
# Operators
style.ruby.10=bold
# Identifiers
style.ruby.11=fore:#7F7F7F
# Comment-blocks
style.ruby.12=fore:#7F7F7F
# End of line where string is not closed
style.ruby.13=fore:#000000,$(font.monospace),back:#E0C0E0,eolfilled
# Matched Operators
style.ruby.34=fore:#0000FF,bold
style.ruby.35=fore:#FF0000,bold
# Braces are only matched in operator style
braces.ruby.style=10

if PLAT_WIN
command.go.*.rb=ruby $(FileNameExt)
command.go.subsystem.*.rb=2
command.go.*.rbw=rubyw $(FileNameExt)
command.go.subsystem.*.rbw=1
command.help.*.rb=$(CurrentWord)!c:\apps\ruby\ProgrammingRuby.chm
command.help.subsystem.*.rb=4
command.help.*.rbw=$(CurrentWord)!c:\apps\ruby\ProgrammingRuby.chm
command.help.subsystem.*.rbw=4

command.name.1.*.rb=Check Syntax
command.1.*.rb=ruby -cw $(FileNameExt)
command.name.1.*.rbw=Check Syntax
command.1.*.rbw=rubyw -cw $(FileNameExt)

command.name.2.*.rb=Code Profiler
command.2.*.rb=ruby -r profile $(FileNameExt)
command.name.2.*.rbw=Code Profiler
command.2.*.rbw=rubyw -r profile $(FileNameExt)

command.name.3.*.rb=Run irb
command.3.*.rb=irb.bat
command.subsystem.3.*.rb=2
command.name.3.*.rbw=Run irb
command.3.*.rbw=irb.bat
command.subsystem.3.*.rbw=2

command.name.4.*.rb=Debug
command.4.*.rb=ruby -d -r debug $(FileNameExt)
command.subsystem.4.*.rb=2
command.name.4.*.rbw=Debug
command.4.*.rbw= ruby -d -r debug $(FileNameExt)
command.subsystem.4.*.rbw=2

if PLAT_GTK
command.go.*.rb=ruby $(FileNameExt)

command.name.1.*.rb=Check Syntax
command.1.*.rb=ruby -cw $(FileNameExt)

command.name.2.*.rb=Code Profiler
command.2.*.rb=ruby -r profile $(FileNameExt)

___________copy above here

Note: the path to the help file (c:\apps\ruby\ProgrammingRuby.chm)
should be set to where you installed Ruby.

Dave

David Boyd wrote:

Will any of those changes make it through the bug process and to the
current distribution of the ruby.properties file? Here they are for
those that don't want to wade through the bug-fix post I copied
(thanks to the original poster) and provided previously:

    This could be shortened by using $(file.patterns.rb) where commands are the same for rb and rbw.
    The current CVS contains some indentation settings:

statement.indent.$(file.patterns.rb)=5 def class if do elsif else case
statement.end.$(file.patterns.rb)=5 end

block.start.$(file.patterns.rb)=5 do
block.end.$(file.patterns.rb)=5 end

indent.opening.$(file.patterns.rb)=1
indent.closing.$(file.patterns.rb)=1

    Neil

Neil,

Thanks again. Is there any way to put a variable in the properties
file to point to the Ruby help library? This way, at install time,
the (environmental) variable could be set to point to where the help
file is. (If not, it should probably be set to the default location
for the install. -- Isn't this c:\program files\....?? I don't use
this due to occasional problems with spaces in path names. I wasn't
sure if scite exhibits this common problem or if, for example,
surrounding quotes are needed.)

Thanks also to Curt for fixing the distribution. Any other input from
folks who use Ruby scite would help to make it optimally useful for
everyone on the the Ruby communitiy!

Dave

···

On 5/30/05, Neil Hodgson <nyamatongwe+thunder@gmail.com> wrote:

David Boyd wrote:

> Will any of those changes make it through the bug process and to the
> current distribution of the ruby.properties file? Here they are for
> those that don't want to wade through the bug-fix post I copied
> (thanks to the original poster) and provided previously:

   This could be shortened by using $(file.patterns.rb) where commands
are the same for rb and rbw.
   The current CVS contains some indentation settings:

statement.indent.$(file.patterns.rb)=5 def class if do elsif else case
statement.end.$(file.patterns.rb)=5 end

block.start.$(file.patterns.rb)=5 do
block.end.$(file.patterns.rb)=5 end

indent.opening.$(file.patterns.rb)=1
indent.closing.$(file.patterns.rb)=1

   Neil

David Boyd:

> Thanks again. Is there any way to put a variable in the properties
> file to point to the Ruby help library? This way, at install time,
> the (environmental) variable could be set to point to where the help
> file is.

    There is SciTE documentation at
http://scintilla.sourceforge.net/SciTEDoc.html
    "Environment variables are also available as properties and these are overridden by an explicit setting in one of the properties files."

    The one click installer could do this but standard SciTE does not use an installer and doesn't know where Ruby (or PHP or Rexx) is installed. I think it is much easier to set variables in properties files than to set environment variables on Windows.

> (If not, it should probably be set to the default location
> for the install. -- Isn't this c:\program files\....?? I don't use
> this due to occasional problems with spaces in path names. I wasn't
> sure if scite exhibits this common problem or if, for example,
> surrounding quotes are needed.)

    It depends on how it is used, so for example, if it is passed to a command line program then that program may require paths containing spaces to be quoted.

    Neil