Browse Source

Extend sym_new_ext() for 'silent' flag

Serj Kalichev 5 months ago
parent
commit
20f1d46655
3 changed files with 14 additions and 13 deletions
  1. 2 1
      klish/kscheme/ksym.c
  2. 2 2
      klish/ksym.h
  3. 10 10
      plugins/klish/plugin_init.c

+ 2 - 1
klish/kscheme/ksym.c

@@ -67,7 +67,7 @@ ksym_t *ksym_new(const char *name, ksym_fn function)
 
 
 ksym_t *ksym_new_ext(const char *name, ksym_fn function,
-	tri_t permanent, tri_t sync)
+	tri_t permanent, tri_t sync, bool_t silent)
 {
 	ksym_t *sym = NULL;
 
@@ -77,6 +77,7 @@ ksym_t *ksym_new_ext(const char *name, ksym_fn function,
 
 	ksym_set_permanent(sym, permanent);
 	ksym_set_sync(sym, sync);
+	ksym_set_silent(sym, silent);
 
 	return sym;
 }

+ 2 - 2
klish/ksym.h

@@ -25,7 +25,7 @@ typedef int (*ksym_fn)(kcontext_t *context);
 
 // Aliases for silent flag
 #define KSYM_SILENT BOOL_TRUE
-#define KSYM_NONSILENT TRI_FALSE
+#define KSYM_NONSILENT BOOL_FALSE
 
 
 C_DECL_BEGIN
@@ -33,7 +33,7 @@ C_DECL_BEGIN
 // ksym_t
 ksym_t *ksym_new(const char *name, ksym_fn function);
 ksym_t *ksym_new_ext(const char *name, ksym_fn function,
-	tri_t permanent, tri_t sync);
+	tri_t permanent, tri_t sync, bool_t silent);
 void ksym_free(ksym_t *sym);
 
 const char *ksym_name(const ksym_t *sym);

+ 10 - 10
plugins/klish/plugin_init.c

@@ -27,12 +27,12 @@ int kplugin_klish_init(kcontext_t *context)
 
 	// Misc
 	kplugin_add_syms(plugin, ksym_new_ext("nop", klish_nop,
-		KSYM_USERDEFINED_PERMANENT, KSYM_SYNC));
+		KSYM_USERDEFINED_PERMANENT, KSYM_SYNC, KSYM_SILENT));
 	kplugin_add_syms(plugin, ksym_new("tsym", klish_tsym));
 	kplugin_add_syms(plugin, ksym_new("print", klish_print));
 	kplugin_add_syms(plugin, ksym_new("printl", klish_printl));
 	kplugin_add_syms(plugin, ksym_new_ext("pwd", klish_pwd,
-		KSYM_PERMANENT, KSYM_SYNC));
+		KSYM_PERMANENT, KSYM_SYNC, KSYM_NONSILENT));
 	kplugin_add_syms(plugin, ksym_new("prompt", klish_prompt));
 
 	// Log
@@ -42,24 +42,24 @@ int kplugin_klish_init(kcontext_t *context)
 	// Navigation must be permanent (no dry-run) and sync. Because unsync
 	// actions will be fork()-ed so it can't change current path.
 	kplugin_add_syms(plugin, ksym_new_ext("nav", klish_nav,
-		KSYM_PERMANENT, KSYM_SYNC));
+		KSYM_PERMANENT, KSYM_SYNC, KSYM_SILENT));
 
 	// PTYPEs
 	// These PTYPEs are simple and fast so set SYNC flag
 	kplugin_add_syms(plugin, ksym_new_ext("COMMAND", klish_ptype_COMMAND,
-		KSYM_USERDEFINED_PERMANENT, KSYM_SYNC));
+		KSYM_USERDEFINED_PERMANENT, KSYM_SYNC, KSYM_SILENT));
 	kplugin_add_syms(plugin, ksym_new_ext("completion_COMMAND", klish_completion_COMMAND,
-		KSYM_USERDEFINED_PERMANENT, KSYM_SYNC));
+		KSYM_USERDEFINED_PERMANENT, KSYM_SYNC, KSYM_SILENT));
 	kplugin_add_syms(plugin, ksym_new_ext("help_COMMAND", klish_help_COMMAND,
-		KSYM_USERDEFINED_PERMANENT, KSYM_SYNC));
+		KSYM_USERDEFINED_PERMANENT, KSYM_SYNC, KSYM_SILENT));
 	kplugin_add_syms(plugin, ksym_new_ext("COMMAND_CASE", klish_ptype_COMMAND_CASE,
-		KSYM_USERDEFINED_PERMANENT, KSYM_SYNC));
+		KSYM_USERDEFINED_PERMANENT, KSYM_SYNC, KSYM_SILENT));
 	kplugin_add_syms(plugin, ksym_new_ext("INT", klish_ptype_INT,
-		KSYM_USERDEFINED_PERMANENT, KSYM_SYNC));
+		KSYM_USERDEFINED_PERMANENT, KSYM_SYNC, KSYM_SILENT));
 	kplugin_add_syms(plugin, ksym_new_ext("UINT", klish_ptype_UINT,
-		KSYM_USERDEFINED_PERMANENT, KSYM_SYNC));
+		KSYM_USERDEFINED_PERMANENT, KSYM_SYNC, KSYM_SILENT));
 	kplugin_add_syms(plugin, ksym_new_ext("STRING", klish_ptype_STRING,
-		KSYM_USERDEFINED_PERMANENT, KSYM_SYNC));
+		KSYM_USERDEFINED_PERMANENT, KSYM_SYNC, KSYM_SILENT));
 
 	return 0;
 }