Skip to content

Re-design the API of new feature "alternate line color" #9

@muzimuzhi

Description

@muzimuzhi

To improve the usability of the feature suggested in #8 , I am re-thinking the options and the beneath logic of the general highlight feature. The re-designed options

  • use option highlight-lines to choose which highlight mode is used
  • use option highlight-line-numbers to toggle whether highlight the line number part
  • use three color options to specify corresponding colors, and these color options all have default values

This is only a design- and pseudo-level discussion, therefore the actual package code in my forked repo is not modified yet.

Original

Options

 - highlight-lines = <empty> | <selected lines>
 	- default value <empty>
 - highlight-color = <color>
	- default value `LightCyan`

Logic

if (hightlight-lines is <empty>) then
	normal
else
	highlight <selected lines> in <color>
fi

Final

Options

(Modified)
 - highlight-lines = <empty> | <selected lines> | <alternate>
 	- default value <empty>
 - highlight-color = <line color> | {<line color>, <line number color>}
	- default value `{LightCyan, LightYellow}`
(Added)
 - highlight-line-numbers = <boolean value>
	- default value `false`
 - highlight-odd-line-color = <odd line color> 
				| {<odd line color>, <odd line number color>}
	- default value `{LightCyan, LightYellow}`
 - highlight-even-line-color = <even line color> 
				| {<even line color>, <even line number color>}
	- default value `{LightCyan!60, LightYellow!60}`

Logic

if (highlight-lines is <empty>) then
	normal
else if (highlight-lines is <selected lines>) then
	if (line-number is typeset && highlight-line-numbers is `true`) then
		highlight <selected lines> in <line color>, 
		  with line numbers in <line-number-color>
	else
		highlight line of <selected lines> in <line color>
	fi
else // (highlight-lines is <alternate>)
	if (line-number is typeset && highlight-line-numbers is `true`) then
		highlight odd lines in <odd-line-color>, even lines in <even-line-color>, 
		  with line numbers in corresponding colors
	else
		highlight odd lines in <odd-line-color>, even lines in <even-line-color>
	fi
fi

Notes

  1. To keep names of options clear, inter-word dashes are used.
  2. By some searching, I think the phrase alternate rows is more popular than zebra effect, the following one is used in issue minted/#211.
  3. We still need option linenumbersep, but its function is off-topic to this issue, so it's absent in the current issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions