-
-
Notifications
You must be signed in to change notification settings - Fork 39
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
WIP: Add support for vertical header #679
base: master
Are you sure you want to change the base?
Conversation
Add support for vertical header. Add vertical header option.
oviewer/draw.go
Outdated
@@ -54,6 +55,7 @@ func (root *Root) drawBody(lX int, lN int) (int, int) { | |||
markStyleWidth := min(root.scr.vWidth, root.Doc.general.MarkStyleWidth) | |||
|
|||
wrapNum := m.numOfWrap(lX, lN) | |||
log.Println("wrapNum:", lN, wrapNum, m.width) |
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.
Do you want to keep this?
It looks like a left behind debug
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.
Thank you for your comment.
However, this PR is experimental, so it may change a lot. Also, it may not be merged.
oviewer/draw.go
Outdated
func (root *Root) drawVerticalHeader(y int, lX int, lineC LineC) { | ||
numberWidth := root.scr.numberWidth | ||
if numberWidth > 0 { | ||
numberWidth += 1 |
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.
numberWidth += 1 | |
numberWidth++ |
@@ -100,6 +100,11 @@ type SCR struct { | |||
// sectionHeaderEnd is the end of the section header. | |||
sectionHeaderEnd int | |||
|
|||
// numWidth is the width of the number. |
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.
This comment is so bad, haha
I hope it's an AI generated one 🤞
I'm sure something better than this could be suggested
oviewer/oviewer.go
Outdated
@@ -100,6 +100,11 @@ type SCR struct { | |||
// sectionHeaderEnd is the end of the section header. | |||
sectionHeaderEnd int | |||
|
|||
// numWidth is the width of the number. | |||
numberWidth int | |||
// verticalHeader is the vertical header. |
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.
Same
oviewer/prepare_draw.go
Outdated
@@ -73,7 +76,7 @@ func (root *Root) prepareDraw(ctx context.Context) { | |||
root.scr.headerEnd = root.Doc.firstLine() | |||
// Set the header height. | |||
root.Doc.headerHeight = root.Doc.getHeight(root.scr.headerLN, root.scr.headerEnd) | |||
|
|||
log.Println("headerHeight:", root.Doc.headerHeight, root.Doc.width) |
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.
Do you want to keep this log?
oviewer/prepare_draw.go
Outdated
@@ -306,6 +309,7 @@ func (m *Document) getHeight(startLN int, endLN int) int { | |||
for lN := startLN; lN < endLN; lN++ { | |||
height += len(m.leftMostX(lN)) | |||
} | |||
log.Println("height:", startLN, endLN, height) |
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.
Same
Fix the gap between the number of lines when wrapped. Deleted Debug line. Fixed the code and comments pointed out in the comments.
Added style to set with StyleVerticalHeader
rootCmd.PersistentFlags().IntP("vertical-header", "V", 0, "number of vertical header lines to be displayed constantly") | ||
_ = viper.BindPFlag("general.VerticalHeader", rootCmd.PersistentFlags().Lookup("vertical-header")) | ||
_ = rootCmd.RegisterFlagCompletionFunc("vertical-header", func(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) { | ||
return []string{"1"}, cobra.ShellCompDirectiveNoFileComp |
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.
Could you explain me this pattern?
The field is an integer, and so here you tell viper to complete the field will the value 1
, why 1? Why not []string{}
Is it a way to complete with something that will help user to understand it's a number that is expected?
I had already looked at the code and I was surprised to see this
Here you are doing it again, either on purpose or by copy pasting code.
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.
This is still a temporary option, so it doesn't make much sense.
This indicates that an option argument requires numerical values (1 or more).
I thought that the blank ("") wouldn't know what to specify.
Add support for vertical header.
Add vertical header option.