Replace all tabs with spaces for consistency

This commit is contained in:
Isaiah Odhner 2024-01-11 20:14:43 -05:00
parent 2f5d708f4e
commit 4375c518e4
6 changed files with 415 additions and 415 deletions

10
.gitattributes vendored
View File

@ -25,13 +25,13 @@
*.dbproj merge=union *.dbproj merge=union
# Standard to msysgit # Standard to msysgit
*.doc diff=astextplain *.doc diff=astextplain
*.DOC diff=astextplain *.DOC diff=astextplain
*.docx diff=astextplain *.docx diff=astextplain
*.DOCX diff=astextplain *.DOCX diff=astextplain
*.dot diff=astextplain *.dot diff=astextplain
*.DOT diff=astextplain *.DOT diff=astextplain
*.pdf diff=astextplain *.pdf diff=astextplain
*.PDF diff=astextplain *.PDF diff=astextplain
*.rtf diff=astextplain *.rtf diff=astextplain
*.RTF diff=astextplain *.RTF diff=astextplain

108
.vscode/launch.json vendored
View File

@ -1,63 +1,63 @@
{ {
// Use IntelliSense to learn about possible attributes. // Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes. // Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{ {
"name": "Run Textual App", "name": "Run Textual App",
"type": "python", "type": "python",
"request": "launch", "request": "launch",
// TODO: is there a way to get this from the environment, i.e. to use // TODO: is there a way to get this from the environment, i.e. to use
// the binary that `which textual` would return, // the binary that `which textual` would return,
// or to use textual as "module" but still run the correct app? // or to use textual as "module" but still run the correct app?
// At least with a virtual environment, I can point to a location // At least with a virtual environment, I can point to a location
// that should exist if you follow the readme instructions. // that should exist if you follow the readme instructions.
// Although the docs for "program" say "Absolute path to the program." // Although the docs for "program" say "Absolute path to the program."
"program": ".venv/bin/textual", "program": ".venv/bin/textual",
"args": ["run", "--dev", "src.textual_paint.paint --clear-screen --inspect-layout"], "args": ["run", "--dev", "src.textual_paint.paint --clear-screen --inspect-layout"],
"console": "integratedTerminal", "console": "integratedTerminal",
"justMyCode": false "justMyCode": false
}, },
{ {
"name": "Open A File in App", "name": "Open A File in App",
"type": "python", "type": "python",
"request": "launch", "request": "launch",
// "program": "src.textual_paint.paint", // "program": "src.textual_paint.paint",
// "args": ["LICENSE.txt"], // "args": ["LICENSE.txt"],
"program": ".venv/bin/textual", "program": ".venv/bin/textual",
"args": ["run", "--dev", "src.textual_paint.paint --clear-screen --inspect-layout LICENSE.txt"], "args": ["run", "--dev", "src.textual_paint.paint --clear-screen --inspect-layout LICENSE.txt"],
"console": "integratedTerminal", "console": "integratedTerminal",
"justMyCode": false "justMyCode": false
}, },
{ {
"name": "Recode Samples", "name": "Recode Samples",
"type": "python", "type": "python",
"request": "launch", "request": "launch",
"program": "src.textual_paint.paint", "program": "src.textual_paint.paint",
"args": ["--recode-samples"], "args": ["--recode-samples"],
"console": "integratedTerminal", "console": "integratedTerminal",
"justMyCode": false "justMyCode": false
}, },
{ {
"name": "Debug --restart-on-changes file matching", "name": "Debug --restart-on-changes file matching",
"type": "python", "type": "python",
"request": "launch", "request": "launch",
"program": ".venv/bin/textual", "program": ".venv/bin/textual",
"args": ["run", "--dev", "src.textual_paint.paint --clear-screen --restart-on-changes"], "args": ["run", "--dev", "src.textual_paint.paint --clear-screen --restart-on-changes"],
"console": "integratedTerminal", "console": "integratedTerminal",
"justMyCode": false "justMyCode": false
}, },
{ {
"name": "Debug Tests", "name": "Debug Tests",
"type": "python", "type": "python",
"request": "launch", "request": "launch",
"program": ".venv/bin/pytest", "program": ".venv/bin/pytest",
// "args": ["tests/test_snapshots.py::test_paint_open_dialog"], // "args": ["tests/test_snapshots.py::test_paint_open_dialog"],
"console": "integratedTerminal", "console": "integratedTerminal",
"justMyCode": false, "justMyCode": false,
// If using pytest-cov in the future: // If using pytest-cov in the future:
// "env": {"PYTEST_ADDOPTS": "--no-cov"} // "env": {"PYTEST_ADDOPTS": "--no-cov"}
} }
] ]
} }

