Ticket #259 (closed enhancement: fixed)

Opened 4 years ago

Last modified 9 months ago

Auto-scroll support for NmapOutputViewer (changed from VPaned to HIGVBox)

Reported by: ignotus Owned by: ignotus
Priority: medium Milestone: Umit 1.0beta2
Component: Umit Version: current svn
Keywords: NmapOutputViewer Cc:

Description

Initially I changed the superclass of NmapOutputViewer? to HIGVBox from gtk.VPaned, since I did not see any reason to use adjustable panes. I added support to auto-scroll to NmapOutputViewer? too. The auto-scroll works by default and when the adjustment is down. If the user places the adjustment at any other position the scroll is disabled. However, when the output is changed the adjustment stay on the same place instead jumping to the top (as work before). The patch is attached.

Attachments

NmapOutputViewer.py.diff (3.6 kB) - added by ignotus 4 years ago.
scroll-output.diff (1.0 kB) - added by nopper 4 years ago.
scroll-output-2.diff (1.1 kB) - added by nopper 4 years ago.
This add checks that ignotus21 introduced to avoid scrolling to end if the user is seeing another region of scrooledwindow != en
NmapOutputViewer.py.2.diff (3.4 kB) - added by ignotus 4 years ago.
New version
NmapOutputViewer.py.3.diff (3.9 kB) - added by ignotus 4 years ago.
ticket_259.diff (6.6 kB) - added by gpolo 4 years ago.

Change History

Changed 4 years ago by ignotus

  Changed 4 years ago by luis

it works properly in unix environment (GNU/Linux and Mac OS).

Someone can test it under windows?

Changed 4 years ago by nopper

follow-up: ↓ 3   Changed 4 years ago by nopper

I've attached a patch that shows a lesser intrusive scheme to obtain the same result. Works fine on win32.

Changed 4 years ago by nopper

This add checks that ignotus21 introduced to avoid scrolling to end if the user is seeing another region of scrooledwindow != en

in reply to: ↑ 2   Changed 4 years ago by ignotus

I tested on Linux (Slackware 12.2) with PyGTK 2.12.1. The patch "scroll-output-2.diff" did not work as expected. It seems that the standard use of marks does not have the right effects.

I talked to nopper and he did not like the "strip()" on the output. I think that there is no reason to show leading whitespaces, but I understand when he said: "the output should be presented as is".

Moreover, as nobody talked about the use of HIGVBox instead VPaned I assume this is ok. I don't know if nopper tested my patch on windows. I can't test it soon on this environment. So, I appreciate if someone else can test it.

  Changed 4 years ago by nopper

Ok my patch seems broken on linux. Btw I rethought the whole structure of the class and I agree with ignotus21 about removing the gtk.VPaned as base class. We should use the gtk.HBox as base class like ignotus21 proposed.

So ignotus remove the .strip() from the patch and should be ok for me.

  Changed 4 years ago by ignotus

  • type changed from enhancement to defect

  Changed 4 years ago by gpolo

Looks good.

Do you really need to do this ?

while (gtk.events_pending() or gtk.gdk.events_pending()): 
    gtk.main_iteration_do(True)

I mean, do you really need to check gtk.gdk.events_pending and block on main_iteration ? Shouldn't the following suffice:

while gtk.events_pending():
    gtk.main_iteration()

?

  Changed 4 years ago by ignotus

  • status changed from new to closed
  • resolution set to fixed

The gpolo suggested changes are incorporated and removed the strip() which nopper talk about. Fixed by r4452.

  Changed 4 years ago by gpolo

  • status changed from closed to reopened
  • resolution fixed deleted

Reopening as it has been problematic at least under py2exed Windows XP (Umit freezes). I had to comment part of the code that was causing the problem and the auto-scroll no longer works.

Changed 4 years ago by ignotus

New version

follow-up: ↓ 10   Changed 4 years ago by ignotus

I attached a new version of the patch (NmapOutputViewer?.py.2.diff) that seems to solve the problem. Now I'm using gtk.Adjustment signals instead all hacks in previous solution. I tested the solution in Linux, Windows XP (both, directly and py2exed version).

I removed some part of code due to redundancy.

420                self.text_buffer.move_mark(self.mark, 
421                                           self.text_buffer.get_start_iter()) 

