net/omnitty: Add abililty to "toggle" tagged machines

We often need to do "something" to about half the machines, then
do "something else" to the other half.  So add a hack to toggle the
"tagged" status of the machines.

This is implemented by means of the F1 menu; the command characters
"o" and "O" can toggle the "tagged" status of the machines.

PR:		211682
Submitted by:	maintainer
This commit is contained in:
Tobias Kortkamp 2018-08-09 12:25:08 +00:00
parent 1cc6292222
commit f0f35ca44f
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=476742
5 changed files with 70 additions and 9 deletions

View file

@ -3,7 +3,7 @@
PORTNAME= omnitty
PORTVERSION= 0.3.0
PORTREVISION= 3
PORTREVISION= 4
CATEGORIES= net
MASTER_SITES= SF/omnitty/omnitty/omnitty-${PORTVERSION}
@ -19,9 +19,6 @@ LIBS+= -lncurses
ALL_TARGET= omnitty
PLIST_FILES= bin/omnitty man/man1/omnitty.1.gz
post-patch:
${REINPLACE_CMD} 's|<alloca.h>|<stdlib.h>|' ${WRKSRC}/machmgr.c
do-install:
${INSTALL_PROGRAM} ${WRKSRC}/omnitty ${STAGEDIR}${PREFIX}/bin
${INSTALL_MAN} ${WRKSRC}/omnitty.1 ${STAGEDIR}${MANPREFIX}/man/man1

View file

@ -0,0 +1,25 @@
--- machmgr.c.orig 2005-10-25 22:04:01 UTC
+++ machmgr.c
@@ -26,7 +26,7 @@
#include "machine.h"
#include "minibuf.h"
#include <string.h>
-#include <alloca.h>
+#include <stdlib.h>
#define MACHINE_MAX 256
@@ -261,5 +261,13 @@ void machmgr_delete_dead() {
int i;
for (i = machcount - 1; i >= 0; i--)
if (!machs[i]->alive) machmgr_delete(i);
+}
+
+void machmgr_toggle_tag_all(bool ignore_dead) {
+ int i;
+ for (i = 0; i < machcount; i++) {
+ if (!ignore_dead || machs[i]->alive)
+ machs[i]->tag = !machs[i]->tag;
+ }
}

View file

@ -0,0 +1,13 @@
--- machmgr.h.orig 2005-10-25 22:04:01 UTC
+++ machmgr.h
@@ -106,6 +106,10 @@ void machmgr_delete_dead();
/* Deletes all tagged machines */
void machmgr_delete_tagged();
+/* Toggles tagged status of all machines. If ignore_dead, does not
+ * tag dead machines (i.e. machines whose alive flag is down). */
+void machmgr_toggle_tag_all(bool ignore_dead);
+
/* Tags all machines. If ignore_dead, does not tag dead machines (i.e. machines
* whose alive flag is down). */
void machmgr_tag_all(bool ignore_dead);

View file

@ -1,5 +1,5 @@
--- main.c.orig 2005-10-26 06:08:25.000000000 +0800
+++ main.c 2011-04-22 23:14:33.000000000 +0800
--- main.c.orig 2005-10-25 22:08:25 UTC
+++ main.c
@@ -36,6 +36,7 @@
/* minimum terminal dimensions to run program */
#define MIN_REQUIRED_WIDTH 80
@ -8,7 +8,7 @@
#define REMINDER_LINE "OmNiTTY-R v" OMNITTY_VERSION \
" \007F1\007:menu \006F2/3\007:sel \003F4\007:tag" \
@@ -88,6 +88,12 @@
@@ -88,6 +89,12 @@ void curses_init() {
define_key("\e[15~", KEY_F(5)); define_key("\e[17~", KEY_F(6));
define_key("\e[18~", KEY_F(7)); define_key("\e[19~", KEY_F(8));
define_key("\e[20~", KEY_F(9)); define_key("\e[21~", KEY_F(10));
@ -21,7 +21,7 @@
getmaxyx(stdscr, h, w);
if (h < MIN_REQUIRED_HEIGHT || w < MIN_REQUIRED_WIDTH) {
@@ -288,10 +289,10 @@
@@ -288,10 +295,10 @@ static void add_machines_from_file(const char *file) {
}
static void add_machine() {
@ -34,7 +34,7 @@
if (*buf == '@') add_machines_from_file(buf+1);
else machmgr_add(buf);
}
@@ -335,9 +341,10 @@
@@ -335,9 +342,10 @@ int main(int argc, char **argv) {
while (!quit) {
if (zombie_count) {

View file

@ -0,0 +1,26 @@
--- menu.c.orig 2005-10-25 22:04:01 UTC
+++ menu.c
@@ -29,11 +29,13 @@
#include "help.h"
#define MENU_LINES 12
-#define MENU_COLS 38
+#define MENU_COLS 45
#define MENU_CONTENTS \
"{[h]} online help\n" \
"{[r]} rename machine\n" \
+ "{[o]} toggle tag all machines (live only)\n" \
+ "{[O]} toggle tag all machines (live & dead)\n" \
"{[t]} tag all machines (live only)\n" \
"{[T]} tag all machines (live & dead)\n" \
"{[u]} untag all machines\n" \
@@ -100,6 +102,8 @@ void menu_show() {
}
break;
+ case 'o': machmgr_toggle_tag_all(true); break;
+ case 'O': machmgr_toggle_tag_all(false); break;
case 't': machmgr_tag_all(true); break;
case 'T': machmgr_tag_all(false); break;
case 'u': machmgr_untag_all(); break;