View File

@ -1,190 +1,190 @@
{ {
"files": [ "files": [
"**", "**",
".*/**" ".*/**"
], ],
"enableFiletypes": [ "enableFiletypes": [
"pip-requirements", "pip-requirements",
"shellscript", "shellscript",
"tlaplus_cfg", // file type detected wrong, I'm just trying to match *.cfg "tlaplus_cfg", // file type detected wrong, I'm just trying to match *.cfg
"toml" "toml"
], ],
"ignorePaths": [ "ignorePaths": [
"snapshot_report.html", "snapshot_report.html",
"*.ambr", "*.ambr",
".git", ".git",
"*.(bmp|png|jpg|jpeg|gif|svg|ico|tiff|tif|ans|flf)", "*.(bmp|png|jpg|jpeg|gif|svg|ico|tiff|tif|ans|flf)",
"*.log", "*.log",
"**/localization/*/**/*", "**/localization/*/**/*",
"**/localization/*.sh", "**/localization/*.sh",
"**/typings/**/*", "**/typings/**/*",
"**/samples/*", "**/samples/*",
"**/samples/**/*", "**/samples/**/*",
"__pycache__", "__pycache__",
"**/*.egg-info/**/*" "**/*.egg-info/**/*"
], ],
"words": [ "words": [
"afterstep", "afterstep",
"ambr", "ambr",
"Andale", "Andale",
"APNG", "APNG",
"appcode", "appcode",
"appscript", "appscript",
"asyncio", "asyncio",
"bezier", "bezier",
"blackbox", "blackbox",
"Bresenham", "Bresenham",
"Bresenham's", "Bresenham's",
"bsetbg", "bsetbg",
"bucketization", "bucketization",
"Caja", "Caja",
"Cascadia", "Cascadia",
"clion", "clion",
"cmdpxl", "cmdpxl",
"COLORTERM", "COLORTERM",
"conhost", "conhost",
"Consola", "Consola",
"Consolas", "Consolas",
"Cour", "Cour",
"dasharray", "dasharray",
"dcop", "dcop",
"Deutsch", "Deutsch",
"DIALOGEX", "DIALOGEX",
"disambiguates", "disambiguates",
"dockable", "dockable",
"docstrings", "docstrings",
"domtree", "domtree",
"Dunder", "Dunder",
"emacsclient", "emacsclient",
"executablepath", "executablepath",
"fbsetbg", "fbsetbg",
"Figlet", "Figlet",
"Fira", "Fira",
"fluxbox", "fluxbox",
"fudgedness", "fudgedness",
"gconftool", "gconftool",
"getbands", "getbands",
"getpid", "getpid",
"getpixel", "getpixel",
"goland", "goland",
"gsettings", "gsettings",
"gvim", "gvim",
"hackily", "hackily",
"Haha", "Haha",
"hkey", "hkey",
"hslrgb", "hslrgb",
"hsrgb", "hsrgb",
"humbnail", "humbnail",
"icewm", "icewm",
"icewmbg", "icewmbg",
"icns", "icns",
"Inconsolata", "Inconsolata",
"Inkscape", "Inkscape",
"Intelli", "Intelli",
"kdesktop", "kdesktop",
"ksmserver", "ksmserver",
"kubuntu", "kubuntu",
"linewrap", "linewrap",
"𝗟𝙇", "𝗟𝙇",
"llpaper", "llpaper",
"lrgb", "lrgb",
"lubuntu", "lubuntu",
"Lubuntu", "Lubuntu",
"Lucida", "Lucida",
"lxde", "lxde",
"LXDE", "LXDE",
"mateconftool", "mateconftool",
"Menlo", "Menlo",
"mirc", "mirc",
"modd", "modd",
"mspaint", "mspaint",
"mvim", "mvim",
"mypy", "mypy",
"myusername", "myusername",
"Nemo", "Nemo",
"Noto", "Noto",
"Odhner", "Odhner",
"openbox", "openbox",
"Openbox", "Openbox",
"osascript", "osascript",
"pacman", "pacman",
"pagedown", "pagedown",
"pageup", "pageup",
"palettized", "palettized",
"pcmanfm", "pcmanfm",
"performantly", "performantly",
"phpstorm", "phpstorm",
"pipreqs", "pipreqs",
"pipx", "pipx",
"Playscii", "Playscii",
"polyline", "polyline",
"psutil", "psutil",
"pybabel", "pybabel",
"pycache", "pycache",
"pyfakefs", "pyfakefs",
"pyfiglet", "pyfiglet",
"Pylance", "Pylance",
"pyobjc", "pyobjc",
"pyperclip", "pyperclip",
"pypixelart", "pypixelart",
"pyright", "pyright",
"pytest", "pytest",
"pyxdg", "pyxdg",
"qualname", "qualname",
"rasterization", "rasterization",
"razorkwin", "razorkwin",
"rects", "rects",
"renderable", "renderable",
"rmam", "rmam",
"rmate", "rmate",
"rubymine", "rubymine",
"screeninfo", "screeninfo",
"scrollbars", "scrollbars",
"sdist", "sdist",
"SETDESKWALLPAPER", "SETDESKWALLPAPER",
"setterm", "setterm",
"setuptools", "setuptools",
"Shft", "Shft",
"sixel", "sixel",
"skeuomorphism", "skeuomorphism",
"skool", "skool",
"smam", "smam",
"Smushing", "Smushing",
"stransi", "stransi",
"STRINGTABLE", "STRINGTABLE",
"strxfrm", "strxfrm",
"subl", "subl",
"tasklist", "tasklist",
"testpypi", "testpypi",
"textconv", "textconv",
"thumbnailer", "thumbnailer",
"Thunar", "Thunar",
"tkinter", "tkinter",
"tlaplus", "tlaplus",
"tput", "tput",
"truecolor", "truecolor",
"tspan", "tspan",
"tspans", "tspans",
"txtpnt", "txtpnt",
"ubuntustudio", "ubuntustudio",
"ufeff", "ufeff",
"undecorate", "undecorate",
"undoable", "undoable",
"undos", "undos",
"ustom", "ustom",
"venv", "venv",
"vkey", "vkey",
"webp", "webp",
"webstorm", "webstorm",
"windowmaker", "windowmaker",
"wmaker", "wmaker",
"wmsetbg", "wmsetbg",
"wstorm", "wstorm",
"xfce", "xfce",
"xfconf", "xfconf",
"xfdesktop", "xfdesktop",
"xgettext", "xgettext",
"xpot", "xpot",
"xubuntu" "xubuntu"
] ]
} }

