From 73919c7b811bac351087c407867272f1b89f3c25 Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Sun, 23 Feb 2020 14:45:46 +0200 Subject: [PATCH] [scripts] add onscreen-message.py --- nvim/plugin/editing.vim | 2 ++ scripts/onscreen-message.py | 45 +++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100755 scripts/onscreen-message.py diff --git a/nvim/plugin/editing.vim b/nvim/plugin/editing.vim index be109ed..df84744 100644 --- a/nvim/plugin/editing.vim +++ b/nvim/plugin/editing.vim @@ -188,4 +188,6 @@ set commentstring=//%s let g:vim_markdown_conceal_code_blocks = 0 let g:vim_markdown_no_default_key_mappings = 0 + let g:vala_syntax_folding_enabled = 0 + " }}} diff --git a/scripts/onscreen-message.py b/scripts/onscreen-message.py new file mode 100755 index 0000000..3ca6694 --- /dev/null +++ b/scripts/onscreen-message.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python3 +import gi +import argparse + +gi.require_version("Gtk", "3.0") +from gi.repository import Gtk, Gdk, Pango # noqa: E402 + + +parser = argparse.ArgumentParser() +parser.add_argument("message", type=str, nargs="+") +args = parser.parse_args() + +message = " ".join(args.message) + + +window = Gtk.ApplicationWindow() +window.set_keep_above(True) +window.set_decorated(False) +window.set_default_size(800, 100) + +scrolled_window = Gtk.ScrolledWindow() +label = Gtk.Label(label=message) +scrolled_window.add(label) +window.add(scrolled_window) + + +def on_key_release(target, event): + key = event.keyval + if key in [Gdk.KEY_Escape, Gdk.KEY_q, Gdk.KEY_Q]: + window.close() + + +def on_configure(target, event): + if target != window or event.type != Gdk.EventType.CONFIGURE: + return + font_desc = Pango.FontDescription() + font_desc.set_size(Pango.SCALE * event.height * 2 / 3) + label.override_font(font_desc) + + +window.connect("configure-event", on_configure) +window.connect("key-release-event", on_key_release) +window.show_all() +window.connect("destroy", Gtk.main_quit) +Gtk.main()