From 157646f54cd010c8c884998319954006260f960e Mon Sep 17 00:00:00 2001 From: NRK Date: Fri, 10 Feb 2023 11:51:53 +0600 Subject: etc changes related to code-style docs * Add a "Code Style" section in CONTRIBUTING * Move .clang-format to etc/ * Add a short comment on clang-format and editorconfig file --- etc/.clang-format | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++ etc/CONTRIBUTING.md | 17 ++++++++++- 2 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 etc/.clang-format (limited to 'etc') diff --git a/etc/.clang-format b/etc/.clang-format new file mode 100644 index 0000000..a29be62 --- /dev/null +++ b/etc/.clang-format @@ -0,0 +1,82 @@ +# clang-format doesn't dictate the project's code style and can mess up a +# couple edge cases. However it comes quite close and can be used for fixing +# most style issues automatically on new changes via `git-clang-format`. +--- + +Standard: c++03 + +ColumnLimit: 0 + +AccessModifierOffset: -8 +ConstructorInitializerIndentWidth: 8 +ContinuationIndentWidth: 8 +IndentCaseLabels: false +IndentGotoLabels: false +IndentPPDirectives: None +IndentWidth: 8 +IndentWrappedFunctionNames: false +NamespaceIndentation: None +TabWidth: 8 +UseTab: AlignWithSpaces + +AlignAfterOpenBracket: true +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: false +AlignOperands: true +AlignTrailingComments: false +DerivePointerAlignment: true +PointerAlignment: true + +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: true +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false + +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: false + +BinPackArguments: true +BinPackParameters: true + +BreakBeforeBraces: Custom +BraceWrapping: + AfterControlStatement: MultiLine + AfterEnum: false + AfterExternBlock: false + AfterFunction: true + AfterStruct: false + AfterUnion: false + BeforeElse: false + IndentBraces: false + SplitEmptyFunction: true + +BreakBeforeBinaryOperators: None +BreakBeforeInheritanceComma: false +BreakBeforeTernaryOperators: false +BreakConstructorInitializers: BeforeComma +BreakConstructorInitializersBeforeComma: false +BreakStringLiterals: true + +Cpp11BracedListStyle: false +MaxEmptyLinesToKeep: 1 + +ReflowComments: false + +SortIncludes: true + +SpaceAfterCStyleCast: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false + +... diff --git a/etc/CONTRIBUTING.md b/etc/CONTRIBUTING.md index 8d9680f..aa96068 100644 --- a/etc/CONTRIBUTING.md +++ b/etc/CONTRIBUTING.md @@ -23,7 +23,7 @@ Contribution Guideline When contributing, make sure: * Your contribution falls under nsxiv's scope and aim - * You follow the existing code style (see [.editorconfig](../.editorconfig)) + * You follow the existing code style (see the "Code Style" section below) * You open the pull request from a new branch, not from master * To avoid using force pushes, especially for bigger patches. Only use them when there's merge conflicts. @@ -44,6 +44,21 @@ to work on. You can also filter the issues via label: (Intermediate/Experienced) Issues where we require some help. +Code Style +---------- + +`nsxiv` mostly follows the [suckless code-style][sl], with a few exceptions. +If your editor supports [.editorconfig](../.editorconfig) then you'll already be +off to a good start without needing much manual intervention. Additionally we +provide a [clang-format](./.clang-format) configuration for reference, which you +may use via [`git-clang-format`][cf] to format the changes you've made (please +do not run it globally on the entire code-base since clang-format gets a decent +amount of edge cases wrong). + +[sl]: https://suckless.org/coding_style/ +[cf]: https://clang.llvm.org/docs/ClangFormat.html#git-integration + + Development workflow for maintainers ------------------------------------ -- cgit v1.2.3 From 502b30301c1c178748c221076f3f06f817956880 Mon Sep 17 00:00:00 2001 From: NRK Date: Fri, 17 Mar 2023 07:58:02 +0600 Subject: document handling of empty X resources values since 5cab2fb we reject empty X resources value to support use-cases like this: https://codeberg.org/nsxiv/nsxiv/issues/339 this issue was also bought up by GRFreire in: https://codeberg.org/nsxiv/nsxiv-record/pulls/115#issuecomment-474831 this suggests that this is a use-case that a decent amount of users might be interested in. so document the behavior so it's more easily visible. --- etc/nsxiv.1 | 3 +++ 1 file changed, 3 insertions(+) (limited to 'etc') diff --git a/etc/nsxiv.1 b/etc/nsxiv.1 index d601e5c..a75a0a0 100644 --- a/etc/nsxiv.1 +++ b/etc/nsxiv.1 @@ -457,6 +457,9 @@ Color of the bar foreground. Defaults to window.foreground Color of the mark foreground. Defaults to window.foreground .TP Please see xrdb(1) on how to change them. +.LP +An X resources entry with an empty value means the default +(defined in config.h) will be used. .SH WINDOW TITLE The window title can be replaced with the output of a user-provided script, which is called by nsxiv whenever any of the relevant information changes. -- cgit v1.2.3 From 54bfc5db042960a196e8aa291971160d36bd80f2 Mon Sep 17 00:00:00 2001 From: NRK Date: Fri, 17 Mar 2023 08:13:31 +0600 Subject: fix a typpo in CHANGELOG.md --- etc/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'etc') diff --git a/etc/CHANGELOG.md b/etc/CHANGELOG.md index aefb36f..5ea1259 100644 --- a/etc/CHANGELOG.md +++ b/etc/CHANGELOG.md @@ -116,7 +116,7 @@ references *above* can be found on the new main nsxiv repository on CodeBerg. * Changes: - * Window title is now customizeable via `win-title`, cli flag `-T` and related + * Window title is now customizable via `win-title`, cli flag `-T` and related config.h options are removed. See `WINDOW TITLE` section of the manpage for more info. [#213] * Imlib2 cache size is now set based on total memory percentage, by default -- cgit v1.2.3 From 733916ad70b5b2d92e7adfecdf53a74dd4617b74 Mon Sep 17 00:00:00 2001 From: eylles Date: Fri, 14 Apr 2023 19:45:39 +0000 Subject: add a pick quit keybind (#432) The last time[0] this was discussed, no-one was against it but no-one was confident in it either and so it was added to nsxiv-extra as a patch. But now that enough time has passed, it seems like there's a pretty high demand for something like this because there's plenty of use-cases that use nsxiv as a "picker" where it's meant to quickly pick a single file. And so add this as a convenient default key-bind. [0]: https://codeberg.org/nsxiv/nsxiv-record/pulls/42 Co-authored-by: eylles Co-authored-by: NRK Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/432 Reviewed-by: NRK Co-authored-by: eylles Co-committed-by: eylles --- commands.c | 7 +++++++ commands.h | 2 ++ config.def.h | 1 + etc/nsxiv.1 | 4 ++++ 4 files changed, 14 insertions(+) (limited to 'etc') diff --git a/commands.c b/commands.c index 7c44ace..97cadf2 100644 --- a/commands.c +++ b/commands.c @@ -59,6 +59,13 @@ bool cg_quit(arg_t status) return None; /* silence tcc warning */ } +bool cg_pick_quit(arg_t status) +{ + if (options->to_stdout && markcnt == 0) + printf("%s%c", files[fileidx].name, options->using_null ? '\0' : '\n'); + return cg_quit(status); +} + bool cg_switch_mode(arg_t _) { if (mode == MODE_IMAGE) { diff --git a/commands.h b/commands.h index 76b1330..4e694f0 100644 --- a/commands.h +++ b/commands.h @@ -12,6 +12,7 @@ bool cg_n_or_last(arg_t); bool cg_navigate_marked(arg_t); bool cg_prefix_external(arg_t); bool cg_quit(arg_t); +bool cg_pick_quit(arg_t); bool cg_reload_image(arg_t); bool cg_remove_image(arg_t); bool cg_reverse_marks(arg_t); @@ -57,6 +58,7 @@ bool ct_select(arg_t); #define g_navigate_marked { cg_navigate_marked, MODE_ALL } #define g_prefix_external { cg_prefix_external, MODE_ALL } #define g_quit { cg_quit, MODE_ALL } +#define g_pick_quit { cg_pick_quit, MODE_ALL } #define g_reload_image { cg_reload_image, MODE_ALL } #define g_remove_image { cg_remove_image, MODE_ALL } #define g_reverse_marks { cg_reverse_marks, MODE_ALL } diff --git a/config.def.h b/config.def.h index a0935f6..5d4e97a 100644 --- a/config.def.h +++ b/config.def.h @@ -92,6 +92,7 @@ static const KeySym KEYHANDLER_ABORT = XK_Escape; static const keymap_t keys[] = { /* modifiers key function argument */ { 0, XK_q, g_quit, 0 }, + { 0, XK_Q, g_pick_quit, 0 }, { 0, XK_Return, g_switch_mode, None }, { 0, XK_f, g_toggle_fullscreen, None }, { 0, XK_b, g_toggle_bar, None }, diff --git a/etc/nsxiv.1 b/etc/nsxiv.1 index a75a0a0..10f131a 100644 --- a/etc/nsxiv.1 +++ b/etc/nsxiv.1 @@ -135,6 +135,10 @@ Prefix the next command with a number (denoted via .B q Quit nsxiv. .TP +.B Q +Quit nsxiv, but additionally print the current filename when \-o is active and +no files have been marked. +.TP .B Return Switch to thumbnail mode / open selected image in image mode. .TP -- cgit v1.2.3 From 5c6745436fcaca6e92b1a36a4add5aa15d17e164 Mon Sep 17 00:00:00 2001 From: NRK Date: Sat, 13 May 2023 23:28:27 +0600 Subject: [ci]: silence false positive warning clang-tidy currently flags the following: util.c:57:8: error: 'ptr' may be set to null if 'realloc' fails, which may result in a leak of the original buffer [bugprone-suspicious-realloc-usage,-warnings-as-errors] ptr = realloc(ptr, size); the analysis here is correct, but if realloc fails, we simply exit so there's no real "leak". moreover this check is not very useful for nsxiv's codebase because we do not use naked realloc(), instead we use the erealloc wrapper that exits on failure. so just disable the warning entirely instead of changing the source code to silence the false positive. --- etc/woodpecker/clang-tidy-checks | 1 + 1 file changed, 1 insertion(+) (limited to 'etc') diff --git a/etc/woodpecker/clang-tidy-checks b/etc/woodpecker/clang-tidy-checks index 0cc2693..edf0ba6 100644 --- a/etc/woodpecker/clang-tidy-checks +++ b/etc/woodpecker/clang-tidy-checks @@ -9,6 +9,7 @@ misc-*,android-cloexec-*,llvm-include-order -bugprone-implicit-widening-of-multiplication-result,-bugprone-integer-division -android-cloexec-fopen,-android-cloexec-pipe,-cert-err33-c -bugprone-assignment-in-if-condition +-bugprone-suspicious-realloc-usage # false positive warnings -clang-analyzer-valist.Uninitialized -- cgit v1.2.3 From c03ec39437b473526080f496d6c8564e98bea1d7 Mon Sep 17 00:00:00 2001 From: NRK Date: Sun, 28 May 2023 06:49:07 +0000 Subject: update documentation (#448) the fedora copr repo is no longer being updated since the maintainer of it, mamg22, no longer uses nsxiv in his daily setup (and thus stopped contributing to nsxiv as well). he has requested the repo and his email to be removed from the project. so go ahead and honor that request. also take this as an opportunity to remove some long inactive maintainers from the CURRENT MAINTAINERS section of the manpage. Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/448 Reviewed-by: explosion-mental --- README.md | 4 ---- etc/nsxiv.1 | 5 ----- 2 files changed, 9 deletions(-) (limited to 'etc') diff --git a/README.md b/README.md index bc303d4..70376d7 100644 --- a/README.md +++ b/README.md @@ -58,10 +58,6 @@ nsxiv is available on the following distributions/repositories. If you don't see your distro listed here, either contact your distro's package maintainer or consider packaging it yourself and adding it to the respective community repo. -Repos not tracked by repology: - -* Fedora: Enable the copr repo via `dnf copr enable mamg22/nsxiv`. - Dependencies ------------ diff --git a/etc/nsxiv.1 b/etc/nsxiv.1 index 10f131a..e2fb4c8 100644 --- a/etc/nsxiv.1 +++ b/etc/nsxiv.1 @@ -569,11 +569,6 @@ TAAPArthur eylles Stein Gunnar Bakkeby explosion-mental -mamg22 -LuXu -Guilherme Freire -Sam Whitehead -Kian Kasad .EE .SH CONTRIBUTORS .EX -- cgit v1.2.3