1. Linux: position() bug?

Running the demo file search.ex:

This is a screen capture from a run of the demo file search.ex:

string (* and ? may be used): load_files 
             y  --<<<-- cursor placed here after displaying "match case? (n)" 
match case? (n) 
file-spec (*.*): *.ex n --<<<-------- ? 
 
press q to quitries? (y) --? 
 
                                                                                             
   23 files scanned (*.ex) 
   20 files skipped 
    0 files contained "load_files" (case must match) 
 
search time: 0.0 seconds 
 

This is the code segment form search.ex:

 
 
if alphabetic(orig_string) then 
    puts(SCREEN, "match case? (n)") 
    pos = get_position() 
    position(pos[1], pos[2] - 2)--<<<----- pos[1] should place on the same line as the match case? (n)" prompt, yes? 
    match_case = find('y', gets(KEYB)) 
    puts(SCREEN, '\n') 
-- 
-- 
puts(SCREEN, "scan subdirectories? (y)") 
	    pos = get_position() 
	    position(pos[1], pos[2] - 2)  --<<------- 
	    scan_subdirs = not match("n", gets(KEYB)) 
 

Regards, Kenneth Rhodes

new topic     » topic index » view message » categorize

2. Re: Linux: position() bug?

I haven't got linux to test this but here is some code that can be used ... (btw it works fine in Windows).

 
include std/graphics.e 
constant SCREEN = 1, KEYB = 0 
 
object pos 
    pos = get_position()  
    ? pos 
 
    puts(SCREEN, "match case? (n)")  
    pos = get_position()  
    position(pos[1], pos[2] - 2) 
    gets(KEYB) 
    puts(SCREEN, '\n')  
    ? pos 
new topic     » goto parent     » topic index » view message » categorize

3. Re: Linux: position() bug?

Running Derek's test code:

{1,1} 
match case? (n) 
 
{2,16} 


(program exited with code: 0) Press return to continue

Ubuntu 11.10 gnome-terminal Intel® Core™2 Duo CPU E7400 @ 2.80GHz × 2 os type: 32 bit

new topic     » goto parent     » topic index » view message » categorize

4. Re: Linux: position() bug?

K_D_R said...

Running the demo file search.ex:

This is a screen capture from a run of the demo file search.ex:

string (* and ? may be used): load_files 
             y  --<<<-- cursor placed here after displaying "match case? (n)" 
match case? (n) 
file-spec (*.*): *.ex n --<<<-------- ? 
 
press q to quitries? (y) --? 
 
                                                                                             
   23 files scanned (*.ex) 
   20 files skipped 
    0 files contained "load_files" (case must match) 
 
search time: 0.0 seconds 
 

This is the code segment form search.ex:

 
 
if alphabetic(orig_string) then 
    puts(SCREEN, "match case? (n)") 
    pos = get_position() 
    position(pos[1], pos[2] - 2)--<<<----- pos[1] should place on the same line as the match case? (n)" prompt, yes? 
    match_case = find('y', gets(KEYB)) 
    puts(SCREEN, '\n') 
-- 
-- 
puts(SCREEN, "scan subdirectories? (y)") 
	    pos = get_position() 
	    position(pos[1], pos[2] - 2)  --<<------- 
	    scan_subdirs = not match("n", gets(KEYB)) 
 

Regards, Kenneth Rhodes

Confirmed. It looks like what's happening is that we aren't updating our internal line count, screen_line, in be_w.c when gets(0) is called. As a result, we miss the newline at the end and our line count is off by one for each gets(0) call.

new topic     » goto parent     » topic index » view message » categorize

5. Re: Linux: position() bug?

I hope you guys can fix it.... oh, and there's that irritating cursor positoning problem in Linux at startup. Or is that the tail of the same horse?

kenneth@kenneth-OptiPlex-360:~/euphoria.4.0.3$  
 
kenneth@kenneth-OptiPlex-360:~/euphoria.4.0.3$ ed.ex  --<<<< executing ed.ex without an argument 
 
kenneth@ken$  --<<----- $ marks the prompt, 2 or 3 lines up, and minus 10 columns or so.                                                                                                      
file name:  
 
kenneth@kened.ex                                                                                                 
file name:  

That thing has been around forever. I am not sure that it has ever worked since Rob dropped ncurses.

Your efforts are appreciated. Regards, Kenneth Rhodes

