commit a2deaf57f310518855160eb8f8363c532b1b611d
parent 0fb4ed5093eb84aac57f4dff0f8e267892860af7
Author: Arun Prakash Jana <engineerarun@gmail.com>
Date: Wed, 14 Aug 2024 05:56:12 +0530
rm improvements
- show name of the hovered file to be removed
- show number of selected files to be removed
Diffstat:
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/src/nnn.c b/src/nnn.c
@@ -603,7 +603,7 @@ static char * const utils[] = {
#define MSG_SSN_NAME 6
#define MSG_CP_MV_AS 7
#define MSG_CUR_SEL_OPTS 8
-#define MSG_FORCE_RM 9
+#define MSG_FILE_LIMIT 9
#define MSG_SIZE_LIMIT 10
#define MSG_NEW_OPTS 11
#define MSG_CLI_MODE 12
@@ -638,7 +638,6 @@ static char * const utils[] = {
#define MSG_NOCHANGE 41
#define MSG_DIR_CHANGED 42
#define MSG_BM_NAME 43
-#define MSG_FILE_LIMIT 44
static const char * const messages[] = {
"",
@@ -650,7 +649,7 @@ static const char * const messages[] = {
"session name: ",
"'c'p/'m'v as?",
"'c'urrent/'s'el?",
- "%s %s? [Esc cancels]",
+ "file limit exceeded",
"size limit exceeded",
"['f'ile]/'d'ir/'s'ym/'h'ard?",
"['g'ui]/'c'li?",
@@ -685,7 +684,6 @@ static const char * const messages[] = {
"unchanged",
"dir changed, range sel off",
"name: ",
- "file limit exceeded",
};
/* Supported configuration environment variables */
@@ -1553,14 +1551,17 @@ static void xdelay(useconds_t delay)
static char confirm_force(bool selection, bool use_trash)
{
- char str[64];
+ char str[300];
/* Note: ideally we should use utils[UTIL_RM_RF] instead of the "rm -rf" string */
- snprintf(str, 64, messages[MSG_FORCE_RM],
- use_trash ? utils[UTIL_GIO_TRASH] + 4 : "rm -rf",
- (selection ? "selected" : "hovered"));
+ int r = snprintf(str, 20, "%s", use_trash ? utils[UTIL_GIO_TRASH] + 4 : "rm -rf");
+
+ if (selection)
+ snprintf(str + r, 280, " %d files?", nselected);
+ else
+ snprintf(str + r, 280, " '%s'?", pdents[cur].name);
- int r = get_input(str);
+ r = get_input(str);
if (r == ESC)
return '\0'; /* cancel */