~rjarry/aerc-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
10 2

[PATCH] style: customize vertical and horizontal border-chars

Details
Message ID
<CG0X2EY3NRUO.3HVU1DYN9U6BK@lamia>
DKIM signature
pass
Download raw message
This allows vertical and horizontal border characters to be defined in
aerc.conf; I considered making them a styleset property but adding
border.vertical and border.horizontal properties there looks a lot more
involved.
Details
Message ID
<F54ADF69-E748-46F8-A78F-1E362B9E05BE@jarry.cc>
In-Reply-To
<CG0X2EY3NRUO.3HVU1DYN9U6BK@lamia> (view parent)
DKIM signature
missing
Download raw message
Hi Dian,

Please do not send patches as email attachments. They should be inline. You can use the `git send-email` command which will take care of it for you.

Here are some guides for reference:

https://git-send-email.io/
https://doc.dpdk.org/guides/contributing/patches.html#sending-patches

Thanks!
Details
Message ID
<20211128164915.11189-1-dian.m.fay@gmail.com>
In-Reply-To
<F54ADF69-E748-46F8-A78F-1E362B9E05BE@jarry.cc> (view parent)
DKIM signature
pass
Download raw message
Let's try this again. --compose seems a little finicky so hopefully this
works out....
Details
Message ID
<20211128164915.11189-2-dian.m.fay@gmail.com>
In-Reply-To
<20211128164915.11189-1-dian.m.fay@gmail.com> (view parent)
DKIM signature
pass
Download raw message
Patch: +28 -6
---
 config/aerc.conf.in      | 5 +++++
 config/config.go         | 8 ++++++++
 doc/aerc-config.5.scd    | 7 ++++++-
 doc/aerc-stylesets.7.scd | 2 +-
 lib/ui/borders.go        | 4 +++-
 widgets/compose.go       | 3 ++-
 widgets/msgviewer.go     | 5 +++--
 7 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/config/aerc.conf.in b/config/aerc.conf.in
index 08d1dbc..132d7ea 100644
--- a/config/aerc.conf.in
+++ b/config/aerc.conf.in
@@ -94,6 +94,11 @@ next-message-on-delete=true
# default: @SHAREDIR@/stylesets/
stylesets-dirs=@SHAREDIR@/stylesets/

# Uncomment to use box-drawing characters for vertical and horizontal borders.
#
# Default: "  "
# border-chars=│─

