1
1
mirror of https://github.com/walles/moar.git synced 2024-09-11 12:15:43 +03:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Johan Walles
e68547a413 Make line numbers easier to read 2024-08-13 07:00:32 +02:00
Johan Walles
c379459982 Add a regression test
For: https://github.com/walles/moar/issues/236#issuecomment-2282677792
2024-08-13 06:56:16 +02:00
3 changed files with 34 additions and 4 deletions

View File

@ -219,6 +219,24 @@ func TestCodeHighlight_compressed(t *testing.T) {
}
}
// Regression test for:
// https://github.com/walles/moar/issues/236#issuecomment-2282677792
//
// Sample file sysctl.h from:
// https://github.com/fastfetch-cli/fastfetch/blob/f9597eba39d6afd278eeca2f2972f73a7e54f111/src/common/sysctl.h
func TestCodeHighlightingIncludes(t *testing.T) {
reader, err := NewReaderFromFilename("../sample-files/sysctl.h", *styles.Get("native"), formatters.TTY16m, nil)
assert.NilError(t, err)
assert.NilError(t, reader._wait())
screen := startPaging(t, reader)
firstIncludeLine := screen.GetRow(2)
secondIncludeLine := screen.GetRow(3)
// Both should start with "#include" colored the same way
assertCellsEqual(t, firstIncludeLine[0], secondIncludeLine[0])
}
func TestUnicodePrivateUse(t *testing.T) {
// This character lives in a Private Use Area:
// https://codepoints.net/U+f244

View File

@ -119,10 +119,10 @@ func styleUI(chromaStyle *chroma.Style, chromaFormatter *chroma.Formatter, statu
chromaLineNumbers := twinStyleFromChroma(chromaStyle, chromaFormatter, chroma.LineNumbers, true)
if chromaLineNumbers != nil {
// If somebody can provide an example where not-dimmed line numbers
// looks good I'll change this, but until then they will be dimmed no
// matter what the theme authors think.
lineNumbersStyle = chromaLineNumbers.WithAttr(twin.AttrDim)
// NOTE: We used to dim line numbers here, but Johan found them too hard
// to read. If line numbers should look some other way for some Chroma
// style, go fix that in Chroma!
lineNumbersStyle = *chromaLineNumbers
}
if standoutStyle != nil {

12
sample-files/sysctl.h Normal file
View File

@ -0,0 +1,12 @@
#pragma once
#include "fastfetch.h"
#include "util/FFcheckmacros.h"
#include <sys/types.h>
#include <sys/sysctl.h>
const char* ffSysctlGetString(const char* propName, FFstrbuf* result);
FF_C_NODISCARD int ffSysctlGetInt(const char* propName, int defaultValue);
FF_C_NODISCARD int64_t ffSysctlGetInt64(const char* propName, int64_t defaultValue);
FF_C_NODISCARD void* ffSysctlGetData(int* request, u_int requestLength, size_t* resultLength);