View File

@ -1,97 +1,97 @@
{ {
"include": [ "include": [
"**/*.py", "**/*.py",
], ],
"exclude": [ "exclude": [
"**/node_modules", "**/node_modules",
"**/__pycache__", "**/__pycache__",
"**/build", "**/build",
"**/.*" "**/.*"
], ],
"strict": [ "strict": [
// "**/*.py" // "**/*.py"
], ],
// CUSTOMIZATIONS // CUSTOMIZATIONS
"reportOptionalMemberAccess": "warning", "reportOptionalMemberAccess": "warning",
// reportUnknownMemberType caused numerous bogus errors, // reportUnknownMemberType caused numerous bogus errors,
// with Textual's generic App[ResultType] and Screen[ScreenResultType] classes. // with Textual's generic App[ResultType] and Screen[ScreenResultType] classes.
"reportUnknownMemberType": false, "reportUnknownMemberType": false,
"reportUnnecessaryTypeIgnoreComment": "information", "reportUnnecessaryTypeIgnoreComment": "information",
// STRICT PROFILE // STRICT PROFILE
// As far as I know, there's no way to inherit from strict and then loosen any rules, // As far as I know, there's no way to inherit from strict and then loosen any rules,
// so I've copied from the table and am commenting out the ones I want to change. // so I've copied from the table and am commenting out the ones I want to change.
// https://github.com/microsoft/pyright/blob/2a096860c11dff7bbda92f92efb0216e2580c2c6/docs/configuration.md#diagnostic-rule-defaults // https://github.com/microsoft/pyright/blob/2a096860c11dff7bbda92f92efb0216e2580c2c6/docs/configuration.md#diagnostic-rule-defaults
// > In strict type checking mode, overrides may only increase the severity level (e.g. from "warning" to "error"). // > In strict type checking mode, overrides may only increase the severity level (e.g. from "warning" to "error").
"strictListInference": true, "strictListInference": true,
"strictDictionaryInference": true, "strictDictionaryInference": true,
"strictSetInference": true, "strictSetInference": true,
"analyzeUnannotatedFunctions": true, "analyzeUnannotatedFunctions": true,
"strictParameterNoneValue": true, "strictParameterNoneValue": true,
"enableTypeIgnoreComments": true, "enableTypeIgnoreComments": true,
"reportMissingModuleSource": "warning", "reportMissingModuleSource": "warning",
"reportMissingImports": "error", "reportMissingImports": "error",
"reportUndefinedVariable": "error", "reportUndefinedVariable": "error",
"reportAssertAlwaysTrue": "error", "reportAssertAlwaysTrue": "error",
"reportInvalidStringEscapeSequence": "error", "reportInvalidStringEscapeSequence": "error",
"reportInvalidTypeVarUse": "error", "reportInvalidTypeVarUse": "error",
"reportMissingTypeStubs": "error", "reportMissingTypeStubs": "error",
"reportSelfClsParameterName": "error", "reportSelfClsParameterName": "error",
"reportUnsupportedDunderAll": "error", "reportUnsupportedDunderAll": "error",
"reportUnusedExpression": "error", "reportUnusedExpression": "error",
"reportWildcardImportFromLibrary": "error", "reportWildcardImportFromLibrary": "error",
"reportGeneralTypeIssues": "error", "reportGeneralTypeIssues": "error",
"reportOptionalSubscript": "error", "reportOptionalSubscript": "error",
// "reportOptionalMemberAccess": "error", // "reportOptionalMemberAccess": "error",
"reportOptionalCall": "error", "reportOptionalCall": "error",
"reportOptionalIterable": "error", "reportOptionalIterable": "error",
"reportOptionalContextManager": "error", "reportOptionalContextManager": "error",
"reportOptionalOperand": "error", "reportOptionalOperand": "error",
"reportTypedDictNotRequiredAccess": "error", "reportTypedDictNotRequiredAccess": "error",
"reportPrivateImportUsage": "error", "reportPrivateImportUsage": "error",
"reportUnboundVariable": "error", "reportUnboundVariable": "error",
"reportUnusedCoroutine": "error", "reportUnusedCoroutine": "error",
"reportConstantRedefinition": "error", "reportConstantRedefinition": "error",
"reportDeprecated": "error", "reportDeprecated": "error",
"reportDuplicateImport": "error", "reportDuplicateImport": "error",
"reportFunctionMemberAccess": "error", "reportFunctionMemberAccess": "error",
"reportIncompatibleMethodOverride": "error", "reportIncompatibleMethodOverride": "error",
"reportIncompatibleVariableOverride": "error", "reportIncompatibleVariableOverride": "error",
"reportIncompleteStub": "error", "reportIncompleteStub": "error",
"reportInconsistentConstructor": "error", "reportInconsistentConstructor": "error",
"reportInvalidStubStatement": "error", "reportInvalidStubStatement": "error",
"reportMatchNotExhaustive": "error", "reportMatchNotExhaustive": "error",
"reportMissingParameterType": "error", "reportMissingParameterType": "error",
"reportMissingTypeArgument": "error", "reportMissingTypeArgument": "error",
"reportOverlappingOverload": "error", "reportOverlappingOverload": "error",
"reportPrivateUsage": "error", "reportPrivateUsage": "error",
"reportTypeCommentUsage": "error", "reportTypeCommentUsage": "error",
"reportUnknownArgumentType": "error", "reportUnknownArgumentType": "error",
"reportUnknownLambdaType": "error", "reportUnknownLambdaType": "error",
// "reportUnknownMemberType": "error", // "reportUnknownMemberType": "error",
"reportUnknownParameterType": "error", "reportUnknownParameterType": "error",
"reportUnknownVariableType": "error", "reportUnknownVariableType": "error",
"reportUnnecessaryCast": "error", "reportUnnecessaryCast": "error",
"reportUnnecessaryComparison": "error", "reportUnnecessaryComparison": "error",
"reportUnnecessaryContains": "error", "reportUnnecessaryContains": "error",
"reportUnnecessaryIsInstance": "error", "reportUnnecessaryIsInstance": "error",
"reportUnusedClass": "error", "reportUnusedClass": "error",
"reportUnusedImport": "error", "reportUnusedImport": "error",
"reportUnusedFunction": "error", "reportUnusedFunction": "error",
"reportUnusedVariable": "error", "reportUnusedVariable": "error",
"reportUntypedBaseClass": "error", "reportUntypedBaseClass": "error",
"reportUntypedClassDecorator": "error", "reportUntypedClassDecorator": "error",
"reportUntypedFunctionDecorator": "error", "reportUntypedFunctionDecorator": "error",
"reportUntypedNamedTuple": "error", "reportUntypedNamedTuple": "error",
"reportCallInDefaultInitializer": "none", "reportCallInDefaultInitializer": "none",
"reportImplicitOverride": "none", "reportImplicitOverride": "none",
"reportImplicitStringConcatenation": "none", "reportImplicitStringConcatenation": "none",
"reportImportCycles": "none", "reportImportCycles": "none",
"reportMissingSuperCall": "none", "reportMissingSuperCall": "none",
"reportPropertyTypeMismatch": "none", "reportPropertyTypeMismatch": "none",
"reportShadowedImports": "none", "reportShadowedImports": "none",
"reportUninitializedInstanceVariable": "none", "reportUninitializedInstanceVariable": "none",
// "reportUnnecessaryTypeIgnoreComment": "none", // "reportUnnecessaryTypeIgnoreComment": "none",
"reportUnusedCallResult": "none", "reportUnusedCallResult": "none",
} }

