New File Filtering Feature

Post any comments, suggestions, annoyances or ideas for future releases here. Please do not post bug reports or questions here.
Post Reply
jussij
Site Admin
Posts: 2508
Joined: Fri Aug 13, 2004 5:10 pm

New File Filtering Feature

Post by jussij » Sat Mar 17, 2012 3:13 am

Based on the Kedit discussion found here: http://www.zeusedit.com/zforum/viewtopic.php?t=6596

I am thinking of adding a level of filtering to Zeus.

While it will not be as sophisticated as the Kedit ALL/MORE/LESS/ZONE features it should hopefully be worthwhile.

How will it work?

There will be a new modeless File Filtering dialog:

Code: Select all

 +------------------------------------------------+
 | File Filtering                                 |
 +------------------------------------------------+
 |           +----------------------------+ +---+ |
 | Document: | C:\temp\test.txt           | |...| |
 |           +----------------------------+ +---+ |
 |                                                |
 | +-- Add Filters -----------------------------+ |
 | |                   +----------------------+ | |
 | |   Filter #1:      |                      | | |
 | |                   +----------------------+ | |
 | |                   +----------------------+ | |
 | |   Filter #2:      |                      | | |
 | |                   +----------------------+ | |
 | |                                  +-------+ | |
 | |                                  | Apply | | |
 | |                                  +-------+ | |
 | +--------------------------------------------+ |
 | +--- Remove Filters -------------------------+ |
 | |                   +----------------------+ | |
 | |   Filter #1:      |                      | | |
 | |                   +----------------------+ | |
 | |                   +----------------------+ | |
 | |   Filter #2:      |                      | | |
 | |                   +----------------------+ | |
 | |                                  +-------+ | |
 | |                                  | Apply | | |
 | |                                  +-------+ | |
 | +--------------------------------------------+ |
 | +-- Line Changes ----------------------------+ |
 | |                   +----------------------+ | |
 | |   Search #1:      |                      | | |
 | |                   +----------------------+ | |
 | |                   +----------------------+ | |
 | |  Replace #2:      |                      | | |
 | |                   +----------------------+ | |
 | |                                  +-------+ | |
 | |                                  | Apply | | |
 | |                                  +-------+ | |
 | +--------------------------------------------+ |
 | +-------+                                      |
 | | Close |                                      |
 | +-------+                                      |
 +------------------------------------------------+
This dialog works by taking an input file (defaults to the active document).

The Add Filters are regular expressions that define which lines of the input file will be taken to create a new document.

The Remove Filters are regular expressions that define which lines of the new document file will be remove.

The Line Changes are search and replace regular expressions that define how to change the lines of the new document.

How will the results be displayed?

As soon as the first Add Filter is applied a new document will be created and displayed in Zeus just like any other text file.

What do we think?

Any comments, suggestions, improvements etc.

Cheers Jussi

billdehaan
Posts: 9
Joined: Tue Mar 13, 2012 8:06 pm

Re: New File Filtering Feature

Post by billdehaan » Sat Mar 17, 2012 3:52 am

jussij wrote:Based on the Kedit discussion found here: http://www.zeusedit.com/zforum/viewtopic.php?t=6596

As soon as the first Add Filter is applied a new document will be created and displayed in Zeus just like any other text file.

What do we think?
When you say "a new document will be created", does this mean that changes made on the filtered criteria will not be reflected in the original document?

Also, if possible, can the filter conditions include line ranges, in addition to regular expressions?

jussij
Site Admin
Posts: 2508
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij » Sat Mar 17, 2012 4:09 am

When you say "a new document will be created", does this mean that changes made on the filtered criteria will not be reflected in the original document?

That is correct. The new document will be an in memory document.

At first I thought about trying to emulate the Kedit line scope concept in full, but this change is just too difficult to implement as it touches too many areas of the Zeus code.

For example it would be quite easy to add a scope flag to each line and then hide lines based on that scope.

But that scope change would also impact on the cursor movement and line editing code meaning all that code would also need to changed.

It would also impact on the mouse marking, and code folding code and so on and so forth :(

So the safest, simplest change is to just create a new document.
Also, if possible, can the filter conditions include line ranges, in addition to regular expressions?
I am not sure what you this means :?:

The filter conditions just define which lines of the input document get copied into the new document.

Cheers Jussi

billdehaan
Posts: 9
Joined: Tue Mar 13, 2012 8:06 pm

Post by billdehaan » Sat Mar 17, 2012 12:53 pm

At first I thought about trying to emulate the Kedit line scope concept in full, but this change is just too difficult to implement as it touches too many areas of the Zeus code.
Not surprising.
So the safest, simplest change is to just create a new document.
Well, the next question then is how to reintegrate the changes back into the original document?

Say I have a 5,000 line file. I want to make changes on lines which have condition Y but not Z. So, I use the new dialog with an Add filter of Y and a Remove filter of Z, and I get a new buffer which has the 200 lines that meet that criteria. I now edit that buffer and make 75 changes, adding 20 new lines, deleting 50 lines, and making text changes on about 100 of them.

Now, I have to put those changes back into the original document. If I have to do that manually, it's going to be far too error prone to make it worthwhile; I'd be better off just editing the original document.

Since you say you can add a SCOPE value to the line, I recommend you add two; say, MAJOR_SCOPE and MINOR scope. By default, both would have value 0. Make both of these values accessible to the macro language(s).

I can envision the following, using the 5,000 line file example above:

1. User selects criteria Y and Z, resulting in 200 matching lines
2. Zeus sets the MAJOR_SCOPE of all lines to increase, incrementally
3. All lines are copied to new buffer, with scope values intact
4. User edits the new buffer.
5. Lines added to the new buffer have MAJOR_SCOPE as the line above, with MINOR_SCOPE incremented
6. When editing is done user can merge, and lines from the new buffer overwrite lines in the original buffer with the same MAJOR_SCOPE. Lines deleted from the new buffer are deleted from the original, and lines added are placed in the original file based on the MINOR_SCOPE.

As an example:

When the new buffer is created, it has 200 lines. The first line has MAJOR_SCOPE of 1, the second has MAJOR_SCOPE of 2, etc. All have MINOR_SCOPE of 0.

Lines are editted without changing the scope.

Lines that are added have the MAJOR_SCOPE of the line above, with new MINOR_SCOPE. So if the user added 5 lines after line 7 in the new buffer, all the new lines would have MAJOR_SCOPE of 7. The first new line would have MINOR_SCOPE of 1, the second would have MINOR_SCOPE of 2, etc.

When it comes time to remerge with the original document, it now becomes an automatic operation, Zeus can use the SCOPE values to re-insert all 200 lines back into the original document in their original position.
I am not sure what you this means :?:
I mean that as well as using regular expressions (lines that include string "ParentClass:MethodName("), be able to specify by line ranges (ie. lines 100 to 107). That's useful when you with to make changes in a block of code such as a large subroutine which can't be defined using a regular expression. Imagine a 20,000 line FORTRAN program where you want to rewrite an 800 line FileHandler() subroutine, so you isolate it into a new buffer and perform global operations on it.

jussij
Site Admin
Posts: 2508
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij » Tue Mar 20, 2012 7:38 am

Well, the next question then is how to reintegrate the changes back into the original document?

This is a very good point. I will have to give this a bit more thought.
be able to specify by line ranges (ie. lines 100 to 107).

This sounds doable.

Cheers Jussi

Post Reply
kuchnie warszawa opinie

Who is online

Users browsing this forum: No registered users and 2 guests