From ba98435ed5e314c4f582e7139bbbd19f4a9cd21b Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Sun, 28 Jan 2024 03:26:10 -0300 Subject: [PATCH] Update bin/emit --- bin/emit | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/bin/emit b/bin/emit index c008f4b..1653929 100755 --- a/bin/emit +++ b/bin/emit @@ -13,19 +13,19 @@ def read .gsub(/[^A-Za-z0-9_\s\/\-,;:*"'.]/, '') end -reads = 0 +open = false loop do tab, buf = "\t", read - if IO.select([$stdin], [], [], 0.1).nil? - reads = 0 - print buf.chomp, "}", "\n" - elsif buf.include?(tab) - print "}\n" if reads > 0 + if buf.include?(tab) + print "\n}\n" if open class_name, class_body = buf.split(tab, 2) class_name.gsub!(%r|([/.])|) { "\\#{_1}" } - print ".#{class_name} {", "\n", " " * 2, class_body.chomp, "\n" - reads += 1 - else - print " " * 2, buf + print ".#{class_name} {", "\n", " " * 2, class_body.chomp + open = true + elsif buf.include?(":") + print "\n", " " * 2, buf.chomp + elsif open + open = false + print "\n}\n" end end