From 53e72ccef02f8a130444d19e91cf8f8442b538d3 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Wed, 15 Jun 2022 00:00:00 -0500 Subject: [PATCH] top: the bottom 'window' headings are now translatable <=== port of newlib 20859f6f ______________________________ original newlib message --------------------------------------------- ( none ) Signed-off-by: Jim Warner --- top/top.c | 16 ++++++++-------- top/top.h | 2 +- top/top_nls.c | 5 +++++ top/top_nls.h | 2 ++ 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/top/top.c b/top/top.c index c7d4d013..9aa2087f 100644 --- a/top/top.c +++ b/top/top.c @@ -132,7 +132,7 @@ static int Bot_task, Bot_rsvd, Bot_indx = BOT_UNFOCUS; static char Bot_sep, - *Bot_name, + *Bot_head, Bot_buf[BOTBUFSIZ]; // the 'environ' can be huge typedef int(*BOT_f)(const void *, const void *); static BOT_f Bot_focus_func; @@ -5253,7 +5253,7 @@ static void *bot_item_hlp (proc_t *p) { * This guy manages the bottom margin window, | * showing miscellaneous variable width data. | */ static void bot_item_show (void) { - #define mkHDR fmtmk("%s for pid %d, %s", Bot_name, Bot_task, p->cmd) + #define mkHDR fmtmk(Bot_head, Bot_task, p->cmd) proc_t *p; int i; @@ -5278,7 +5278,7 @@ static void bot_item_show (void) { /* * This guy toggles between displaying a Ctrl | * bottom window or arranging to turn it off. | */ -static void bot_item_toggle (int what, const char *name, char sep) { +static void bot_item_toggle (int what, const char *head, char sep) { // if already targeted, assume user wants to turn it off ... if (Bot_what == what) { BOT_TOSS; @@ -5296,7 +5296,7 @@ static void bot_item_toggle (int what, const char *name, char sep) { Bot_sep = sep; Bot_what = what; Bot_indx = BOT_UNFOCUS; - Bot_name = (char *)name; + Bot_head = (char *)head; Bot_show_func = bot_item_show; Bot_task = Curwin->ppt[Curwin->begtask]->tid; } @@ -5685,17 +5685,17 @@ static void keys_global (int ch) { break; case kbd_CtrlK: // with string vectors, the 'separator' may serve a different purpose - bot_item_toggle(PROC_FILLARG, "command line", BOT_SEP_SPC); + bot_item_toggle(PROC_FILLARG, N_fmt(X_BOT_cmdlin_fmt), BOT_SEP_SPC); break; case kbd_CtrlN: // with string vectors, the 'separator' may serve a different purpose - bot_item_toggle(PROC_FILLENV, "environment", BOT_SEP_SPC); + bot_item_toggle(PROC_FILLENV, N_fmt(X_BOT_envirn_fmt), BOT_SEP_SPC); break; case kbd_CtrlP: - bot_item_toggle((L_NS), "namespaces", BOT_SEP_CMA); + bot_item_toggle((L_NS), N_fmt(X_BOT_namesp_fmt), BOT_SEP_CMA); break; case kbd_CtrlU: - bot_item_toggle((L_SUPGRP), "supplementary groups", BOT_SEP_CMA); + bot_item_toggle((L_SUPGRP), N_fmt(X_BOT_supgrp_fmt), BOT_SEP_CMA); break; case kbd_BTAB: if (Bot_what) { diff --git a/top/top.h b/top/top.h index 225d8067..db89c002 100644 --- a/top/top.h +++ b/top/top.h @@ -832,7 +832,7 @@ typedef struct WIN_t { //atic int bot_focus_strv (const char *hdr, const char **strv); //atic void *bot_item_hlp (proc_t *p); //atic void bot_item_show (void); -//atic void bot_item_toggle (int what, const char *name, char sep); +//atic void bot_item_toggle (int what, const char *head, char sep); /*------ Interactive Input Tertiary support ----------------------------*/ //atic inline int find_ofs (const WIN_t *q, const char *buf); //atic void find_string (int ch); diff --git a/top/top_nls.c b/top/top_nls.c index 77a8faa3..235348aa 100644 --- a/top/top_nls.c +++ b/top/top_nls.c @@ -524,6 +524,11 @@ static void build_norm_nlstab (void) { Norm_nlstab[XTRA_size2up_txt] = _("terminal is not wide enough"); Norm_nlstab[XTRA_modebad_txt] = _("wrong mode, command inactive"); Norm_nlstab[XTRA_warnold_txt] = _("saving prevents older top from reading, save anyway?"); + Norm_nlstab[X_BOT_cmdlin_fmt] = _("command line for pid %d, %s"); + Norm_nlstab[X_BOT_ctlgrp_fmt] = _("control groups for pid %d, %s"); + Norm_nlstab[X_BOT_envirn_fmt] = _("environment for pid %d, %s"); + Norm_nlstab[X_BOT_namesp_fmt] = _("namespaces for pid %d, %s"); + Norm_nlstab[X_BOT_supgrp_fmt] = _("supplementary groups for pid %d, %s"); } diff --git a/top/top_nls.h b/top/top_nls.h index 7cb41eb3..b7d54f1f 100644 --- a/top/top_nls.h +++ b/top/top_nls.h @@ -84,6 +84,8 @@ enum norm_nls { WORD_process_txt, WORD_threads_txt, WRITE_rcfile_fmt, WRONG_switch_fmt, XTRA_badflds_fmt, XTRA_fixwide_fmt, XTRA_modebad_txt, XTRA_size2up_txt, XTRA_vforest_fmt, XTRA_warncfg_txt, XTRA_warnold_txt, XTRA_winsize_txt, + X_BOT_cmdlin_fmt, X_BOT_ctlgrp_fmt, X_BOT_envirn_fmt, X_BOT_namesp_fmt, + X_BOT_supgrp_fmt, YINSP_demo01_txt, YINSP_demo02_txt, YINSP_demo03_txt, YINSP_deqfmt_txt, YINSP_deqtyp_txt, YINSP_dstory_txt, YINSP_failed_fmt, YINSP_noent1_txt, YINSP_noent2_txt, YINSP_pidbad_fmt, -- 2.40.0