Skip to content

Commit

Permalink
statusline: Provide overwrite mode indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeKar committed Jan 23, 2025
1 parent c61670e commit c1f4e74
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/config/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ var defaultCommonSettings = map[string]interface{}{
"softwrap": false,
"splitbottom": true,
"splitright": true,
"statusformatl": "$(filename) $(modified)($(line),$(col)) $(status.paste)| ft:$(opt:filetype) | $(opt:fileformat) | $(opt:encoding)",
"statusformatl": "$(filename) $(modified)$(overwrite)($(line),$(col)) $(status.paste)| ft:$(opt:filetype) | $(opt:fileformat) | $(opt:encoding)",
"statusformatr": "$(bind:ToggleKeyMenu): bindings, $(bind:ToggleHelp): help",
"statusline": true,
"syntax": true,
Expand Down
6 changes: 6 additions & 0 deletions internal/display/statusline.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ var statusInfo = map[string]func(*buffer.Buffer) string{
}
return ""
},
"overwrite": func(b *buffer.Buffer) string {
if b.OverwriteMode && !b.Type.Readonly {
return "[overwrite] "
}
return ""
},
"lines": func(b *buffer.Buffer) string {
return strconv.Itoa(b.LinesNum())
},
Expand Down
4 changes: 2 additions & 2 deletions runtime/help/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -415,11 +415,11 @@ Here are the available options:
* `statusformatl`: format string definition for the left-justified part of the
statusline. Special directives should be placed inside `$()`. Special
directives include: `filename`, `modified`, `line`, `col`, `lines`,
`percentage`, `opt`, `bind`.
`percentage`, `opt`, `overwrite`, `bind`.
The `opt` and `bind` directives take either an option or an action afterward
and fill in the value of the option or the key bound to the action.

default value: `$(filename) $(modified)($(line),$(col)) $(status.paste)|
default value: `$(filename) $(modified)$(overwrite)($(line),$(col)) $(status.paste)|
ft:$(opt:filetype) | $(opt:fileformat) | $(opt:encoding)`

* `statusformatr`: format string definition for the right-justified part of the
Expand Down

0 comments on commit c1f4e74

Please sign in to comment.