Skip to content
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

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

Conversation

noborus
Copy link
Owner

@noborus noborus commented Jan 5, 2025

Add support for vertical header.
Add vertical header option.

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)
Copy link
Contributor

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

Copy link
Owner Author

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
Copy link
Contributor

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

@@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

@@ -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)
Copy link
Contributor

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?

@@ -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)
Copy link
Contributor

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
Copy link
Contributor

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.

Copy link
Owner Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants