wassup 0.1.0 → 0.2.1

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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +3 -0
  3. data/.gitignore +4 -0
  4. data/README.md +45 -5
  5. data/bin/wassup +8 -1
  6. data/docs/.gitignore +20 -0
  7. data/docs/README.md +41 -0
  8. data/docs/babel.config.js +3 -0
  9. data/docs/blog/2021-12-09-welcome/index.md +8 -0
  10. data/docs/blog/authors.yml +5 -0
  11. data/docs/docs/Supfile-basics/_category_.json +4 -0
  12. data/docs/docs/Supfile-basics/understanding-the-supfile.md +50 -0
  13. data/docs/docs/intro.md +54 -0
  14. data/docs/docusaurus.config.js +110 -0
  15. data/docs/package-lock.json +21196 -0
  16. data/docs/package.json +43 -0
  17. data/docs/sidebars.js +31 -0
  18. data/docs/src/components/HomepageFeatures.module.css +10 -0
  19. data/docs/src/components/HomepageFeatures.tsx +60 -0
  20. data/docs/src/css/custom.css +28 -0
  21. data/docs/src/pages/index.module.css +36 -0
  22. data/docs/src/pages/index.tsx +39 -0
  23. data/docs/src/pages/markdown-page.md +7 -0
  24. data/docs/static/.nojekyll +0 -0
  25. data/docs/static/img/demo-supfile.png +0 -0
  26. data/docs/static/img/favicon.ico +0 -0
  27. data/docs/static/img/logo.svg +27 -0
  28. data/docs/static/img/tutorial/docsVersionDropdown.png +0 -0
  29. data/docs/static/img/tutorial/localeDropdown.png +0 -0
  30. data/docs/static/img/tutorial-intro-starter-screenshot.png +0 -0
  31. data/docs/static/img/undraw_docusaurus_mountain.svg +170 -0
  32. data/docs/static/img/undraw_docusaurus_react.svg +169 -0
  33. data/docs/static/img/undraw_docusaurus_tree.svg +1 -0
  34. data/docs/static/img/wassup-long.png +0 -0
  35. data/docs/static/img/wassup-screenshot.png +0 -0
  36. data/docs/static/img/wassup.png +0 -0
  37. data/docs/static/video/wassup-demo.mov +0 -0
  38. data/docs/tsconfig.json +7 -0
  39. data/examples/basic/Supfile +28 -0
  40. data/examples/debug/Supfile +116 -0
  41. data/examples/josh-fastlane/README.md +14 -0
  42. data/examples/josh-fastlane/Supfile +59 -35
  43. data/examples/josh-fastlane/demo.png +0 -0
  44. data/examples/starter/Supfile +44 -0
  45. data/lib/wassup/app.rb +82 -9
  46. data/lib/wassup/color.rb +76 -0
  47. data/lib/wassup/pane.rb +255 -82
  48. data/lib/wassup/pane_builder.rb +74 -3
  49. data/lib/wassup/version.rb +1 -1
  50. data/lib/wassup.rb +1 -0
  51. metadata +42 -2
@@ -0,0 +1,44 @@
1
+ add_pane do |pane|
2
+ pane.height = 0.5
3
+ pane.width = 0.4
4
+ pane.top = 0
5
+ pane.left = 0
6
+
7
+ pane.highlight = false
8
+ pane.title = "Current Time"
9
+
10
+ pane.interval = 1
11
+ pane.content do |content|
12
+ date = `date`
13
+
14
+ content.add_row(date)
15
+ end
16
+ end
17
+
18
+ add_pane do |pane|
19
+ pane.height = 0.5
20
+ pane.width = 0.6
21
+ pane.top = 0
22
+ pane.left = 0.4
23
+
24
+ pane.highlight = false
25
+ pane.title = "Open PRs - fastlane/fastlane"
26
+
27
+ pane.interval = 60 * 5
28
+ pane.content do |content|
29
+ require 'uri'
30
+ require 'net/http'
31
+ require 'json'
32
+
33
+ uri = URI('https://api.github.com/repos/fastlane/fastlane/pulls')
34
+ res = Net::HTTP.get_response(uri)
35
+
36
+ JSON.parse(res.body).each do |pr|
37
+ display = "[fg=cyan]##{pr['number']} - [fg=white]#{pr['title']}"
38
+ content.add_row(display)
39
+ end
40
+ end
41
+ pane.selection do |pr|
42
+ `open #{pr['html_url']}`
43
+ end
44
+ end
data/lib/wassup/app.rb CHANGED
@@ -10,10 +10,12 @@ module Wassup
10
10
 
