eteran / nedit-ng

a Qt5 port of the NEdit using modern C++14
GNU General Public License v2.0
96 stars 26 forks source link

macro sub focus_window(next) does nothing #347

Open ahoffm11 opened 1 year ago

ahoffm11 commented 1 year ago

I have a session saving macro going over all open tabs like this:

  for (w = focus_window("last"); w != ""; w = focus_window("next")) {
     if ( $file_name != "Untitled" ) {
        append_file($file_path"// "$file_name"/"$cursor"/"$language_mode"/"$n_display_lines"/"$top_line "/\n", name)
    }
    }
}

focus_window("next") does not seem to advance to next tab, no matter how many tabs are open only the last one is reported

nedit-ng version 2020.1-257-gac8ddba5-dirty Qt: 5.12.8

ahoffm11 commented 1 year ago

The original nedit focus_window("next") rotated tabs backwards, this port does it other way around which is imho right but there is no focus_window("first") which could also be much better if you want to iterate over all open tabs . And also since one can now move tabs and also original nedit allowed detaching and reattaching tabs which also changed tab order so iterating from the last opened file was not always correct.

eteran commented 1 year ago

Hey there!

So I'm currently overseas, so I won't be able to respond much for a bit. But yes, NG does iterate forwards instead of backwards.

The reasons are actually pretty subtle and making it iterate backwards is surprisingly MUCH more complicated in the new code.

That being said, you've outlined a circumstance where it actually changes behavior in a notable way, so I'll have to think about what the ideal solution is.

Thanks for the report!