As self.update_output_colors() is called after, and this function already have this instruction, this quoted code is no longer necessary.

in reply to: ↑ 9   Changed 4 years ago by luis

Replying to ignotus:

I attached a new version of the patch (NmapOutputViewer?.py.2.diff) that seems to solve the problem. Now I'm using gtk.Adjustment signals instead all hacks in previous solution. I tested the solution in Linux, Windows XP (both, directly and py2exed version). I removed some part of code due to redundancy. {{{ #!python 420 self.text_buffer.move_mark(self.mark, 421 self.text_buffer.get_start_iter()) }}} As self.update_output_colors() is called after, and this function already have this instruction, this quoted code is no longer necessary.

Tested in Linux and Mac OS. It seems work fine

  Changed 4 years ago by gpolo

  • type changed from defect to enhancement

While it "works fine", I'm feeling uncomfortable while using it. If you have something that generate a large output (something like target: google.com, profile: "quick and verbose scan") and then if you put the scroll somewhere in the middle it acts very weird. I don't know how to express this exactly, maybe you could try redoing these steps and verify.

Reverting this to enhancement.

Changed 4 years ago by ignotus

  Changed 4 years ago by ignotus

New patch (NmapOutputViewer?.py.3.diff) that claims to solve the problems gpolo reported. The scroll jumping caused by gtk.TextBuffer?.set_text() is solved using gtk.TextBuffer?.insert() instead. Now, is not need remember (and apply) the last position of gtk.Adjustment. This patch was tested in Linux and Windows XP (including py2exe version).

follow-up: ↓ 14   Changed 4 years ago by gpolo

This is getting good, ignotus.

There are two more problems remaining: after a scan finishes, there is a jump to top and then it scrolls down (if the scroll is supposed to go to bottom); the second one is about verifying for scroll at bottom when updating the nmap output, this is problematic because if you leave the scroll anywhere different than bottom, and resize the window (after the scan has finished), it will scroll back to bottom (supposing it was at bottom when scan finished).

I've solved the first problem mentioned simply by removing the go_to_host method, I didn't see how it is useful (but if it turns out to be, then it needs to be fixed).

Changed 4 years ago by gpolo

in reply to: ↑ 13 ; follow-up: ↓ 15   Changed 4 years ago by getxsick

Replying to gpolo:

There are two more problems remaining: after a scan finishes, there is a jump to top and then it scrolls down (if the scroll is supposed to go to bottom); the second one is about verifying for scroll at bottom when updating the nmap output, this is problematic because if you leave the scroll anywhere different than bottom, and resize the window (after the scan has finished), it will scroll back to bottom (supposing it was at bottom when scan finished). I've solved the first problem mentioned simply by removing the go_to_host method, I didn't see how it is useful (but if it turns out to be, then it needs to be fixed).

There is still something wrong. I used a case with large output, during the scan set scroll somewhere in the middle. then it looks fine. no jumping. after it finished, when i resize window vertically it works fine. but when i resize window horizontally, there are some jumps of the scroll (a bit up, and down down to the correct position)

in reply to: ↑ 14   Changed 4 years ago by getxsick

Replying to getxsick:

There is still something wrong. I used a case with large output, during the scan set scroll somewhere in the middle. then it looks fine. no jumping. after it finished, when i resize window vertically it works fine. but when i resize window horizontally, there are some jumps of the scroll (a bit up, and down down to the correct position)

I forgot to add that it only happens if you resize horizontally and output doesn't fix (lines are splitted or unsplitted)

  Changed 4 years ago by gpolo

Indeed getxsick, but as I see this is going to remain as is for the moment at least. At some point we would have to freeze the textview so it doesn't show display updates, and at some point thaw it to starting displaying changes again, but this looks problematic to me.

Regarding the "output doesn't fix", I don't know what you mean, textview already handles this for us automatically -- which is part of the problem but also solves several others that we would have.

  Changed 4 years ago by gpolo

  • status changed from reopened to closed
  • resolution set to fixed

As discussed on IRC, we have entered in an agreement and now I have committed it on r4476.

Thanks for everyone that contributed, the nmap output viewer is in a much better state now. Closing.

  Changed 9 months ago by enuavunslug1979

Is this really the way it suppose to work? By the what could mean error fatal error access to undeclared static property ?

Note: See TracTickets for help on using tickets.