11
11
  Curses.stdscr.scrollok true
12
12
 
13
- Curses.init_pair(1, 15, 0) #white foreground, black background
14
- Curses.init_pair(2, 2, 0) # red foreground, black background
15
- Curses.init_pair(3, 7, 3) # white foreground, yellow background
16
- Curses.init_pair(4, 0, 15) # white foreground, yellow background
13
+ Wassup::Color.init
14
+
15
+ # Determines the colors in the 'attron' below
16
+
17
+ #Curses.init_pair(Curses::COLOR_BLUE,Curses::COLOR_BLUE,Curses::COLOR_BLACK)
18
+ #Curses.init_pair(Curses::COLOR_RED,Curses::COLOR_RED,Curses::COLOR_BLACK)
17
19
 
18
20
  app = App.new(path: path)
19
21
  end
@@ -29,11 +31,14 @@ module Wassup
29
31
  pane_builder.top,
30
32
  pane_builder.left,
31
33
  title: pane_builder.title,
34
+ description: pane_builder.description,
32
35
  highlight: pane_builder.highlight,
33
36
  focus_number: number,
34
37
  interval: pane_builder.interval,
38
+ show_refresh: pane_builder.show_refresh,
35
39
  content_block: pane_builder.content_block,
36
- selection_block: pane_builder.selection_block
40
+ selection_blocks: pane_builder.selection_blocks,
41
+ selection_blocks_description: pane_builder.selection_blocks_description
37
42
  )
38
43
  pane.focus_handler = @focus_handler
39
44
  @panes[number.to_s] = pane
@@ -41,10 +46,21 @@ module Wassup
41
46
 
42
47
  def initialize(path:)
43
48
  @hidden_pane = nil
49
+ @help_pane = nil
44
50
  @focused_pane = nil
45
51
  @panes = {}
46
52
 
53
+ @redraw_panes = false
54
+
55
+ # TODO: this could maybe get replaced with selection_blocks now
47
56
  @focus_handler = Proc.new do |input|
57
+ if input == "q"
58
+ exit
59
+ elsif input == "?"
60
+ toggle_help
61
+ next true
62
+ end
63
+
48
64
  if (pane = @panes[input.to_s])
49
65
  @focused_pane.focused = false
50
66
 
@@ -66,8 +82,7 @@ module Wassup
66
82
  end
67
83
 
68
84
  begin
69
-
70
- @hidden_pane = Pane.new(0, 0, 0, 0, highlight: false, focus_number: 0, interval: nil, content_block: nil, selection_block: nil)
85
+ @hidden_pane = Pane.new(0, 0, 0, 0, highlight: false, focus_number: 0, interval: nil, show_refresh: false, content_block: nil, selection_blocks: nil, selection_blocks_description: nil)
71
86
  @hidden_pane.focus_handler = @focus_handler
72
87
  @focused_pane = @hidden_pane
73
88
 
@@ -75,13 +90,71 @@ module Wassup
75
90
 
76
91
  loop do
77
92
  @focused_pane.handle_keyboard
78
- @panes.each do |id, pane|
79
- pane.refresh()
93
+
94
+ if @redraw_panes
95
+ Curses.clear
96
+ Curses.refresh
97
+ end
98
+
99
+ # This isn't ideal to now refresh other panes when help is open
100
+ # But it prevents things from getting drawn where the help is showing
101
+ if @help_pane.nil?
102
+ @panes.each do |id, pane|
103
+ pane.redraw() if @redraw_panes
104
+ pane.refresh()
105
+ end
106
+ @redraw_panes = false
107
+ else
108
+ @help_pane.refresh()
80
109
  end
81
110
  end
82
111
  ensure
83
112
  Curses.close_screen
84
113
  end
85
114
  end
