Skip to content

Commit 9c88f56

Browse files
Merge branch 'MoreCharOptions' into dev
2 parents 293f0e6 + f2c18b2 commit 9c88f56

File tree

4 files changed

+46
-17
lines changed

4 files changed

+46
-17
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,14 @@
99
> - [Add wrapindent option to allow wrapping and hanging indents #3107](https://github.com/zyedidia/micro/pull/3107)
1010
> - [add next/prev split/tab support for terminal pane #3165](https://github.com/zyedidia/micro/pull/3165)
1111
> - [Escape braces that are in string or comments when finding matching brace #3372](https://github.com/zyedidia/micro/pull/3372)
12-
> - [Exposing replacement functions for deprecated IOUtil functions #3393](https://github.com/zyedidia/micro/pull/3393)
1312
> - [Adding timeout when fetching plugin & more clear plugin error message #3389](https://github.com/zyedidia/micro/pull/3389)
1413
> - [Adding Jumping to opening and closing brace logic and actions #3384](https://github.com/zyedidia/micro/pull/3384)
1514
> - [Adding auto complete support for multi cursors #3442](https://github.com/zyedidia/micro/pull/3442)
1615
> - [Fixing comment plugin not using user settings when overriding default setting #3424](https://github.com/zyedidia/micro/pull/3424)
1716
> - [Add the ability lock settings.json and bindings.json for plugins #3618](https://github.com/zyedidia/micro/pull/3618)
1817
> - [Adding error screen for lua functions running in status line #3691](https://github.com/zyedidia/micro/pull/3691)
1918
> - [Adding lua function to use result of RunBackgroundShell #3692](https://github.com/zyedidia/micro/pull/3692)
20-
> - [Fix unable to perform proportional resize caused by chained parents after quiting a nested HSplit inside a VSplit #3708](https://github.com/zyedidia/micro/pull/3708)
19+
> - [Adding indenttabchar, indentspacechar and spacechar options #3760](https://github.com/zyedidia/micro/pull/3760)
2120
>
2221
> To see the diff between this and upstream master, click [here](https://github.com/zyedidia/micro/compare/master...Neko-Box-Coder:micro-dev:dev)
2322

internal/config/settings.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ var defaultCommonSettings = map[string]interface{}{
7070
"hltrailingws": false,
7171
"ignorecase": true,
7272
"incsearch": true,
73-
"indentchar": " ",
73+
"indenttabchar": " ",
74+
"indentspacechar": " ",
75+
"spacechar": " ",
7476
"keepautoindent": false,
7577
"matchbrace": true,
7678
"matchbraceleft": true,
@@ -213,6 +215,13 @@ func validateParsedSettings() error {
213215
}
214216
continue
215217
}
218+
219+
if k == "indentchar" {
220+
// migrate to "indenttabchar" from "indentchar"
221+
parsedSettings["indenttabchar"] = v
222+
err = errors.New("indentchar has been deprecated, use indenttabchar instead")
223+
}
224+
216225
if _, ok := defaults[k]; ok {
217226
if e := verifySetting(k, v, defaults[k]); e != nil {
218227
err = e

internal/display/bufwindow.go

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ func (w *BufWindow) displayBuffer() {
495495
}
496496
bloc.X = bslice
497497

498-
draw := func(r rune, combc []rune, style tcell.Style, highlight bool, showcursor bool) {
498+
draw := func(r rune, combc []rune, validrune bool, style tcell.Style, highlight bool, showcursor bool) {
499499
if nColsBeforeStart <= 0 && vloc.Y >= 0 {
500500
if highlight {
501501
if w.Buf.HighlightSearch && w.Buf.SearchMatch(bloc) {
@@ -572,9 +572,20 @@ func (w *BufWindow) displayBuffer() {
572572
}
573573
}
574574

575-
if r == '\t' {
576-
indentrunes := []rune(b.Settings["indentchar"].(string))
577-
// if empty indentchar settings, use space
575+
if r == '\t' || (r == ' ' && bloc.X < blineLen && validrune) {
576+
var indentrunes []rune
577+
switch r {
578+
case '\t':
579+
indentrunes = []rune(b.Settings["indenttabchar"].(string))
580+
case ' ':
581+
if bloc.X%tabsize == 0 && bloc.X < leadingwsEnd {
582+
indentrunes = []rune(b.Settings["indentspacechar"].(string))
583+
} else {
584+
indentrunes = []rune(b.Settings["spacechar"].(string))
585+
}
586+
}
587+
588+
// if no override for current character, use space
578589
if len(indentrunes) == 0 {
579590
indentrunes = []rune{' '}
580591
}
@@ -693,7 +704,7 @@ func (w *BufWindow) displayBuffer() {
693704
// If a word (or just a wide rune) does not fit in the window
694705
if vloc.X+wordwidth > maxWidth && vloc.X > w.gutterOffset {
695706
for vloc.X < maxWidth {
696-
draw(' ', nil, config.DefStyle, false, false)
707+
draw(' ', nil, false, config.DefStyle, false, false)
697708
}
698709

699710
// We either stop or we wrap to draw the word in the next line
@@ -717,7 +728,7 @@ func (w *BufWindow) displayBuffer() {
717728
}
718729

719730
for _, r := range word {
720-
draw(r.r, r.combc, r.style, true, true)
731+
draw(r.r, r.combc, true, r.style, true, true)
721732

722733
// Draw any extra characters either spaces for tabs or @ for incomplete wide runes
723734
if r.width > 1 {
@@ -727,7 +738,7 @@ func (w *BufWindow) displayBuffer() {
727738
}
728739

729740
for i := 1; i < r.width; i++ {
730-
draw(char, nil, r.style, true, false)
741+
draw(char, nil, false, r.style, true, false)
731742
}
732743
}
733744
bloc.X++
@@ -781,7 +792,7 @@ func (w *BufWindow) displayBuffer() {
781792

782793
if vloc.X != maxWidth {
783794
// Display newline within a selection
784-
draw(' ', nil, config.DefStyle, true, true)
795+
draw(' ', nil, false, config.DefStyle, true, true)
785796
}
786797

787798
bloc.X = w.StartCol

runtime/help/options.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,22 @@ Here are the available options:
203203

204204
default value: `true`
205205

206-
* `indentchar`: sets the indentation character. This will not be inserted into
207-
files; it is only a visual indicator that whitespace is present. If set to a
208-
printing character, it functions as a subset of the "show invisibles"
209-
setting available in many other text editors. The color of this character is
210-
determined by the `indent-char` field in the current theme rather than the
211-
default text color.
206+
* `indenttabchar`: sets the indentation character for tabs. This will not be
207+
inserted into files; it is only a visual indicator that whitespace is present.
208+
If set to a printing character, it functions as a subset of the
209+
"show invisibles" setting available in many other text editors. The color of
210+
this character is determined by the `indent-char` field in the current theme
211+
rather than the default text color.
212+
213+
default value: ` ` (space)
214+
215+
* `indentspacechar`: same as `indenttabchar` except for spaces that are at
216+
locations that are divisible by `tabsize`.
217+
218+
default value: ` ` (space)
219+
220+
* `spacechar`: same as `indenttabchar` but for all spaces. `indentspacechar`
221+
takes precedence over this option.
212222

213223
default value: ` ` (space)
214224

0 commit comments

Comments
 (0)