-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ctrl+Numpad5
vertically aligns found text in "Find All" Editor menu.
#789
Ctrl+Numpad5
vertically aligns found text in "Find All" Editor menu.
#789
Conversation
I don't mind, but isn't our default policy "use macros if you want to redefine keys"? |
My personal preferences aside, I was going to write a macro and add it to the deployment kit. However, I wanted to restrict this macro to Let's keep it as |
Taking it back. Since I don't like macros and the current behavior is counterintuitive anyway, let me flip the default and add the macro for those who what the old directions. |
This will make a lot of people very angry. |
Yeah! I know. I poked around with macros; like it even less. I'll go |
0e654d6
to
ddec86c
Compare
May I suggest splitting the work into two commits, one with vertical alignment and one with keys swapping? Maybe even move keys swapping to a separate PR. |
I can do that. |
ddec86c
to
5230fdd
Compare
Done! Please review. |
5230fdd
to
3a8e613
Compare
Ctrl+Numpad5
vertically aligns found text in "All matching entries" menu.Ctrl+Numpad5
vertically aligns found text in "Find All" Editor menu.
Fixed commit and PR descriptions. |
@MKadaner @alabuzhev Pardon, it's not quite clear from the discussion, are you gentlemen going to reverse the horizontal scrolling direction by Alt+Left/Right keys? |
@HamRusTal, I apologize for the confusion. In this PR I reverted all changes related to swapping the direction of horizontal scrolling. These changes clearly do not belong here. I am preparing another PR which will introduce a new |
3a8e613
to
40a9511
Compare
Rebased and ready for review. @alabuzhev, please have a look. |
40a9511
to
08cb6a2
Compare
Can I help somehow with the review, like adding comments to new functions or describe the general approach here? |
It's fine, I just didn't have much time during the week. |
far/vmenu.hpp
Outdated
@@ -142,11 +143,9 @@ struct MenuItemEx: menu_item | |||
std::any ComplexUserData; | |||
intptr_t SimpleUserData{}; | |||
|
|||
size_t ShowPos{}; | |||
int HPos{}; // Positive: Indent; Negative: Hanging |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is H for Horizontal?
Maybe add a few more letters to avoid confusion with Highlight?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went with HorizontalPosition
. I thought about renaming all other identifiers containing "hpos" but decided against it because it becomes mouthful. Let me know if you like something else renamed.
08cb6a2
to
df5a5f0
Compare
far/vmenu.cpp
Outdated
for (const auto I: std::views::iota(0uz, Items.size())) | ||
NeedRedraw |= SetItemShowPos(static_cast<int>(I), NewShowPos, MaxLineWidth); | ||
for (auto& Item : Items) | ||
NeedRedraw |= SetItemHPos(Item, std::forward<GetNewHPos_T>(GetNewHPos)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sonarcloud complains here, and technically quite rightfully:
- By forwarding the argument we permit the callee to steal it.
- The callee takes the parameter by value, so the parameter ctor technically can take advantage of that and steal from rvalue.
- And then we pass this potentially empty thing again on the next iteration.
Given that everything here is local and we know exactly what comes in and don't need to store these callbacks or anything like that, I suggest keeping things simpler and passing callbacks by const auto&
everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ouch! I've seen Sonarcloud's complaint but missed the fact that the forwarding happens in a loop. Thank you for checking.
a919847
to
32f9de5
Compare
`Ctrl+Numpad5` in Editor menu "All matching entries" vertically aligns found text in all items. To preserve vertical alignment while scrolling items horizontally, the items can be moved beyond the left or right window edges.
32f9de5
to
bf0d803
Compare
Quality Gate passedIssues Measures |
Thanks |
Thank you! |
@MKadaner would it be possible to use Thank you for implementing this. It's really useful. |
@rohitab Alt+Home should work. |
@alabuzhev Nice! I didn't even know about that hotkey. Thank you. |
@MKadaner Is it by intent that Also, I wonder if it is easy to change |
@rohitab, Alabuzhev had beaten me with reply for a few hours. Sure, @HamRusTal, I did not touch the legend on this dialog. Lots of other useful key combinations, like |
@MKadaner I was going to write a macro to toggle the state, but there doesn't seem to be any way to determine the current state. Obviously, there are workarounds, but I think making a small change in Far might be better. Something like the following works to toggle the state from aligned to left and vice-versa. What do you think? diff --git a/far/vmenu.cpp b/far/vmenu.cpp
index 0b54ceb55..004e6f569 100644
--- a/far/vmenu.cpp
+++ b/far/vmenu.cpp
@@ -1649,7 +1649,7 @@ bool VMenu::ProcessKey(const Manager::Key& Key)
case KEY_CTRLNUMPAD5:
case KEY_RCTRLNUMPAD5:
{
- if (AlignAnnotations())
+ if (AlignAnnotations() || SetAllItemsSmartHPos(0))
DrawMenu();
break;
This has another benefit too. Say, I pressed |
@MKadaner Do you have any idea how feasible it is to make the line numbers and their vertical separator line stay put on the left when scrolling the menu items? As they were scrolling all in accord, that looked OK but now when the lines are aligned by the found text, these prefix fragments are scattered all around and look quite confusing IMHO. |
@rohitab, the things will become less obvious if the user aligns all annotations and then shifts one or more individual items left or right. Now, the annotations are not aligned, so the first Thinking of the "Find all" dialog after I actually spent a few months experimenting with quite different behaviors of the list after aligning annotation. One of the behaviors I explored was the kind of state you are suggesting. I showed and discussed different behaviors with a couple of Far users I could communicate directly. Please believe me that the behavior I finally implemented is the most predictable and easy to use, though it also is not free of quirks.
I see how this quick switching back and forth is convenient. I like such kind of behavior myself. However, if we support it, we'll incur other subtle inconsistencies. The real problem here is that line numbers can be shifted out of the viewport, while they of course should stay put, like in Excel spreadsheet for example. It is this problem that should eventually be addressed. So, please read on. P.S. The solution you proposed, while really elegant, is suboptimal. Think of a list with hundredths of thousands of items (which is my regular use case). It is rather expensive to scan all items (inside |
@HamRusTal, this behavior is a damn nuisance I have been thinking about for years. Actually, even before my change, one could align all items to the right ( For me personally, aligning annotations has much higher priority than scattered line numbers, so it went first. Now aligning is done, I am warming up for line numbers. I can see at least two solutions:
The resulting UX will be more or less the same. As it usually happens, each option has its own pros and cons. So, stay tuned. |
@MKadaner thank you for taking the time to explain in detail.
I actually don't see anything wrong with this behavior. If items were shifted, and the user pressed
I see how this could be a problem. In this case, when the user pressed
I honestly don't see any downside to what I'm suggesting. For users that like the current implementation, it should not change anything. All the existing hotkeys, However, I'm not going to push this issue further. If you and other Far users believe this is the best implementation, I'm good with it.
It was my understanding that this already happens. Each time you press |
@rohitab, thank you for the explanations.
The UX problem will be that when all visible annotations are aligned and the user presses There is another, more hypothetical issue though. Did you notice that if the pattern is found on the same line more than once, currently Far inserts so many items in the "Find all" list, each with its unique position number (next to the line number). I actually hate this behavior. More than once was I deceived into thinking that there were many matching lines in the text, while in reality the lines were few, but the occurrences were many. Sure, I had to look at the list header where both the number of lines and the number of occurrences are clearly printed, but... that happened to me again and again. As such, I want to change the UX and show in the list one item for each matching line with all found occurrences highlighted. If I do so, how to align annotations? I thought about using repeated May I ask you to create a new discussion for "toggling" between "align left" and "align the found" with
Consider the normal scenario.
In this scenario, the item 2 above is pure overhead, and not a small one because |
Please see #802 |
Summary
Ctrl+Numpad5
in Editor menu "All matching entries" vertically aligns found text in all items. To preserve vertical alignment while scrolling items horizontally, the items can be moved beyond the left or right window edges.References
This PR is a replacement of #711. See the discussion there for the motivation and design choices.
I decided against automatically aligning the items on open. This would be an unwarranted behavior change, while it requires only a single keystroke to align items manually, and it can even be automated with a macro if somebody wishes it.
Checklist
AlignAnnotations
toVMemu
. #711If not checked, I accept that this work might be rejected in favor of a different great big ineffable plan.