new topic     » goto parent     » topic index » view message » categorize

6. Re: Linux: position() bug?

K_D_R said...

I hope you guys can fix it.... oh, and there's that irritating cursor positoning problem in Linux at startup. Or is that the tail of the same horse?

kenneth@kenneth-OptiPlex-360:~/euphoria.4.0.3$  
 
kenneth@kenneth-OptiPlex-360:~/euphoria.4.0.3$ ed.ex  --<<<< executing ed.ex without an argument 
 
kenneth@ken$  --<<----- $ marks the prompt, 2 or 3 lines up, and minus 10 columns or so.                                                                                                      
file name:  
 
kenneth@kened.ex                                                                                                 
file name:  

That thing has been around forever. I am not sure that it has ever worked since Rob dropped ncurses.

Your efforts are appreciated. Regards, Kenneth Rhodes

Also confirmed. This is a slightly different bug but in the same region of code - the issue here is that we never initialize the position of the screen when we start up by reading it from the terminal, instead we assume it's at 1,1 (the top of the screen).

For now, the following code will work around the issue by manually reading this value and then calling position() to set it (the cursor should not move, but the call to position() will update Euphoria's internal cursor position to match the terminals).

procedure get_real_text_starting_position() 
                sequence sss = "" 
                integer ccc 
                puts(1, 27&"[6n") 
                while 1 do 
                        ccc = get_key() 
                        if ccc = 'R' then 
                                exit 
                        end if 
                        if ccc != -1 then 
                                sss &= ccc 
                        end if 
                end while 
                sss = sss[3..$] 
                sequence aa, bb 
                aa = value(sss[1..find(';', sss)-1]) 
                bb = value(sss[find(';', sss)+1..$]) 
                position(aa[2], bb[2]) 
end procedure 
ifdef LINUX then 
	get_real_text_starting_position() 
end ifdef 

I tested this by putting it in after line 46 of ed.ex (after the include std/text.e line but before the constant TRUE line).

new topic     » goto parent     » topic index » view message » categorize

7. Re: Linux: position() bug?

jimcbrown said...
K_D_R said...

I hope you guys can fix it.... oh, and there's that irritating cursor positoning problem in Linux at startup. Or is that the tail of the same horse?

kenneth@kenneth-OptiPlex-360:~/euphoria.4.0.3$  
 
kenneth@kenneth-OptiPlex-360:~/euphoria.4.0.3$ ed.ex  --<<<< executing ed.ex without an argument 
 
kenneth@ken$  --<<----- $ marks the prompt, 2 or 3 lines up, and minus 10 columns or so.                                                                                                      
file name:  
 
kenneth@kened.ex                                                                                                 
file name:  

That thing has been around forever. I am not sure that it has ever worked since Rob dropped ncurses.

Your efforts are appreciated. Regards, Kenneth Rhodes

Also confirmed. This is a slightly different bug but in the same region of code - the issue here is that we never initialize the position of the screen when we start up by reading it from the terminal, instead we assume it's at 1,1 (the top of the screen).

For now, the following code will work around the issue by manually reading this value and then calling position() to set it (the cursor should not move, but the call to position() will update Euphoria's internal cursor position to match the terminals).

procedure get_real_text_starting_position() 
                sequence sss = "" 
                integer ccc 
                puts(1, 27&"[6n") 
                while 1 do 
                        ccc = get_key() 
                        if ccc = 'R' then 
                                exit 
                        end if 
                        if ccc != -1 then 
                                sss &= ccc 
                        end if 
                end while 
                sss = sss[3..$] 
                sequence aa, bb 
                aa = value(sss[1..find(';', sss)-1]) 
                bb = value(sss[find(';', sss)+1..$]) 
                position(aa[2], bb[2]) 
end procedure 
ifdef LINUX then 
	get_real_text_starting_position() 
end ifdef 

I tested this by putting it in after line 46 of ed.ex (after the include std/text.e line but before the constant TRUE line).

I also tested this in demo/search.ex and it works as well, after I add an include for std/get.e . I call get_real_text_starting_position() as soon as it's defined (between the last include file and the first constant) and also immediately before both calls to get_position().

new topic     » goto parent     » topic index » view message » categorize

8. Re: Linux: position() bug?

EXCELLENT!

Thanks for the fix!

Regards, Kenneth Rhodes

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu