firew0rks 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e27f82bdc52c7baedbdd6e6cef27334dcead8d04047e984a9af9536e2147c75
4
- data.tar.gz: 0aa153b8662574c41c7889bb8123965bd2edf561d93c3086bbb45897de292ce3
3
+ metadata.gz: '05698dd4f09201f6c1daa2243b0aa3c8e4283e176c5351f086cd6e1ff8a471f2'
4
+ data.tar.gz: 599205907b70d6d6ed6989b240bbcae26309954f689c41d121ce31bf6cbf0827
5
5
  SHA512:
6
- metadata.gz: 71f396074db45724013b28183faf85f41451d2d668c253235f7de7cbcfb3ef9b96b547466ddb41f203009aef4dd4a677bbe4481c2e68094f67b7273e0e0d69d5
7
- data.tar.gz: 2383c755732bc302e570a0078689b60f256dd6a4e2d68907eb7809c003bcb9af190c12adcba7a236c11a2b746b9906f8a2e83901397ee2244ee3f3c69da8bf16
6
+ metadata.gz: 167e7ec659bf378efd9e32a5f9fc2f781e13fdfee485396153ab67b6f86cfc65cb9922c575ec8b37bc0902b2dc22f87586b7a8ea8392242de743f28b5595c90d
7
+ data.tar.gz: 18c6bce19eb8be3f829b964984020e743e8069820a3a58772e85c120652072a2e3a184d3205d91b4922479b13afc4e2dc11cacbf372e4a768cdc76544569c99e
data/.DS_Store ADDED
Binary file
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Play fireworks text art animations in your terminal!
4
4
 
5
- ![fireworks_show](./fireworks_show.gif)
5
+ ![fireworks_show](./sample/fireworks_show.gif)
6
6
 
7
7
  ## Installation
8
8
 
@@ -19,7 +19,7 @@ Play fireworks text art animations in your terminal!
19
19
  `Ctrl + C`
20
20
 
21
21
  ## Acknowledgments
22
- This project is a Ruby version of [text_art_animations](https://github.com/rvizzz/text_art_animations) by rvizzz. Thank you for the inspiration and the amazing ASCII art animations!
22
+ This project is a Ruby version of [text_art_animations](https://github.com/rvizzz/text_art_animations) by [rvizzz](https://github.com/rvizzz). Thank you for the inspiration and the amazing ASCII art animations!
23
23
 
24
24
  ## Contributing
25
25
 
data/exe/firew0rks CHANGED
@@ -1,22 +1,31 @@
1
1
  #!/usr/bin/env ruby
2
- require_relative "../lib/firew0rks.rb"
3
- require 'reline'
2
+ require_relative "../lib/firew0rks"
3
+ require_relative "../lib/firew0rks/terminal"
4
4
 
5
- terminal = Reline::ANSI.new
6
- terminal.hide_cursor
5
+ def setup
6
+ Terminal.open_buffer
7
+ Terminal.hide_cursor
8
+ Terminal.clear_screen
9
+ end
10
+
11
+ def clean_up
12
+ Terminal.close_buffer
13
+ Terminal.clear_screen
14
+ Terminal.show_cursor
15
+ end
7
16
 
8
17
  trap("INT") {
9
- terminal.show_cursor
18
+ clean_up
10
19
  puts ""
11
20
  puts "Bye."
12
21
  exit 0
13
22
  }
14
23
 
15
-
16
24
  begin
25
+ setup
17
26
  Fireworks.new.run
18
27
  rescue => error
19
28
  puts error
20
29
  ensure
21
- terminal.show_cursor
30
+ clean_up
22
31
  end
@@ -0,0 +1,34 @@
1
+ # ANSI_escape_code
2
+ # Ref: https://xn--rpa.cc/irl/term.html
3
+ # https://en.wikipedia.org/wiki/ANSI_escape_code#CSIsection
4
+
5
+ class Terminal
6
+ class << self
7
+
8
+ def clear_buffer
9
+ print "\x1b[3J"
10
+ end
11
+
12
+ def clear_screen
13
+ print "\x1b[2J"
14
+ end
15
+
16
+ def hide_cursor
17
+ print "\x1b[?25l"
18
+ end
19
+
20
+ def show_cursor
21
+ print "\x1b[?25h"
22
+ end
23
+
24
+ def open_buffer
25
+ # 打开特殊缓存
26
+ print "\x1b[?1049h"
27
+ end
28
+
29
+ def close_buffer
30
+ # 关闭特殊缓存
31
+ print "\x1b[?1049l"
32
+ end
33
+ end
34
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Firew0rks
4
- VERSION = "0.3.0"
4
+ VERSION = "0.5.0"
5
5
  end
data/lib/firew0rks.rb CHANGED
@@ -3,6 +3,7 @@ require "io/console"
3
3
  require_relative "firew0rks/version"
4
4
  require_relative "firew0rks/frame"
5
5
  require_relative "firew0rks/error"
6
+ require_relative "firew0rks/terminal"
6
7
 
7
8
 
8
9
  class Fireworks
@@ -14,7 +15,7 @@ class Fireworks
14
15
 
15
16
 
16
17
  def clear_screen
17
- $stdout.clear_screen
18
+ Terminal.clear_buffer
18
19
  end
19
20
 
20
21
  def init_screen
@@ -27,7 +28,7 @@ class Fireworks
27
28
  if !@first_frame
28
29
  $stdout.print @backspace_adjust
29
30
  end
30
-
31
+ clear_screen
31
32
  $stdout.print content
32
33
  @first_frame = false
33
34
  sleep(0.05)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: firew0rks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark24
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-01-01 00:00:00.000000000 Z
10
+ date: 2025-01-03 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: "Fireworks in your terminal \U0001F386 power by Ruby"
13
13
  email:
@@ -17,11 +17,11 @@ executables:
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
+ - ".DS_Store"
20
21
  - LICENSE.txt
21
22
  - README.md
22
23
  - Rakefile
23
24
  - exe/firew0rks
24
- - fireworks_show.gif
25
25
  - lib/firew0rks.rb
26
26
  - lib/firew0rks/error.rb
27
27
  - lib/firew0rks/frame.rb
@@ -175,6 +175,7 @@ files:
175
175
  - lib/firew0rks/frames/97.txt
176
176
  - lib/firew0rks/frames/98.txt
177
177
  - lib/firew0rks/frames/99.txt
178
+ - lib/firew0rks/terminal.rb
178
179
  - lib/firew0rks/version.rb
179
180
  - sig/firew0rks.rbs
180
181
  homepage: https://github.com/Mark24Code/firew0rks
data/fireworks_show.gif DELETED
Binary file