sciTe editor IRB window getting double characters

S

soxinbox

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.
 
S

soxinbox

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.
 
D

David Boyd

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=3Dcmd /c ruby $(FileNameExt) < con: > con:
=09command.go.subsystem.*.rb=3D1
=09command.go.*.rbw=3Drubyw $(FileNameExt)
=09command.go.subsystem.*.rbw=3D1
command.compile.*.rb=3Dcmd /c ruby -d -r debug $(FileNameExt) < con: > =
con:
=09command.compile.subsystem.*.rb=3D1
=09command.compile.*.rbw=3Drubyw -d -r debug $(FileNameExt)
=09command.compile.subsystem.*.rbw=3D1
command.build.*.rb=3Dcmd /c ruby myscript.rb $(FileNameExt) < con: > c=
on:
=09command.build.subsystem.*.rb=3D1
)

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 =3D gets=20
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=20
output is shown then.
=3D> You have to insert '$stdout.flush' after each 'puts' line to get=20
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=
=20
(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.
=20
c) Changing the 'go' command to :
command.go.*.rb=3Dcmd /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=20
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 pro=
mpt
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=3D1
instead of:
command.subsystem.3.*.rb=3D1
(*rbw too)

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

Another try, keeping subsystem with '0' and setting command.quiet.3.*.rb=3D=
1=20
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=3DDebug
command.4.*.rb=3Druby -d -r debug $(FileNameExt)
command.subsystem.4.*.rb=3D2
command.name.4.*.rbw=3DDebug
command.4.*.rbw=3D ruby -d -r debug $(FileNameExt)
command.subsystem.4.*.rbw=3D2

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=
=20
identically for debugging.

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

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

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

Neil Hodgson

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
 
D

David Boyd

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=3DRuby (.rb,.rbw)|*.rb;*.rbw|

lexer.*.rb;*.rbw=3Druby

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

keywordclass.ruby=3D__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)=3D$(keywordclass.ruby)

statement.indent.*.rb=3D
statement.end*.rb=3D
statement.lookback.*.rb=3D1
block.start.*.rb=3D10

comment.block.ruby=3D#~

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

if PLAT_WIN
command.go.*.rb=3Druby $(FileNameExt)
command.go.subsystem.*.rb=3D2
command.go.*.rbw=3Drubyw $(FileNameExt)
command.go.subsystem.*.rbw=3D1
command.help.*.rb=3D$(CurrentWord)!c:\apps\ruby\ProgrammingRuby.chm
command.help.subsystem.*.rb=3D4
command.help.*.rbw=3D$(CurrentWord)!c:\apps\ruby\ProgrammingRuby.chm
command.help.subsystem.*.rbw=3D4

command.name.1.*.rb=3DCheck Syntax
command.1.*.rb=3Druby -cw $(FileNameExt)
command.name.1.*.rbw=3DCheck Syntax
command.1.*.rbw=3Drubyw -cw $(FileNameExt)

command.name.2.*.rb=3DCode Profiler
command.2.*.rb=3Druby -r profile $(FileNameExt)
command.name.2.*.rbw=3DCode Profiler
command.2.*.rbw=3Drubyw -r profile $(FileNameExt)

command.name.3.*.rb=3DRun irb
command.3.*.rb=3Dirb.bat
command.subsystem.3.*.rb=3D2
command.name.3.*.rbw=3DRun irb
command.3.*.rbw=3Dirb.bat
command.subsystem.3.*.rbw=3D2

command.name.4.*.rb=3DDebug
command.4.*.rb=3Druby -d -r debug $(FileNameExt)
command.subsystem.4.*.rb=3D2
command.name.4.*.rbw=3DDebug
command.4.*.rbw=3D ruby -d -r debug $(FileNameExt)
command.subsystem.4.*.rbw=3D2

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

command.name.1.*.rb=3DCheck Syntax
command.1.*.rb=3Druby -cw $(FileNameExt)

command.name.2.*.rb=3DCode Profiler
command.2.*.rb=3Druby -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
 
C

Curt Hibbs

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.
 
N

Neil Hodgson

David said:
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
 
D

David Boyd

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
 
N

Neil Hodgson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top