# Sets the styleset to use for the aerc ui elements.
#
# Default: default
diff --git a/config/config.go b/config/config.go
index 9be55c6..49b5f69 100644
--- a/config/config.go
+++ b/config/config.go
@@ -50,6 +50,7 @@ type UIConfig struct {
	NextMessageOnDelete bool          `ini:"next-message-on-delete"`
	CompletionDelay     time.Duration `ini:"completion-delay"`
	CompletionPopovers  bool          `ini:"completion-popovers"`
	BorderChars         string        `ini:"border-chars"`
	StyleSetDirs        []string      `ini:"stylesets-dirs" delim:":"`
	StyleSetName        string        `ini:"styleset-name"`
	style               StyleSet
@@ -440,6 +441,12 @@ func (config *AercConfig) LoadConfig(file *ini.File) error {
		return err
	}

	if len([]rune(config.Ui.BorderChars)) < 2 {
		// got a partial config, right-pad with the default space to
		// avoid crashing
		config.Ui.BorderChars = fmt.Sprintf("%-2s", config.Ui.BorderChars)
	}

	for idx, contextualUi := range config.ContextualUis {
		if contextualUi.UiConfig.StyleSetName == "" &&
			len(contextualUi.UiConfig.StyleSetDirs) == 0 {
@@ -522,6 +529,7 @@ func LoadConfigFromFile(root *string, sharedir string) (*AercConfig, error) {
			NextMessageOnDelete: true,
			CompletionDelay:     250 * time.Millisecond,
			CompletionPopovers:  true,
			BorderChars:         "  ",
			StyleSetDirs:        []string{path.Join(sharedir, "stylesets")},
			StyleSetName:        "default",
		},
diff --git a/doc/aerc-config.5.scd b/doc/aerc-config.5.scd
index 4dbdba3..790fbc2 100644
--- a/doc/aerc-config.5.scd
+++ b/doc/aerc-config.5.scd
@@ -192,9 +192,14 @@ These options are configured in the *[ui]* section of aerc.conf.

	Default: 250ms

*border-chars*
	Vertical and horizontal border characters, in that order.

	Default: "  "

*stylesets-dirs*
	The directories where the stylesets are stored. The config takes a
	colon-seperated list of dirs.
	colon-separated list of dirs.

	Default: "/usr/share/aerc/stylesets"

diff --git a/doc/aerc-stylesets.7.scd b/doc/aerc-stylesets.7.scd
index ff23aa3..7f80e2a 100644
--- a/doc/aerc-stylesets.7.scd
+++ b/doc/aerc-stylesets.7.scd
@@ -128,7 +128,7 @@ styling.
|  spinner
:  The style for the loading spinner.
|  border
:  The style used to draw borders. *Only the background color is used*.
:  The style used to draw borders. *Only the background color is used unless you customize border-chars in aerc.conf*.
|  selector_default
:  The default style for the selector ui element.
|  selector_focused
diff --git a/lib/ui/borders.go b/lib/ui/borders.go
index 1b69a8e..1e24ef0 100644
--- a/lib/ui/borders.go
+++ b/lib/ui/borders.go
@@ -50,6 +50,8 @@ func (bordered *Bordered) Draw(ctx *Context) {
	width := ctx.Width()
	height := ctx.Height()
	style := bordered.uiConfig.GetStyle(config.STYLE_BORDER)
	vert := []rune(bordered.uiConfig.BorderChars)[0]

	if bordered.borders&BORDER_LEFT != 0 {
		ctx.Fill(0, 0, 1, ctx.Height(), ' ', style)
		x += 1
@@ -61,7 +63,7 @@ func (bordered *Bordered) Draw(ctx *Context) {
		height -= 1
	}
	if bordered.borders&BORDER_RIGHT != 0 {
		ctx.Fill(ctx.Width()-1, 0, 1, ctx.Height(), ' ', style)
		ctx.Fill(ctx.Width()-1, 0, 1, ctx.Height(), vert, style)
		width -= 1
	}
	if bordered.borders&BORDER_BOTTOM != 0 {
diff --git a/widgets/compose.go b/widgets/compose.go
index 69a2dcc..7a28c45 100644
--- a/widgets/compose.go
+++ b/widgets/compose.go
@@ -679,9 +679,10 @@ func (c *Composer) updateGrid() {
		c.grid.RemoveChild(c.heditors)
	}
	borderStyle := c.config.Ui.GetStyle(config.STYLE_BORDER)
	horiz := []rune(c.config.Ui.BorderChars)[1]
	c.heditors = heditors
	c.grid.AddChild(c.heditors).At(0, 0)
	c.grid.AddChild(ui.NewFill(' ', borderStyle)).At(1, 0)
	c.grid.AddChild(ui.NewFill(horiz, borderStyle)).At(1, 0)
}

func (c *Composer) reloadEmail() error {
diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go
index fc4529c..d9af5da 100644
--- a/widgets/msgviewer.go
+++ b/widgets/msgviewer.go
@@ -106,14 +106,15 @@ func NewMessageViewer(acct *AccountView,
	}

	borderStyle := acct.UiConfig().GetStyle(config.STYLE_BORDER)
	horiz := []rune(acct.UiConfig().BorderChars)[1]

	grid.AddChild(header).At(0, 0)
	if msg.PGPDetails() != nil {
		grid.AddChild(NewPGPInfo(msg.PGPDetails(), acct.UiConfig())).At(1, 0)
		grid.AddChild(ui.NewFill(' ', borderStyle)).At(2, 0)
		grid.AddChild(ui.NewFill(horiz, borderStyle)).At(2, 0)
		grid.AddChild(switcher).At(3, 0)
	} else {
		grid.AddChild(ui.NewFill(' ', borderStyle)).At(1, 0)
		grid.AddChild(ui.NewFill(horiz, borderStyle)).At(1, 0)
		grid.AddChild(switcher).At(2, 0)
	}

-- 
2.34.1
Details
Message ID
<CG1OYN8DJ0AJ.2HMMGL6ZSX7NV@diabtop>
In-Reply-To
<20211128164915.11189-2-dian.m.fay@gmail.com> (view parent)
DKIM signature
missing
Download raw message
Hi,

Dian M Fay, Nov 28, 2021 at 17:49:
> ---
>  config/aerc.conf.in      | 5 +++++
>  config/config.go         | 8 ++++++++
>  doc/aerc-config.5.scd    | 7 ++++++-
>  doc/aerc-stylesets.7.scd | 2 +-
>  lib/ui/borders.go        | 4 +++-
>  widgets/compose.go       | 3 ++-
>  widgets/msgviewer.go     | 5 +++--
>  7 files changed, 28 insertions(+), 6 deletions(-)

Could you write a short description of what your commit does and why it
is useful?

You may refer to the Linux kernel docs for inspiration:

https://www.kernel.org/doc/html/latest/process/submitting-patches.html#describe-your-changes

> diff --git a/config/aerc.conf.in b/config/aerc.conf.in
> index 08d1dbc..132d7ea 100644
> --- a/config/aerc.conf.in
> +++ b/config/aerc.conf.in
> @@ -94,6 +94,11 @@ next-message-on-delete=true
>  # default: @SHAREDIR@/stylesets/
>  stylesets-dirs=@SHAREDIR@/stylesets/
>  
> +# Uncomment to use box-drawing characters for vertical and horizontal borders.
> +#
> +# Default: "  "
> +# border-chars=│─
> +
>  # Sets the styleset to use for the aerc ui elements.
>  #
>  # Default: default
> diff --git a/config/config.go b/config/config.go
> index 9be55c6..49b5f69 100644
> --- a/config/config.go
> +++ b/config/config.go
> @@ -50,6 +50,7 @@ type UIConfig struct {
>  	NextMessageOnDelete bool          `ini:"next-message-on-delete"`
>  	CompletionDelay     time.Duration `ini:"completion-delay"`
>  	CompletionPopovers  bool          `ini:"completion-popovers"`
> +	BorderChars         string        `ini:"border-chars"`
>  	StyleSetDirs        []string      `ini:"stylesets-dirs" delim:":"`
>  	StyleSetName        string        `ini:"styleset-name"`
>  	style               StyleSet
> @@ -440,6 +441,12 @@ func (config *AercConfig) LoadConfig(file *ini.File) error {
>  		return err
>  	}
>  
> +	if len([]rune(config.Ui.BorderChars)) < 2 {
> +		// got a partial config, right-pad with the default space to
> +		// avoid crashing

This is very fragile. I would prefer two separate settings to avoid
confusion:

  border-char-vertical
  border-char-horizontal

Along with validation that the setting is exactly one character long
(after stripping white space).

> +		config.Ui.BorderChars = fmt.Sprintf("%-2s", config.Ui.BorderChars)
> +	}
> +
>  	for idx, contextualUi := range config.ContextualUis {
>  		if contextualUi.UiConfig.StyleSetName == "" &&
>  			len(contextualUi.UiConfig.StyleSetDirs) == 0 {
> @@ -522,6 +529,7 @@ func LoadConfigFromFile(root *string, sharedir string) (*AercConfig, error) {
>  			NextMessageOnDelete: true,
>  			CompletionDelay:     250 * time.Millisecond,
>  			CompletionPopovers:  true,
> +			BorderChars:         "  ",
>  			StyleSetDirs:        []string{path.Join(sharedir, "stylesets")},
>  			StyleSetName:        "default",
>  		},
> diff --git a/doc/aerc-config.5.scd b/doc/aerc-config.5.scd
> index 4dbdba3..790fbc2 100644
> --- a/doc/aerc-config.5.scd
> +++ b/doc/aerc-config.5.scd
> @@ -192,9 +192,14 @@ These options are configured in the *[ui]* section of aerc.conf.
>  
>  	Default: 250ms
>  
> +*border-chars*
> +	Vertical and horizontal border characters, in that order.
> +
> +	Default: "  "
> +
>  *stylesets-dirs*
>  	The directories where the stylesets are stored. The config takes a
> -	colon-seperated list of dirs.
> +	colon-separated list of dirs.

This line should not be included in the patch.

Thanks.

[PATCH v2 1/2] style: customize vertical and horizontal border characters

Details
Message ID
<20211129034726.95965-1-dian.m.fay@gmail.com>
In-Reply-To
<CG1OYN8DJ0AJ.2HMMGL6ZSX7NV@diabtop> (view parent)
DKIM signature
pass
Download raw message
Patch: +74 -49
New border-char-horizontal and border-char-vertical config settings in
aerc.conf allow users to modify border appearance from the default
1-wide/tall blank space. In stylesets, border.fg now affects the
foreground color when custom characters are defined.
---
Unfortunately go-ini doesn't seem to be capable of deserializing a rune
directly or this'd be noticeably shorter :(

 config/aerc.conf.in      |  6 +++
 config/config.go         | 93 ++++++++++++++++++++++------------------
 doc/aerc-config.5.scd    |  7 +++
 doc/aerc-stylesets.7.scd |  2 +-
 lib/ui/borders.go        |  9 ++--
 widgets/compose.go       |  2 +-
 widgets/msgviewer.go     |  4 +-
 7 files changed, 74 insertions(+), 49 deletions(-)

diff --git a/config/aerc.conf.in b/config/aerc.conf.in
index 08d1dbc..1f5c87d 100644
--- a/config/aerc.conf.in
+++ b/config/aerc.conf.in
@@ -94,6 +94,12 @@ next-message-on-delete=true
# default: @SHAREDIR@/stylesets/
stylesets-dirs=@SHAREDIR@/stylesets/

# Uncomment to use box-drawing characters for vertical and horizontal borders.
#
# Default: spaces
# border-char-vertical=│
# border-char-horizontal=─

# Sets the styleset to use for the aerc ui elements.
#
# Default: default
diff --git a/config/config.go b/config/config.go
index 9be55c6..1c172c4 100644
--- a/config/config.go
+++ b/config/config.go
@@ -28,31 +28,33 @@ type GeneralConfig struct {
}

type UIConfig struct {
	IndexFormat         string        `ini:"index-format"`
	TimestampFormat     string        `ini:"timestamp-format"`
	ThisDayTimeFormat   string        `ini:"this-day-time-format"`
	ThisWeekTimeFormat  string        `ini:"this-week-time-format"`
	ThisYearTimeFormat  string        `ini:"this-year-time-format"`
	ShowHeaders         []string      `delim:","`
	RenderAccountTabs   string        `ini:"render-account-tabs"`
	PinnedTabMarker     string        `ini:"pinned-tab-marker"`
	SidebarWidth        int           `ini:"sidebar-width"`
	PreviewHeight       int           `ini:"preview-height"`
	EmptyMessage        string        `ini:"empty-message"`
	EmptyDirlist        string        `ini:"empty-dirlist"`
	MouseEnabled        bool          `ini:"mouse-enabled"`
	ThreadingEnabled    bool          `ini:"threading-enabled"`
	NewMessageBell      bool          `ini:"new-message-bell"`
	Spinner             string        `ini:"spinner"`
	SpinnerDelimiter    string        `ini:"spinner-delimiter"`
	DirListFormat       string        `ini:"dirlist-format"`
	Sort                []string      `delim:" "`
	NextMessageOnDelete bool          `ini:"next-message-on-delete"`
	CompletionDelay     time.Duration `ini:"completion-delay"`
	CompletionPopovers  bool          `ini:"completion-popovers"`
	StyleSetDirs        []string      `ini:"stylesets-dirs" delim:":"`
	StyleSetName        string        `ini:"styleset-name"`
	style               StyleSet
	IndexFormat          string        `ini:"index-format"`
	TimestampFormat      string        `ini:"timestamp-format"`
	ThisDayTimeFormat    string        `ini:"this-day-time-format"`
	ThisWeekTimeFormat   string        `ini:"this-week-time-format"`
	ThisYearTimeFormat   string        `ini:"this-year-time-format"`
	ShowHeaders          []string      `delim:","`
	RenderAccountTabs    string        `ini:"render-account-tabs"`
	PinnedTabMarker      string        `ini:"pinned-tab-marker"`
	SidebarWidth         int           `ini:"sidebar-width"`
	PreviewHeight        int           `ini:"preview-height"`
	EmptyMessage         string        `ini:"empty-message"`
	EmptyDirlist         string        `ini:"empty-dirlist"`
	MouseEnabled         bool          `ini:"mouse-enabled"`
	ThreadingEnabled     bool          `ini:"threading-enabled"`
	NewMessageBell       bool          `ini:"new-message-bell"`
	Spinner              string        `ini:"spinner"`
	SpinnerDelimiter     string        `ini:"spinner-delimiter"`
	DirListFormat        string        `ini:"dirlist-format"`
	Sort                 []string      `delim:" "`
	NextMessageOnDelete  bool          `ini:"next-message-on-delete"`
	CompletionDelay      time.Duration `ini:"completion-delay"`
	CompletionPopovers   bool          `ini:"completion-popovers"`
	BorderCharVertical   string        `ini:"border-char-vertical"`
	BorderCharHorizontal string        `ini:"border-char-horizontal"`
	StyleSetDirs         []string      `ini:"stylesets-dirs" delim:":"`
	StyleSetName         string        `ini:"styleset-name"`
	style                StyleSet
}

type ContextType int
@@ -440,6 +442,13 @@ func (config *AercConfig) LoadConfig(file *ini.File) error {
		return err
	}

	if len([]rune(config.Ui.BorderCharVertical)) > 1 {
		return errors.New("border-char-vertical must be one and only one character")
	}
	if len([]rune(config.Ui.BorderCharHorizontal)) > 1 {
		return errors.New("border-char-horizontal must be one and only one character")
	}

	for idx, contextualUi := range config.ContextualUis {
		if contextualUi.UiConfig.StyleSetName == "" &&
			len(contextualUi.UiConfig.StyleSetDirs) == 0 {
@@ -508,22 +517,24 @@ func LoadConfigFromFile(root *string, sharedir string) (*AercConfig, error) {
			ShowHeaders: []string{
				"From", "To", "Cc", "Bcc", "Subject", "Date",
			},
			RenderAccountTabs:   "auto",
			PinnedTabMarker:     "`",
			SidebarWidth:        20,
			PreviewHeight:       12,
			EmptyMessage:        "(no messages)",
			EmptyDirlist:        "(no folders)",
			MouseEnabled:        false,
			NewMessageBell:      true,
			Spinner:             "[..]    , [..]   ,  [..]  ,   [..] ,    [..],   [..] ,  [..]  , [..]   ",
			SpinnerDelimiter:    ",",
			DirListFormat:       "%n %>r",
			NextMessageOnDelete: true,
			CompletionDelay:     250 * time.Millisecond,
			CompletionPopovers:  true,
			StyleSetDirs:        []string{path.Join(sharedir, "stylesets")},
			StyleSetName:        "default",
			RenderAccountTabs:    "auto",
			PinnedTabMarker:      "`",
			SidebarWidth:         20,
			PreviewHeight:        12,
			EmptyMessage:         "(no messages)",
			EmptyDirlist:         "(no folders)",
			MouseEnabled:         false,
			NewMessageBell:       true,
			Spinner:              "[..]    , [..]   ,  [..]  ,   [..] ,    [..],   [..] ,  [..]  , [..]   ",
			SpinnerDelimiter:     ",",
			DirListFormat:        "%n %>r",
			NextMessageOnDelete:  true,
			CompletionDelay:      250 * time.Millisecond,
			CompletionPopovers:   true,
			BorderCharVertical:   " ",
			BorderCharHorizontal: " ",
			StyleSetDirs:         []string{path.Join(sharedir, "stylesets")},
			StyleSetName:         "default",
		},

		ContextualUis: []UIConfigContext{},
diff --git a/doc/aerc-config.5.scd b/doc/aerc-config.5.scd
index 4dbdba3..12e643e 100644
--- a/doc/aerc-config.5.scd
+++ b/doc/aerc-config.5.scd
@@ -192,6 +192,13 @@ These options are configured in the *[ui]* section of aerc.conf.

	Default: 250ms

*border-char-vertical*
*border-char-horizontal*
	Set stylable characters (via the 'border' element) for vertical and
	horizontal borders.

	Default: spaces

*stylesets-dirs*
	The directories where the stylesets are stored. The config takes a
	colon-seperated list of dirs.
diff --git a/doc/aerc-stylesets.7.scd b/doc/aerc-stylesets.7.scd
index ff23aa3..4e1a2b5 100644
--- a/doc/aerc-stylesets.7.scd
+++ b/doc/aerc-stylesets.7.scd
@@ -128,7 +128,7 @@ styling.
|  spinner
:  The style for the loading spinner.
|  border
:  The style used to draw borders. *Only the background color is used*.
:  The style used to draw borders. *Only the background color is used unless you customize border-char-vertical and/or border-char-horizontal in aerc.conf*.
|  selector_default
:  The default style for the selector ui element.
|  selector_focused
diff --git a/lib/ui/borders.go b/lib/ui/borders.go
index 1b69a8e..611318c 100644
--- a/lib/ui/borders.go
+++ b/lib/ui/borders.go
@@ -50,22 +50,23 @@ func (bordered *Bordered) Draw(ctx *Context) {
	width := ctx.Width()
	height := ctx.Height()
	style := bordered.uiConfig.GetStyle(config.STYLE_BORDER)

	if bordered.borders&BORDER_LEFT != 0 {
		ctx.Fill(0, 0, 1, ctx.Height(), ' ', style)
		ctx.Fill(0, 0, 1, ctx.Height(), []rune(bordered.uiConfig.BorderCharVertical)[0], style)
		x += 1
		width -= 1
	}
	if bordered.borders&BORDER_TOP != 0 {
		ctx.Fill(0, 0, ctx.Width(), 1, ' ', style)
		ctx.Fill(0, 0, ctx.Width(), 1, []rune(bordered.uiConfig.BorderCharHorizontal)[0], style)
		y += 1
		height -= 1
	}
	if bordered.borders&BORDER_RIGHT != 0 {
		ctx.Fill(ctx.Width()-1, 0, 1, ctx.Height(), ' ', style)
		ctx.Fill(ctx.Width()-1, 0, 1, ctx.Height(), []rune(bordered.uiConfig.BorderCharVertical)[0], style)
		width -= 1
	}
	if bordered.borders&BORDER_BOTTOM != 0 {
		ctx.Fill(0, ctx.Height()-1, ctx.Width(), 1, ' ', style)
		ctx.Fill(0, ctx.Height()-1, ctx.Width(), 1, []rune(bordered.uiConfig.BorderCharHorizontal)[0], style)
		height -= 1
	}
	subctx := ctx.Subcontext(x, y, width, height)
diff --git a/widgets/compose.go b/widgets/compose.go
index 69a2dcc..13307da 100644
--- a/widgets/compose.go
+++ b/widgets/compose.go
@@ -681,7 +681,7 @@ func (c *Composer) updateGrid() {
	borderStyle := c.config.Ui.GetStyle(config.STYLE_BORDER)
	c.heditors = heditors
	c.grid.AddChild(c.heditors).At(0, 0)
	c.grid.AddChild(ui.NewFill(' ', borderStyle)).At(1, 0)
	c.grid.AddChild(ui.NewFill([]rune(c.config.Ui.BorderCharHorizontal)[0], borderStyle)).At(1, 0)
}

func (c *Composer) reloadEmail() error {
diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go
index fc4529c..bdab48c 100644
--- a/widgets/msgviewer.go
+++ b/widgets/msgviewer.go
@@ -110,10 +110,10 @@ func NewMessageViewer(acct *AccountView,
	grid.AddChild(header).At(0, 0)
	if msg.PGPDetails() != nil {
		grid.AddChild(NewPGPInfo(msg.PGPDetails(), acct.UiConfig())).At(1, 0)
		grid.AddChild(ui.NewFill(' ', borderStyle)).At(2, 0)
		grid.AddChild(ui.NewFill([]rune(acct.UiConfig().BorderCharHorizontal)[0], borderStyle)).At(2, 0)
		grid.AddChild(switcher).At(3, 0)
	} else {
		grid.AddChild(ui.NewFill(' ', borderStyle)).At(1, 0)
		grid.AddChild(ui.NewFill([]rune(acct.UiConfig().BorderCharHorizontal)[0], borderStyle)).At(1, 0)
		grid.AddChild(switcher).At(2, 0)
	}

-- 
2.34.1

[PATCH v2 2/2] doc: fix typo in stylesets-dirs

Details
Message ID
<20211129034726.95965-2-dian.m.fay@gmail.com>
In-Reply-To
<20211129034726.95965-1-dian.m.fay@gmail.com> (view parent)
DKIM signature
pass
Download raw message
Patch: +1 -1
---
 doc/aerc-config.5.scd | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/aerc-config.5.scd b/doc/aerc-config.5.scd
index 12e643e..e95a86c 100644
--- a/doc/aerc-config.5.scd
+++ b/doc/aerc-config.5.scd
@@ -201,7 +201,7 @@ These options are configured in the *[ui]* section of aerc.conf.

*stylesets-dirs*
	The directories where the stylesets are stored. The config takes a
	colon-seperated list of dirs.
	colon-separated list of dirs.

	Default: "/usr/share/aerc/stylesets"

-- 
2.34.1

Re: [PATCH v2 1/2] style: customize vertical and horizontal border characters

Details
Message ID
<CG2J6VJFKTVA.FTJF5ZGYSMKF@diabtop>
In-Reply-To
<20211129034726.95965-1-dian.m.fay@gmail.com> (view parent)
DKIM signature
missing
Download raw message
Dian M Fay, Nov 29, 2021 at 04:47:
> New border-char-horizontal and border-char-vertical config settings in
> aerc.conf allow users to modify border appearance from the default
> 1-wide/tall blank space. In stylesets, border.fg now affects the
> foreground color when custom characters are defined.
> ---
> Unfortunately go-ini doesn't seem to be capable of deserializing a rune
> directly or this'd be noticeably shorter :(

I wonder if we could manually parse the setting and force it to a rune
type in the UIConfig object. It would make it easier to use in the
remaining code.

> diff --git a/config/config.go b/config/config.go
> index 9be55c6..1c172c4 100644
> --- a/config/config.go
> +++ b/config/config.go
> @@ -28,31 +28,33 @@ type GeneralConfig struct {
>  }
>  
>  type UIConfig struct {
> -	IndexFormat         string        `ini:"index-format"`
> -	TimestampFormat     string        `ini:"timestamp-format"`
> -	ThisDayTimeFormat   string        `ini:"this-day-time-format"`
> -	ThisWeekTimeFormat  string        `ini:"this-week-time-format"`
> -	ThisYearTimeFormat  string        `ini:"this-year-time-format"`
> -	ShowHeaders         []string      `delim:","`
> -	RenderAccountTabs   string        `ini:"render-account-tabs"`
> -	PinnedTabMarker     string        `ini:"pinned-tab-marker"`
> -	SidebarWidth        int           `ini:"sidebar-width"`
> -	PreviewHeight       int           `ini:"preview-height"`
> -	EmptyMessage        string        `ini:"empty-message"`
> -	EmptyDirlist        string        `ini:"empty-dirlist"`
> -	MouseEnabled        bool          `ini:"mouse-enabled"`
> -	ThreadingEnabled    bool          `ini:"threading-enabled"`
> -	NewMessageBell      bool          `ini:"new-message-bell"`
> -	Spinner             string        `ini:"spinner"`
> -	SpinnerDelimiter    string        `ini:"spinner-delimiter"`
> -	DirListFormat       string        `ini:"dirlist-format"`
> -	Sort                []string      `delim:" "`
> -	NextMessageOnDelete bool          `ini:"next-message-on-delete"`
> -	CompletionDelay     time.Duration `ini:"completion-delay"`
> -	CompletionPopovers  bool          `ini:"completion-popovers"`
> -	StyleSetDirs        []string      `ini:"stylesets-dirs" delim:":"`
> -	StyleSetName        string        `ini:"styleset-name"`
> -	style               StyleSet
> +	IndexFormat          string        `ini:"index-format"`
> +	TimestampFormat      string        `ini:"timestamp-format"`
> +	ThisDayTimeFormat    string        `ini:"this-day-time-format"`
> +	ThisWeekTimeFormat   string        `ini:"this-week-time-format"`
> +	ThisYearTimeFormat   string        `ini:"this-year-time-format"`
> +	ShowHeaders          []string      `delim:","`
> +	RenderAccountTabs    string        `ini:"render-account-tabs"`
> +	PinnedTabMarker      string        `ini:"pinned-tab-marker"`
> +	SidebarWidth         int           `ini:"sidebar-width"`
> +	PreviewHeight        int           `ini:"preview-height"`
> +	EmptyMessage         string        `ini:"empty-message"`
> +	EmptyDirlist         string        `ini:"empty-dirlist"`
> +	MouseEnabled         bool          `ini:"mouse-enabled"`
> +	ThreadingEnabled     bool          `ini:"threading-enabled"`
> +	NewMessageBell       bool          `ini:"new-message-bell"`
> +	Spinner              string        `ini:"spinner"`
> +	SpinnerDelimiter     string        `ini:"spinner-delimiter"`
> +	DirListFormat        string        `ini:"dirlist-format"`
> +	Sort                 []string      `delim:" "`
> +	NextMessageOnDelete  bool          `ini:"next-message-on-delete"`
> +	CompletionDelay      time.Duration `ini:"completion-delay"`
> +	CompletionPopovers   bool          `ini:"completion-popovers"`
> +	BorderCharVertical   string        `ini:"border-char-vertical"`
> +	BorderCharHorizontal string        `ini:"border-char-horizontal"`
> +	StyleSetDirs         []string      `ini:"stylesets-dirs" delim:":"`
> +	StyleSetName         string        `ini:"styleset-name"`
> +	style                StyleSet

That is very sad that gofmt realigns every field when adding a single
one. This makes patches impossible to read and completely breaks git
blame. Could you add both settings at the end after a commented line to
prevent gofmt from realigning everything?

> @@ -440,6 +442,13 @@ func (config *AercConfig) LoadConfig(file *ini.File) error {
>  		return err
>  	}
>  
> +	if len([]rune(config.Ui.BorderCharVertical)) > 1 {
> +		return errors.New("border-char-vertical must be one and only one character")
> +	}
> +	if len([]rune(config.Ui.BorderCharHorizontal)) > 1 {
> +		return errors.New("border-char-horizontal must be one and only one character")
> +	}
> +

You must also check for min length. In fact, it should be:

    if len(xxx) != 1 {
        return error
    }

> @@ -508,22 +517,24 @@ func LoadConfigFromFile(root *string, sharedir string) (*AercConfig, error) {
>  			ShowHeaders: []string{
>  				"From", "To", "Cc", "Bcc", "Subject", "Date",
>  			},
> -			RenderAccountTabs:   "auto",
> -			PinnedTabMarker:     "`",
> -			SidebarWidth:        20,
> -			PreviewHeight:       12,
> -			EmptyMessage:        "(no messages)",
> -			EmptyDirlist:        "(no folders)",
> -			MouseEnabled:        false,
> -			NewMessageBell:      true,
> -			Spinner:             "[..]    , [..]   ,  [..]  ,   [..] ,    [..],   [..] ,  [..]  , [..]   ",
> -			SpinnerDelimiter:    ",",
> -			DirListFormat:       "%n %>r",
> -			NextMessageOnDelete: true,
> -			CompletionDelay:     250 * time.Millisecond,
> -			CompletionPopovers:  true,
> -			StyleSetDirs:        []string{path.Join(sharedir, "stylesets")},
> -			StyleSetName:        "default",
> +			RenderAccountTabs:    "auto",
> +			PinnedTabMarker:      "`",
> +			SidebarWidth:         20,
> +			PreviewHeight:        12,
> +			EmptyMessage:         "(no messages)",
> +			EmptyDirlist:         "(no folders)",
> +			MouseEnabled:         false,
> +			NewMessageBell:       true,
> +			Spinner:              "[..]    , [..]   ,  [..]  ,   [..] ,    [..],   [..] ,  [..]  , [..]   ",
> +			SpinnerDelimiter:     ",",
> +			DirListFormat:        "%n %>r",
> +			NextMessageOnDelete:  true,
> +			CompletionDelay:      250 * time.Millisecond,
> +			CompletionPopovers:   true,
> +			BorderCharVertical:   " ",
> +			BorderCharHorizontal: " ",
> +			StyleSetDirs:         []string{path.Join(sharedir, "stylesets")},
> +			StyleSetName:         "default",

Same remark about gofmt. Please add both new fields after a commented
line to make a smaller diff.

The rest looks good.

Thanks!

Re: [PATCH v2 2/2] doc: fix typo in stylesets-dirs

Details
Message ID
<CG2J9LRDUO2Z.1IOJV0P5YEWC8@diabtop>
In-Reply-To
<20211129034726.95965-2-dian.m.fay@gmail.com> (view parent)
DKIM signature
missing
Download raw message
Applied on master.

Thanks!

[PATCH v3] style: customize vertical and horizontal border characters

Details
Message ID
<20211129224835.27921-1-dian.m.fay@gmail.com>
In-Reply-To
<CG2J6VJFKTVA.FTJF5ZGYSMKF@diabtop> (view parent)
DKIM signature
pass
Download raw message
Patch: +35 -8
New border-char-horizontal and border-char-vertical config settings in
aerc.conf allow users to modify border appearance from the default
1-wide/tall blank space. In stylesets, border.fg now affects the
foreground color when custom characters are defined.
---
> I wonder if we could manually parse the setting and force it to a rune
> type in the UIConfig object. It would make it easier to use in the
> remaining code.
I did notice https://gowalker.org/gopkg.in/ini.v1#MapToWithMapper while
trying to find something better than the current implementation, but
that appears only to handle keys (e.g. casing style variations) and
won't help changing value types. There's also a recent issue regarding
uint8 parsing: https://github.com/go-ini/ini/issues/302

 config/aerc.conf.in      |  6 ++++++
 config/config.go         | 13 +++++++++++++
 doc/aerc-config.5.scd    |  7 +++++++
 doc/aerc-stylesets.7.scd |  2 +-
 lib/ui/borders.go        |  9 +++++----
 widgets/compose.go       |  2 +-
 widgets/msgviewer.go     |  4 ++--
 7 files changed, 35 insertions(+), 8 deletions(-)

diff --git a/config/aerc.conf.in b/config/aerc.conf.in
index 08d1dbc..1f5c87d 100644
--- a/config/aerc.conf.in
+++ b/config/aerc.conf.in
@@ -94,6 +94,12 @@ next-message-on-delete=true
# default: @SHAREDIR@/stylesets/
stylesets-dirs=@SHAREDIR@/stylesets/

# Uncomment to use box-drawing characters for vertical and horizontal borders.
#
# Default: spaces
# border-char-vertical=│
# border-char-horizontal=─

# Sets the styleset to use for the aerc ui elements.
#
# Default: default
diff --git a/config/config.go b/config/config.go
index 9be55c6..3543c2b 100644
--- a/config/config.go
+++ b/config/config.go
@@ -53,6 +53,9 @@ type UIConfig struct {
	StyleSetDirs        []string      `ini:"stylesets-dirs" delim:":"`
	StyleSetName        string        `ini:"styleset-name"`
	style               StyleSet
	// customize border appearance
	BorderCharVertical   string        `ini:"border-char-vertical"`
	BorderCharHorizontal string        `ini:"border-char-horizontal"`
}

type ContextType int
@@ -440,6 +443,13 @@ func (config *AercConfig) LoadConfig(file *ini.File) error {
		return err
	}

	if len([]rune(config.Ui.BorderCharVertical)) != 1 {
		return errors.New("border-char-vertical must be one and only one character")
	}
	if len([]rune(config.Ui.BorderCharHorizontal)) != 1 {
		return errors.New("border-char-horizontal must be one and only one character")
	}

	for idx, contextualUi := range config.ContextualUis {
		if contextualUi.UiConfig.StyleSetName == "" &&
			len(contextualUi.UiConfig.StyleSetDirs) == 0 {
@@ -524,6 +534,9 @@ func LoadConfigFromFile(root *string, sharedir string) (*AercConfig, error) {
			CompletionPopovers:  true,
			StyleSetDirs:        []string{path.Join(sharedir, "stylesets")},
			StyleSetName:        "default",
			// border defaults
			BorderCharVertical:   " ",
			BorderCharHorizontal: " ",
		},

		ContextualUis: []UIConfigContext{},
diff --git a/doc/aerc-config.5.scd b/doc/aerc-config.5.scd
index f659e60..e95a86c 100644
--- a/doc/aerc-config.5.scd
+++ b/doc/aerc-config.5.scd
@@ -192,6 +192,13 @@ These options are configured in the *[ui]* section of aerc.conf.

	Default: 250ms

*border-char-vertical*
*border-char-horizontal*
	Set stylable characters (via the 'border' element) for vertical and
	horizontal borders.

	Default: spaces

*stylesets-dirs*
	The directories where the stylesets are stored. The config takes a
	colon-separated list of dirs.
diff --git a/doc/aerc-stylesets.7.scd b/doc/aerc-stylesets.7.scd
index ff23aa3..4e1a2b5 100644
--- a/doc/aerc-stylesets.7.scd
+++ b/doc/aerc-stylesets.7.scd
@@ -128,7 +128,7 @@ styling.
|  spinner
:  The style for the loading spinner.
|  border
:  The style used to draw borders. *Only the background color is used*.
:  The style used to draw borders. *Only the background color is used unless you customize border-char-vertical and/or border-char-horizontal in aerc.conf*.
|  selector_default
:  The default style for the selector ui element.
|  selector_focused
diff --git a/lib/ui/borders.go b/lib/ui/borders.go
index 1b69a8e..611318c 100644
--- a/lib/ui/borders.go
+++ b/lib/ui/borders.go
@@ -50,22 +50,23 @@ func (bordered *Bordered) Draw(ctx *Context) {
	width := ctx.Width()
	height := ctx.Height()
	style := bordered.uiConfig.GetStyle(config.STYLE_BORDER)

	if bordered.borders&BORDER_LEFT != 0 {
		ctx.Fill(0, 0, 1, ctx.Height(), ' ', style)
		ctx.Fill(0, 0, 1, ctx.Height(), []rune(bordered.uiConfig.BorderCharVertical)[0], style)
		x += 1
		width -= 1
	}
	if bordered.borders&BORDER_TOP != 0 {
		ctx.Fill(0, 0, ctx.Width(), 1, ' ', style)
		ctx.Fill(0, 0, ctx.Width(), 1, []rune(bordered.uiConfig.BorderCharHorizontal)[0], style)
		y += 1
		height -= 1
	}
	if bordered.borders&BORDER_RIGHT != 0 {
		ctx.Fill(ctx.Width()-1, 0, 1, ctx.Height(), ' ', style)
		ctx.Fill(ctx.Width()-1, 0, 1, ctx.Height(), []rune(bordered.uiConfig.BorderCharVertical)[0], style)
		width -= 1
	}
	if bordered.borders&BORDER_BOTTOM != 0 {
		ctx.Fill(0, ctx.Height()-1, ctx.Width(), 1, ' ', style)
		ctx.Fill(0, ctx.Height()-1, ctx.Width(), 1, []rune(bordered.uiConfig.BorderCharHorizontal)[0], style)
		height -= 1
	}
	subctx := ctx.Subcontext(x, y, width, height)
diff --git a/widgets/compose.go b/widgets/compose.go
index 69a2dcc..13307da 100644
--- a/widgets/compose.go
+++ b/widgets/compose.go
@@ -681,7 +681,7 @@ func (c *Composer) updateGrid() {
	borderStyle := c.config.Ui.GetStyle(config.STYLE_BORDER)
	c.heditors = heditors
	c.grid.AddChild(c.heditors).At(0, 0)
	c.grid.AddChild(ui.NewFill(' ', borderStyle)).At(1, 0)
	c.grid.AddChild(ui.NewFill([]rune(c.config.Ui.BorderCharHorizontal)[0], borderStyle)).At(1, 0)
}

func (c *Composer) reloadEmail() error {
diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go
index fc4529c..bdab48c 100644
--- a/widgets/msgviewer.go
+++ b/widgets/msgviewer.go
@@ -110,10 +110,10 @@ func NewMessageViewer(acct *AccountView,
	grid.AddChild(header).At(0, 0)
	if msg.PGPDetails() != nil {
		grid.AddChild(NewPGPInfo(msg.PGPDetails(), acct.UiConfig())).At(1, 0)
		grid.AddChild(ui.NewFill(' ', borderStyle)).At(2, 0)
		grid.AddChild(ui.NewFill([]rune(acct.UiConfig().BorderCharHorizontal)[0], borderStyle)).At(2, 0)
		grid.AddChild(switcher).At(3, 0)
	} else {
		grid.AddChild(ui.NewFill(' ', borderStyle)).At(1, 0)
		grid.AddChild(ui.NewFill([]rune(acct.UiConfig().BorderCharHorizontal)[0], borderStyle)).At(1, 0)
		grid.AddChild(switcher).At(2, 0)
	}

-- 
2.34.1

Re: [PATCH v3] style: customize vertical and horizontal border characters

Details
Message ID
<CG36OM6PSS60.31BTAT7Y1K0M0@diabtop>
In-Reply-To
<20211129224835.27921-1-dian.m.fay@gmail.com> (view parent)
DKIM signature
missing
Download raw message
Dian M Fay, Nov 29, 2021 at 23:48:
> New border-char-horizontal and border-char-vertical config settings in
> aerc.conf allow users to modify border appearance from the default
> 1-wide/tall blank space. In stylesets, border.fg now affects the
> foreground color when custom characters are defined.
> ---
> > I wonder if we could manually parse the setting and force it to a rune
> > type in the UIConfig object. It would make it easier to use in the
> > remaining code.
> I did notice https://gowalker.org/gopkg.in/ini.v1#MapToWithMapper while
> trying to find something better than the current implementation, but
> that appears only to handle keys (e.g. casing style variations) and
> won't help changing value types. There's also a recent issue regarding
> uint8 parsing: https://github.com/go-ini/ini/issues/302

I changed a few things and applied on master.

To git.sr.ht:~rjarry/aerc
   ad5f65b92788..f776fb82469d  f776fb82469d -> master

Thanks!
Reply to thread Export thread (mbox)