View File

@ -22,25 +22,25 @@ from textual_paint.windows import DialogWindow
# https://github.com/kouzhudong/win2k/blob/ce6323f76d5cd7d136b74427dad8f94ee4c389d2/trunk/private/shell/win16/comdlg/color.c#L38-L43 # https://github.com/kouzhudong/win2k/blob/ce6323f76d5cd7d136b74427dad8f94ee4c389d2/trunk/private/shell/win16/comdlg/color.c#L38-L43
# These are a fallback in case colors are not received from some driver. # These are a fallback in case colors are not received from some driver.
# const default_basic_colors = [ # const default_basic_colors = [
# "#8080FF", "#80FFFF", "#80FF80", "#80FF00", "#FFFF80", "#FF8000", "#C080FF", "#FF80FF", # "#8080FF", "#80FFFF", "#80FF80", "#80FF00", "#FFFF80", "#FF8000", "#C080FF", "#FF80FF",
# "#0000FF", "#00FFFF", "#00FF80", "#40FF00", "#FFFF00", "#C08000", "#C08080", "#FF00FF", # "#0000FF", "#00FFFF", "#00FF80", "#40FF00", "#FFFF00", "#C08000", "#C08080", "#FF00FF",
# "#404080", "#4080FF", "#00FF00", "#808000", "#804000", "#FF8080", "#400080", "#8000FF", # "#404080", "#4080FF", "#00FF00", "#808000", "#804000", "#FF8080", "#400080", "#8000FF",
# "#000080", "#0080FF", "#008000", "#408000", "#FF0000", "#A00000", "#800080", "#FF0080", # "#000080", "#0080FF", "#008000", "#408000", "#FF0000", "#A00000", "#800080", "#FF0080",
# "#000040", "#004080", "#004000", "#404000", "#800000", "#400000", "#400040", "#800040", # "#000040", "#004080", "#004000", "#404000", "#800000", "#400000", "#400040", "#800040",
# "#000000", "#008080", "#408080", "#808080", "#808040", "#C0C0C0", "#400040", "#FFFFFF", # "#000000", "#008080", "#408080", "#808080", "#808040", "#C0C0C0", "#400040", "#FFFFFF",
# ]; # ];
# Grabbed with Color Cop from the screen with Windows 98 SE running in VMWare # Grabbed with Color Cop from the screen with Windows 98 SE running in VMWare
basic_colors = [ basic_colors = [
"#FF8080", "#FFFF80", "#80FF80", "#00FF80", "#80FFFF", "#0080FF", "#FF80C0", "#FF80FF", "#FF8080", "#FFFF80", "#80FF80", "#00FF80", "#80FFFF", "#0080FF", "#FF80C0", "#FF80FF",
"#FF0000", "#FFFF00", "#80FF00", "#00FF40", "#00FFFF", "#0080C0", "#8080C0", "#FF00FF", "#FF0000", "#FFFF00", "#80FF00", "#00FF40", "#00FFFF", "#0080C0", "#8080C0", "#FF00FF",
"#804040", "#FF8040", "#00FF00", "#008080", "#004080", "#8080FF", "#800040", "#FF0080", "#804040", "#FF8040", "#00FF00", "#008080", "#004080", "#8080FF", "#800040", "#FF0080",
"#800000", "#FF8000", "#008000", "#008040", "#0000FF", "#0000A0", "#800080", "#8000FF", "#800000", "#FF8000", "#008000", "#008040", "#0000FF", "#0000A0", "#800080", "#8000FF",
"#400000", "#804000", "#004000", "#004040", "#000080", "#000040", "#400040", "#400080", "#400000", "#804000", "#004000", "#004040", "#000080", "#000040", "#400040", "#400080",
"#000000", "#808000", "#808040", "#808080", "#408080", "#C0C0C0", "#400040", "#FFFFFF", "#000000", "#808000", "#808040", "#808080", "#408080", "#C0C0C0", "#400040", "#FFFFFF",
] ]
custom_colors = [ custom_colors = [
"#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF",
"#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF",
] ]
num_colors_per_row = 8 num_colors_per_row = 8

