From 7d9f8cf20bff7a9b72d65e74102f382803069c83 Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Mon, 22 Apr 2019 22:51:33 +0000 Subject: [PATCH] A simple script to display a user's avatar somewhere on the terminal screen. The default user is the current user. If a different user's avatar is to be shown, the user number must be passed on the command-line. Other command-line options supported: -draw = use the Graphic.draw() method to display anywhere (requires ANSI) -top = display the avatar at the top of the screen -right = display the avatar at the right edge of the screen -above = display the avatar above the current cursor position The -top/right/above options imply "draw", and all require ANSI support. The default display method is to simply "show" the avatar (not draw) and that does not require ANSI support, but can only display the avatar at the current cursor location, left-justified. --- exec/showavatar.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 exec/showavatar.js diff --git a/exec/showavatar.js b/exec/showavatar.js new file mode 100644 index 0000000000..6d2ccf7d14 --- /dev/null +++ b/exec/showavatar.js @@ -0,0 +1,37 @@ +// $Id$ + +var usernum = user.number; +var draw = false; +var above = false; +var right = false; +var top = false; +for(var i in argv) { + switch(argv[i]) { + case '-draw': + draw = true; + break; + case '-above': + draw = true; + above = true; + break; + case '-right': + draw = true; + right = true; + break; + case '-top': + draw = true; + top = true; + break; + default: + if(parseInt(argv[i], 10)) + usernum = parseInt(argv[i], 10); + } +} + +var Avatar = load({}, 'avatar_lib.js'); +if(draw) { + Avatar.draw(usernum, /* name: */null, /* netaddr: */null, above, right, top); + console.attributes = 7; // Clear the background attribute as the next line might scroll, filling with BG attribute +} else { + Avatar.show(usernum); +} -- GitLab