From b94d010c61ba46474af78536873db89492b251a4 Mon Sep 17 00:00:00 2001 From: Evgeni Chasnovski Date: Fri, 20 Oct 2023 10:25:48 +0300 Subject: [PATCH] (mini.colors) Update `interactive()` content with examples. Details: - Resolves #511. --- doc/mini-colors.txt | 2 +- lua/mini/colors.lua | 10 +++- ...ts-test_colors.lua---interactive()---works | 52 +++++++++++++------ ...est_colors.lua---interactive()---works-002 | 52 +++++++++++++------ tests/test_colors.lua | 12 +++-- 5 files changed, 89 insertions(+), 39 deletions(-) diff --git a/doc/mini-colors.txt b/doc/mini-colors.txt index 48d93dbe..0b39143c 100644 --- a/doc/mini-colors.txt +++ b/doc/mini-colors.txt @@ -113,7 +113,7 @@ To apply single method to current color scheme, use > Recipes: - Tweak lightness: > - -- Invert to dark/light color scheme to be light/dark + -- Invert dark/light color scheme to be light/dark chan_invert('lightness', { gamut_clip = 'cusp' }) -- Ensure constant contrast ratio diff --git a/lua/mini/colors.lua b/lua/mini/colors.lua index e88c774a..020de2ed 100644 --- a/lua/mini/colors.lua +++ b/lua/mini/colors.lua @@ -111,7 +111,7 @@ --- Recipes: --- - Tweak lightness: > --- ---- -- Invert to dark/light color scheme to be light/dark +--- -- Invert dark/light color scheme to be light/dark --- chan_invert('lightness', { gamut_clip = 'cusp' }) --- --- -- Ensure constant contrast ratio @@ -830,6 +830,14 @@ MiniColors.interactive = function(opts) '-- Reset: ' .. maps.Reset, '-- Quit: ' .. maps.Quit, '-- Write: ' .. maps.Write, + '--', + '-- Examples:', + '--', + '-- Invert dark/light color scheme to be light/dark', + "-- chan_invert('lightness', { gamut_clip = 'cusp' })", + '--', + '-- Make foreground text more saturated', + "-- chan_add('saturation', 20, { filter = 'fg' })", '', '', } diff --git a/tests/screenshots/tests-test_colors.lua---interactive()---works b/tests/screenshots/tests-test_colors.lua---interactive()---works index 9fb38d15..a7d8d3cc 100644 --- a/tests/screenshots/tests-test_colors.lua---interactive()---works +++ b/tests/screenshots/tests-test_colors.lua---interactive()---works @@ -11,14 +11,24 @@ 10|-- Reset: 11|-- Quit: 12|-- Write: -13| -14| -15|~ -16|~ -17|[Scratch] 14,0-1 All -18| -19| -20| +13|-- +14|-- Examples: +15|-- +16|-- Invert dark/light color scheme to be light/dark +17|-- chan_invert('lightness', { gamut_clip = 'cusp' }) +18|-- +19|-- Make foreground text more saturated +20|-- chan_add('saturation', 20, { filter = 'fg' }) +21| +22| +23|~ +24|~ +25|~ +26|~ +27|[Scratch] 22,0-1 All +28| +29| +30| --|---------|---------|---------|---------|---------|---------| 01|000000000000000000000000000000000000000000000000000111111111 @@ -33,11 +43,21 @@ 10|000000000000000001111111111111111111111111111111111111111111 11|000000000000000001111111111111111111111111111111111111111111 12|000000000000000001111111111111111111111111111111111111111111 -13|111111111111111111111111111111111111111111111111111111111111 -14|111111111111111111111111111111111111111111111111111111111111 -15|222222222222222222222222222222222222222222222222222222222222 -16|222222222222222222222222222222222222222222222222222222222222 -17|333333333333333333333333333333333333333333333333333333333333 -18|444444444444444444444444444444444444444444444444444444444444 -19|111111111111111111111111111111111111111111111111111111111111 -20|111111111111111111111111111111111111111111111111111111111111 +13|001111111111111111111111111111111111111111111111111111111111 +14|000000000000111111111111111111111111111111111111111111111111 +15|001111111111111111111111111111111111111111111111111111111111 +16|000000000000000000000000000000000000000000000000001111111111 +17|000000000000000000000000000000000000000000000000000011111111 +18|001111111111111111111111111111111111111111111111111111111111 +19|000000000000000000000000000000000000001111111111111111111111 +20|000000000000000000000000000000000000000000000000011111111111 +21|111111111111111111111111111111111111111111111111111111111111 +22|111111111111111111111111111111111111111111111111111111111111 +23|222222222222222222222222222222222222222222222222222222222222 +24|222222222222222222222222222222222222222222222222222222222222 +25|222222222222222222222222222222222222222222222222222222222222 +26|222222222222222222222222222222222222222222222222222222222222 +27|333333333333333333333333333333333333333333333333333333333333 +28|444444444444444444444444444444444444444444444444444444444444 +29|111111111111111111111111111111111111111111111111111111111111 +30|111111111111111111111111111111111111111111111111111111111111 diff --git a/tests/screenshots/tests-test_colors.lua---interactive()---works-002 b/tests/screenshots/tests-test_colors.lua---interactive()---works-002 index 14edbce5..b708cf4a 100644 --- a/tests/screenshots/tests-test_colors.lua---interactive()---works-002 +++ b/tests/screenshots/tests-test_colors.lua---interactive()---works-002 @@ -11,14 +11,24 @@ 10|-- Reset: 11|-- Quit: 12|-- Write: -13| -14|chan_invert('lightness') -15|~ -16|~ -17|[Scratch] 14,24 All -18|Write to 'colors/' of your config under this name: test_inte -19|ractive -20| +13|-- +14|-- Examples: +15|-- +16|-- Invert dark/light color scheme to be light/dark +17|-- chan_invert('lightness', { gamut_clip = 'cusp' }) +18|-- +19|-- Make foreground text more saturated +20|-- chan_add('saturation', 20, { filter = 'fg' }) +21| +22|chan_invert('lightness') +23|~ +24|~ +25|~ +26|~ +27|[Scratch] 22,24 All +28|Write to 'colors/' of your config under this name: test_inte +29|ractive +30| --|---------|---------|---------|---------|---------|---------| 01|000000000000000000000000000000000000000000000000000111111111 @@ -33,11 +43,21 @@ 10|000000000000000001111111111111111111111111111111111111111111 11|000000000000000001111111111111111111111111111111111111111111 12|000000000000000001111111111111111111111111111111111111111111 -13|111111111111111111111111111111111111111111111111111111111111 -14|111111111112333333333332111111111111111111111111111111111111 -15|444444444444444444444444444444444444444444444444444444444444 -16|444444444444444444444444444444444444444444444444444444444444 -17|555555555555555555555555555555555555555555555555555555555555 -18|666666666666666666666666666666666666666666666666666666666666 -19|666666666666666666666666666666666666666666666666666666666666 -20|666666666666666666666666666666666666666666666666666666666666 +13|001111111111111111111111111111111111111111111111111111111111 +14|000000000000111111111111111111111111111111111111111111111111 +15|001111111111111111111111111111111111111111111111111111111111 +16|000000000000000000000000000000000000000000000000001111111111 +17|000000000000000000000000000000000000000000000000000011111111 +18|001111111111111111111111111111111111111111111111111111111111 +19|000000000000000000000000000000000000001111111111111111111111 +20|000000000000000000000000000000000000000000000000011111111111 +21|111111111111111111111111111111111111111111111111111111111111 +22|111111111112333333333332111111111111111111111111111111111111 +23|444444444444444444444444444444444444444444444444444444444444 +24|444444444444444444444444444444444444444444444444444444444444 +25|444444444444444444444444444444444444444444444444444444444444 +26|444444444444444444444444444444444444444444444444444444444444 +27|555555555555555555555555555555555555555555555555555555555555 +28|666666666666666666666666666666666666666666666666666666666666 +29|666666666666666666666666666666666666666666666666666666666666 +30|666666666666666666666666666666666666666666666666666666666666 diff --git a/tests/test_colors.lua b/tests/test_colors.lua index 29227f8b..b9eccaea 100644 --- a/tests/test_colors.lua +++ b/tests/test_colors.lua @@ -2267,9 +2267,11 @@ T['interactive()']['works'] = function() -- Check screenshots only on Neovim>=0.9 as there are slight differences in -- highlighting - local check_screenshot = child.fn.has('nvim-0.9') == 1 + local expect_screenshot = function() + if child.fn.has('nvim-0.9') == 1 then child.expect_screenshot() end + end - child.set_size(20, 60) + child.set_size(30, 60) child.o.cmdheight = 3 child.g.colors_name = 'test_interactive' @@ -2278,10 +2280,10 @@ T['interactive()']['works'] = function() child.lua('MiniColors.interactive()') -- General data - if check_screenshot then child.expect_screenshot() end + expect_screenshot() eq(child.bo.filetype, 'lua') - eq(child.get_cursor(), { 14, 0 }) + eq(child.get_cursor(), { 22, 0 }) eq(child.api.nvim_get_mode().mode, 'n') -- Applying transformations using direct calls to methods @@ -2292,7 +2294,7 @@ T['interactive()']['works'] = function() -- Writing -- - Write type_keys('') - if check_screenshot then child.expect_screenshot() end + expect_screenshot() type_keys('new_cs') -- - Verify -- knotmirror 0.0.1