View File

@ -6,7 +6,7 @@ tput clear
# Check environment variables # Check environment variables
init_script="$HOME/.bashrc" init_script="$HOME/.bashrc"
if [[ -f $HOME/.zshrc ]]; then if [[ -f $HOME/.zshrc ]]; then
init_script="$HOME/.zshrc" init_script="$HOME/.zshrc"
fi fi
# uninstall_instruction="uninstall terminal wallpaper support with 'textual-paint --remove-wallpaper'" # uninstall_instruction="uninstall terminal wallpaper support with 'textual-paint --remove-wallpaper'"
this_script_abs_path=${BASH_SOURCE[0]} this_script_abs_path=${BASH_SOURCE[0]}
@ -15,80 +15,80 @@ source_line="source $this_script_abs_path"
uninstall_instruction="uninstall terminal wallpaper support by removing \"$source_line\" from $init_script" uninstall_instruction="uninstall terminal wallpaper support by removing \"$source_line\" from $init_script"
add_var_instruction="Add it to $init_script before the line that includes terminal_wallpaper.sh (\"$source_line\"), or $uninstall_instruction" add_var_instruction="Add it to $init_script before the line that includes terminal_wallpaper.sh (\"$source_line\"), or $uninstall_instruction"
if [[ -z $TERMINAL_WALLPAPER ]]; then if [[ -z $TERMINAL_WALLPAPER ]]; then
echo "TERMINAL_WALLPAPER not set. $add_var_instruction" echo "TERMINAL_WALLPAPER not set. $add_var_instruction"
return return
fi fi
if [[ -z $TERMINAL_WALLPAPER_MODE ]]; then if [[ -z $TERMINAL_WALLPAPER_MODE ]]; then
echo "TERMINAL_WALLPAPER_MODE not set. $add_var_instruction" echo "TERMINAL_WALLPAPER_MODE not set. $add_var_instruction"
return return
fi fi
# Check file exists # Check file exists
if [[ ! -f $TERMINAL_WALLPAPER ]]; then if [[ ! -f $TERMINAL_WALLPAPER ]]; then
echo "TERMINAL_WALLPAPER file not found: $TERMINAL_WALLPAPER\nUpdate TERMINAL_WALLPAPER in $init_script, or $uninstall_instruction" echo "TERMINAL_WALLPAPER file not found: $TERMINAL_WALLPAPER\nUpdate TERMINAL_WALLPAPER in $init_script, or $uninstall_instruction"
return return
fi fi
# Draw terminal background according to mode # Draw terminal background according to mode
if [[ $TERMINAL_WALLPAPER_MODE == "TOP_LEFT" || $TERMINAL_WALLPAPER_MODE == "TOP-LEFT" ]]; then if [[ $TERMINAL_WALLPAPER_MODE == "TOP_LEFT" || $TERMINAL_WALLPAPER_MODE == "TOP-LEFT" ]]; then
cat $TERMINAL_WALLPAPER cat $TERMINAL_WALLPAPER
else else
# Split lines of terminal background into array # Split lines of terminal background into array
IFS=$'\n' read -d '' -r -a lines < $TERMINAL_WALLPAPER IFS=$'\n' read -d '' -r -a lines < $TERMINAL_WALLPAPER
# Measure image size # Measure image size
image_height=${#lines[@]} image_height=${#lines[@]}
image_width=0 image_width=0
for (( y=0; y<$image_height; y++ )); do for (( y=0; y<$image_height; y++ )); do
line=${lines[$y]} line=${lines[$y]}
# Have to strip ANSI escape sequences from line length # Have to strip ANSI escape sequences from line length
line_length=${#line} line_length=${#line}
filtered_line=$(sed -r "s/\x1B\[[0-9;]*[mK]//g" <<< "$line") filtered_line=$(sed -r "s/\x1B\[[0-9;]*[mK]//g" <<< "$line")
line_width=${#filtered_line} line_width=${#filtered_line}
# echo "y=$y line : $line line_length=$line_length" # echo "y=$y line : $line line_length=$line_length"
# echo "y=$y filtered line: $filtered_line line_width=$line_width" # echo "y=$y filtered line: $filtered_line line_width=$line_width"
if [[ $line_width -gt $image_width ]]; then if [[ $line_width -gt $image_width ]]; then
image_width=$line_width image_width=$line_width
fi fi
done done
if [[ $TERMINAL_WALLPAPER_MODE == "CENTER" || $TERMINAL_WALLPAPER_MODE == "CENTERED" ]]; then if [[ $TERMINAL_WALLPAPER_MODE == "CENTER" || $TERMINAL_WALLPAPER_MODE == "CENTERED" ]]; then
# Calculate offset # Calculate offset
terminal_width=$(tput cols) terminal_width=$(tput cols)
terminal_height=$(tput lines) terminal_height=$(tput lines)
offset_x=$(( ($terminal_width - $image_width) / 2 )) offset_x=$(( ($terminal_width - $image_width) / 2 ))
offset_y=$(( ($terminal_height - $image_height) / 2 )) offset_y=$(( ($terminal_height - $image_height) / 2 ))
# Ensure offset is positive # Ensure offset is positive
if [[ $offset_x -lt 0 ]]; then offset_x=0; fi if [[ $offset_x -lt 0 ]]; then offset_x=0; fi
if [[ $offset_y -lt 0 ]]; then offset_y=0; fi if [[ $offset_y -lt 0 ]]; then offset_y=0; fi
# Draw image # Draw image
for (( i=0; i<$image_height; i++ )); do for (( i=0; i<$image_height; i++ )); do
tput cup $(( $offset_y + $i )) $offset_x tput cup $(( $offset_y + $i )) $offset_x
echo -e "${lines[$i]}" echo -e "${lines[$i]}"
done done
elif [[ $TERMINAL_WALLPAPER_MODE == "TILE" || $TERMINAL_WALLPAPER_MODE == "TILED" ]]; then elif [[ $TERMINAL_WALLPAPER_MODE == "TILE" || $TERMINAL_WALLPAPER_MODE == "TILED" ]]; then
# Draw tiled image # Draw tiled image
tput rmam tput rmam
setterm -linewrap off setterm -linewrap off
terminal_width=$(tput cols) terminal_width=$(tput cols)
terminal_height=$(tput lines) terminal_height=$(tput lines)
for (( y=0; y<$terminal_height; y+=$image_height )); do for (( y=0; y<$terminal_height; y+=$image_height )); do
for (( x=0; x<$terminal_width; x+=$image_width )); do for (( x=0; x<$terminal_width; x+=$image_width )); do
for (( i=0; i<$image_height; i++ )); do for (( i=0; i<$image_height; i++ )); do
# Don't scroll past bottom of terminal # Don't scroll past bottom of terminal
if [[ $(( $y + $i + 1 )) -ge $terminal_height ]]; then if [[ $(( $y + $i + 1 )) -ge $terminal_height ]]; then
break break
fi fi
# Draw line # Draw line
tput cup $(( $y + $i )) $x tput cup $(( $y + $i )) $x
echo -e "${lines[$i]}" echo -e "${lines[$i]}"
done done
done done
done done
tput smam tput smam
setterm -linewrap on setterm -linewrap on
fi fi
fi fi
# Reset cursor position # Reset cursor position