-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
statusline: Provide overwrite
mode indicator
#3620
base: master
Are you sure you want to change the base?
Conversation
internal/display/statusline.go
Outdated
@@ -47,6 +47,12 @@ var statusInfo = map[string]func(*buffer.Buffer) string{ | |||
} | |||
return "" | |||
}, | |||
"overwrite": func(b *buffer.Buffer) string { | |||
if b.GetActiveCursor().IsOverwriteMode { | |||
return "del" |
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.
"Delete" is not exactly what the overwrite mode is about. It is about overwrite aka replace, right?
I'm not sure which string should we display here.
I'm also wondering: can we be space-saving here and display a string only when in overwrite mode (similarly to $(modified)
)? Then maybe we could even add $(overwrite)
to the default value of statusformatl
.
Although again, I'm not sure which string should we display then. [overwrite]
? Anything shorter?
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.
Even we find something, which we think it fits the needs...there is the one who likes to customize it anyway. 😉
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 cannot come up with a better string, but I usually see "INS" displayed on the status bar when overwrite mode is enabled in GUI text editors. I don't think there could be a string with only symbols that can be recognized without confusion.
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.
Yeah, I thought about [ins]
too. I'm not entirely opposed to it, although arguably it would be a lie, since it is not the "insert mode" but the opposite of it (but hey, we can always say that it is "the mode that is triggered by pressing Insert, hence [ins]
).
For reference, what some other editors display in their status lines, FWICS:
- vim:
-- REPLACE --
in overwrite mode,-- INSERT --
in normal insert mode - emacs:
Ovwrt
in overwrite mode, nothing in normal mode - geany:
OVR
in overwrite mode,INS
in normal mode - nano doesn't seem to implement overwrite mode at all, the Insert key triggers something different
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'd prefer to keep the normal and default insert mode unmarked, as it is right now and only mark the replace/overwrite mode.
Unfortunately you don't like [>]
, because it is not self-explaining. 😉
How about [ow]
...it is similar to [ro]
or shall it be more explicit, but possibly longer?
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.
"ow" sounds like "ouch" or something.
[ovr]
?
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.
over what?
I'm not really convinced.
[I]
/[O]
or [I]
/[R]
, but then [I]
needs to be displayed by default, otherwise [O]
or [R]
doesn't self explain.
Or as suggested by you initially just [overwrite]
, which is a bit longer, but explicit and really self explaining.
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.
[overwrite]
is ok for me.
One more thought: maybe let's make [ro]
and [overwrite]
mutually exclusive? Since when the buffer is readonly, there is little point in informing the user that we are in overwrite mode, since the user cannot edit (either insert or overwrite) anything anyway.
i.e. a trivial change:
--- a/internal/display/statusline.go
+++ b/internal/display/statusline.go
@@ -48,7 +48,7 @@ var statusInfo = map[string]func(*buffer.Buffer) string{
return ""
},
"overwrite": func(b *buffer.Buffer) string {
- if b.OverwriteMode {
+ if b.OverwriteMode && !b.Type.Readonly {
return "[overwrite] "
}
return ""
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.
since the user cannot edit (either insert or overwrite) anything anyway.
Well, actually currently the user can overwrite characters in a readonly buffer (try it: open help
, press Insert and start typing characters), but that's a nasty bug to be fixed (#1805).
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.
Good catch, thanks.
#1805 needs to be fixed on its own.
I think abusing That's the trick we use with |
Good point, works like a charm! |
67c67e8
to
40a7486
Compare
40a7486
to
2813b5f
Compare
0abf3d7
to
8253c2f
Compare
8253c2f
to
9960190
Compare
9960190
to
c1f4e74
Compare
Sorry for chiming in late, and please ignore this comment if you think it just makes things more complicated. I personally find that |
We're aware of the fact that it actually requires a lot space within the Unfortunately we didn't came up with a better, shorter and self explaining suggestion.
Hm, something to consider. |
We can store the
overwrite
state in theBuffer
instead of theBufPane
, which makes it easier to be accessed from thestatusline
via thestatusformatl
option.Closes #3155