Skip to content

Commit 85d6e8e

Browse files
committed
♻️ changed the parameter of some log func
1 parent dc8e420 commit 85d6e8e

28 files changed

Lines changed: 171 additions & 671 deletions

commands.d/self-build.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ function extractCommandDefinitionsToVariables() {
283283

284284
if log::isTraceEnabled; then
285285
log::trace "Extracting command definition for:"
286-
log::printFileString "${content%%$'\n'*}"
286+
log::printFileString content
287287
fi
288288

289289
selfBuild_extractCommandDefinitionToVariables "${content}"
@@ -320,8 +320,9 @@ function extractCommandDefinitionsToVariables() {
320320
if log::isTraceEnabled; then
321321
# shellcheck disable=SC2086
322322
exe::captureOutput declare -p ${!TEMP_CMD_BUILD_*}
323+
local declaredVariables="${RETURNED_VALUE}"
323324
log::trace "Declared variables for this command:"
324-
log::printFileString "${RETURNED_VALUE}"
325+
log::printFileString declaredVariables
325326
fi
326327

327328
# verify that the command definition is valid

commands.d/self-document.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,10 @@ function selfDocument::getAllFunctionsDocumentation() {
138138
local IFS=$'\n'
139139
if log::isDebugEnabled; then
140140
log::debug "Analyzing the following files:"
141-
log::printFileString "${filesToAnalyze[*]}"
141+
local file
142+
for file in "${filesToAnalyze[@]}"; do
143+
log::printString "- ${file}"
144+
done
142145
fi
143146

144147
unset -v RETURNED_ASSOCIATIVE_ARRAY SORTED_FUNCTION_NAMES
@@ -188,7 +191,8 @@ function selfDocument::getAllFunctionsDocumentation() {
188191
local key
189192
for key in "${!RETURNED_ASSOCIATIVE_ARRAY[@]}"; do
190193
log::trace "Function: ⌜${key}"
191-
log::printFileString "${RETURNED_ASSOCIATIVE_ARRAY[${key}]}"
194+
local documentationString="${RETURNED_ASSOCIATIVE_ARRAY[${key}]}"
195+
log::printFileString documentationString
192196
done
193197
fi
194198

commands.d/self-release.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ function selfRelease::createRelease() {
184184
done
185185
IFS=$' '
186186
log::info "The tag message is:"
187-
log::printFileString "${tagMessage}"
187+
log::printFileString tagMessage
188188

189189
if [[ "${uploadExistingTag:-}" != "true" ]]; then
190190

libraries.d/lib-http

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ function http::request() {
173173
if (( exitCode != 0 )); then
174174
if log::isDebugEnabled || [[ ${failOnError} == "true" ]]; then
175175
log::errorTrace "HTTP response:"
176-
log::printFileString "${headers}"$'\n'"${body:-}"
176+
log::printString "${headers}"$'\n'"${body:-}"
177177
fi
178178
local message="The HTTP return code ⌜${httpCode}⌝ is not acceptable for url ⌜${url}⌝."
179179
if [[ ${failOnError} == "true" ]]; then

libraries.d/lib-multi-line-prompt

Lines changed: 0 additions & 97 deletions
This file was deleted.

libraries.d/lib-prompt

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,3 +1239,96 @@ function prompt_getDisplayedPromptString() {
12391239
RETURNED_VALUE2=${screenIndex}
12401240
}
12411241

1242+
1243+
# Clear the multi-line prompt
1244+
function prompt_clearMultiLinePrompt() {
1245+
tui::clearBox "${_PROMPT_START_LINE}" "${_PROMPT_START_COLUMN}" "${_PROMPT_WIDTH}" "${_PROMPT_NB_PROMPT_LINES}"
1246+
}
1247+
1248+
function prompt_drawMultiLinePrompt() {
1249+
# we need to draw the prompt on multiple lines
1250+
local promptLines=()
1251+
local promptLinesStartIndex=()
1252+
prompt_drawMultiLinePromptRefreshLines _PROMPT_STRING
1253+
1254+
prompt_getMultiLinePrompt
1255+
printf '%s' "${ESC__CURSOR_HIDE}${ESC__CURSOR_MOVE__}${_PROMPT_START_LINE};${_PROMPT_START_COLUMN}${__ESC__TO}${RETURNED_VALUE}${ESC__CURSOR_MOVE__}${GLOBAL_CURSOR_LINE};${GLOBAL_CURSOR_COLUMN}${__ESC__TO}${ESC__CURSOR_SHOW}"
1256+
}
1257+
1258+
function prompt_drawMultiLinePromptRefreshLines() {
1259+
local -n textToWrapAtWords="${1}"
1260+
1261+
local -i linesIndex=0
1262+
1263+
# short cut in case the text is already shorter than the width
1264+
if [[ ${#textToWrapAtWords} -le ${_PROMPT_STRING_SCREEN_WIDTH} && ${textToWrapAtWords} != *$'\n'* ]]; then
1265+
RETURNED_VALUE="${textToWrapAtWords}"
1266+
return 0
1267+
fi
1268+
1269+
local text="${textToWrapAtWords}"
1270+
local IFS=$' \t' line word realWord RETURNED_VALUE2
1271+
local -i realWordLength=0 firstWord=1
1272+
local -i lineLength=0
1273+
1274+
while ((${#text} > 0)); do
1275+
line="${text%%$'\n'*}"
1276+
text="${text:${#line}+1}"
1277+
1278+
output+=$'\n'""
1279+
1280+
# short cut in case the text is already shorter than the width
1281+
if ((lineLength + ${#line} <= _PROMPT_STRING_SCREEN_WIDTH)); then
1282+
output+="${line}"
1283+
continue
1284+
fi
1285+
1286+
firstWord=1
1287+
1288+
for word in ${line}; do
1289+
if [[ ${word} == *$'\e'* ]]; then
1290+
realWord="${word//$'\e['[0-9][0-9]m/}"
1291+
realWord="${realWord//$'\e['[0-9]m/}"
1292+
realWordLength="${#realWord}"
1293+
else
1294+
realWordLength="${#word}"
1295+
fi
1296+
1297+
if ((lineLength < _PROMPT_STRING_SCREEN_WIDTH && firstWord == 0)); then
1298+
output+=" "
1299+
lineLength+=1
1300+
else
1301+
firstWord=0
1302+
fi
1303+
1304+
if ((lineLength + realWordLength <= _PROMPT_STRING_SCREEN_WIDTH)); then
1305+
# add the word to the current line
1306+
output+="${word}"
1307+
lineLength+=realWordLength
1308+
else
1309+
# not enough space left, check if the word fits on the next line
1310+
if ((realWordLength <= _PROMPT_STRING_SCREEN_WIDTH)); then
1311+
output+=$'\n'"${word}"
1312+
lineLength=realWordLength
1313+
else
1314+
# the word is too long to fit on a line, split it in multiple lines
1315+
string::wrapCharacters word "${_PROMPT_STRING_SCREEN_WIDTH}" "" "$((_PROMPT_STRING_SCREEN_WIDTH - lineLength))"
1316+
output+="${RETURNED_VALUE}"
1317+
lineLength=${RETURNED_VALUE2}
1318+
fi
1319+
fi
1320+
1321+
done
1322+
1323+
lineLength=0
1324+
done
1325+
1326+
RETURNED_VALUE="${output#$'\n'""}"
1327+
1328+
1329+
1330+
string::wrapWords _PROMPT_STRING "${_PROMPT_STRING_SCREEN_WIDTH}" " " "$((_PROMPT_STRING_SCREEN_WIDTH - _PROMPT_SYMBOL_LENGTH))"
1331+
1332+
prompt_getMultiLinePrompt
1333+
printf '%s' "${ESC__CURSOR_HIDE}${ESC__CURSOR_MOVE__}${_PROMPT_START_LINE};${_PROMPT_START_COLUMN}${__ESC__TO}${RETURNED_VALUE}${ESC__CURSOR_MOVE__}${GLOBAL_CURSOR_LINE};${GLOBAL_CURSOR_COLUMN}${__ESC__TO}${ESC__CURSOR_SHOW}"
1334+
}

libraries.d/lib-sfzf

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ source tui
1111
source exe
1212
# shellcheck source=lib-array
1313
source array
14+
# shellcheck source=lib-list
15+
source list
1416

1517
#===============================================================
1618
# >>> Customization
@@ -361,6 +363,9 @@ function drawLeftPane() {
361363
toPrint+="${ESC__CURSOR_MOVE__}$((SFZF_LEFT_PANE_FIRST_LINE + 1));$((SFZF_LEFT_PANE_WIDTH - itemCounterLength))${__ESC__TO}${itemsCounter}"
362364
fi
363365

366+
_PROMPT_ITEMS_BOX_ITEM_WIDTH=$((SFZF_LEFT_PANE_WIDTH - 3))
367+
_PROMPT_ITEMS_BOX_FILTER_STRING="${SFZF_SEARCH_STRING}"
368+
364369
# draw the items
365370
local itemPrefix
366371
local -i index line=${SFZF_LEFT_PANE_FIRST_CONTENT_LINE}
@@ -372,7 +377,10 @@ function drawLeftPane() {
372377
else
373378
itemPrefix=" "
374379
fi
375-
toPrint+="${ESC__CURSOR_MOVE__}${line};${SFZF_LEFT_PANE_WIDTH}${__ESC__TO}${ESC__ERASE_CHARS_LEFT}"$'\r'"${itemPrefix}${SFZF_FILTERED_ITEMS[index]}${SFZF_COLOR_SELECTED_ITEM_RESET}"
380+
381+
_PROMPT_ITEMS_BOX_ITEM_DISPLAYED="${SFZF_FILTERED_ITEMS[index]}"
382+
list::getItemDisplayedString
383+
toPrint+="${ESC__CURSOR_MOVE__}${line};${SFZF_LEFT_PANE_WIDTH}${__ESC__TO}${ESC__ERASE_CHARS_LEFT}"$'\r'"${itemPrefix}${_PROMPT_ITEMS_BOX_ITEM_DISPLAYED}${SFZF_COLOR_SELECTED_ITEM_RESET}"
376384
line+=1
377385
done
378386

libraries.d/main

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ GLOBAL_PROGRAM_STARTED_AT_DIRECTORY="${PWD}"
2222

2323
# To ensure we print errors even before log::init is called
2424
GLOBAL_LOG_PRINT_STATEMENT_FORMATTED_LOG="printf \"%-8s %s\n\" \"\${level:-}\" \"\${!messageVariableName}\" 1>&2"
25-
GLOBAL_LOG_PRINT_STATEMENT_STANDARD="printf \"%s\" \"\${toPrint}\" 1>&2"
25+
GLOBAL_LOG_PRINT_STATEMENT_STANDARD="printf \"%s\" \"\${rawStringToPrintInLog}\" 1>&2"
2626
GLOBAL_LOG_WRAP_PADDING=''
2727
GLOBAL_LOG_DISABLE_WRAP=true
2828

scratchpad/arrays/c2 renamed to scratchpad/arrays/advanced-sort-c-implementation

File renamed without changes.

scratchpad/arrays/c

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)