115
+
116
+ def toggle_help
117
+ if @help_pane.nil?
118
+ if @focused_pane == @hidden_pane
119
+ content_block = Proc.new do |content|
120
+ items = [
121
+ "Welcome to Wassup!",
122
+ "",
123
+ "Press any number key to focus a pane",
124
+ "j - moves row highlight down",
125
+ "k - moves row highlight up",
126
+ "<Enter> - perform selection on highlighted row",
127
+ "",
128
+ "? - opens help for focused pane"
129
+ ]
130
+
131
+ items.each do |item|
132
+ content.add_row(item)
133
+ end
134
+ end
135
+ else
136
+ content_block = Proc.new do |content|
137
+ items = [
138
+ @focused_pane.description,
139
+ "",
140
+ @focused_pane.selection_blocks_description.map do |k,v|
141
+ "#{k} - #{v}"
142
+ end
143
+ ].flatten.compact
144
+
145
+ items.each do |item|
146
+ content.add_row(item)
147
+ end
148
+ end
149
+ end
150
+
151
+ # Maybe find a way to add some a second border or an clear border to add more space to show its floating
152
+ @help_pane = Pane.new(0.5, 0.5, 0.25, 0.25, title: "Help", highlight: false, focus_number: nil, interval: 100, show_refresh: false, content_block: content_block, selection_blocks: nil, selection_blocks_description: nil)
153
+ else
154
+ @help_pane.close
155
+ @help_pane = nil
156
+ @redraw_panes = true
157
+ end
158
+ end
86
159
  end
87
160
  end
@@ -0,0 +1,76 @@
1
+ require 'curses'
2
+
3
+ module Wassup
4
+ class Color
5
+ attr_accessor :color_pair
6
+
7
+ module Pair
8
+ BLACK = 0
9
+ BLUE = 1
10
+ CYAN = 2
11
+ GREEN = 3
12
+ MAGENTA = 4
13
+ RED = 5
14
+ WHITE = 15
15
+ YELLOW = 7
16
+
17
+ NORMAL = 20
18
+ HIGHLIGHT = 21
19
+
20
+ BORDER = 20
21
+ BORDER_FOCUS = 7
22
+
23
+ TITLE = 20
24
+ TITLE_FOCUS = 20
25
+ end
26
+
27
+ def self.init
28
+ Curses.use_default_colors()
29
+
30
+ Curses.init_pair(Pair::NORMAL, Pair::WHITE, 0) #white foreground, black background
31
+ Curses.init_pair(Pair::HIGHLIGHT, 0, Pair::WHITE) # black foreground, white background
32
+
33
+ # Curses.init_pair(Pair::BORDER, Pair::WHITE, 0) #white foreground, black background
34
+ # Curses.init_pair(Pair::BORDER_FOCUS, Pair::MAGENTA, 0) #white foreground, black background
35
+ #
36
+ # Curses.init_pair(Pair::TITLE, Pair::WHITE, 0) #white foreground, black background
37
+ # Curses.init_pair(Pair::TITLE_FOCUS, Pair::WHITE, 0) #white foreground, black background
38
+
39
+ Curses.init_pair(Pair::BLACK, Curses::COLOR_BLACK, 0)
40
+ Curses.init_pair(Pair::BLUE, Curses::COLOR_BLUE, 0)
41
+ Curses.init_pair(Pair::CYAN, Curses::COLOR_CYAN, 0)
42
+ Curses.init_pair(Pair::GREEN, Curses::COLOR_GREEN, 0)
43
+ Curses.init_pair(Pair::MAGENTA, Curses::COLOR_MAGENTA, 0)
44
+ Curses.init_pair(Pair::RED, Curses::COLOR_RED, 0)
45
+ Curses.init_pair(Pair::WHITE, Pair::WHITE, 0)
46
+ Curses.init_pair(Pair::YELLOW, Curses::COLOR_YELLOW, 0)
47
+ end
48
+
49
+ def initialize(string_name)
50
+ @color_pair = case string_name
51
+ when "black"
52
+ Pair::BLACK
53
+ when "blue"
54
+ Pair::BLUE
55
+ when "cyan"
56
+ Pair::CYAN
57
+ when "green"
58
+ Pair::GREEN
59
+ when "magenta"
60
+ Pair::MAGENTA
61
+ when "red"
62
+ Pair::RED
63
+ when "white"
64
+ Pair::WHITE
65
+ when "yellow"
66
+ Pair::YELLOW
67
+ else
68
+ if string_name.to_i.to_s == string_name
69
+ string_name.to_i
70
+ else
71
+ Pair::WHITE
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end