ncursesw 1.4.2 → 1.4.3

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.
@@ -0,0 +1,121 @@
1
+ #!/usr/bin/ruby
2
+ # Copyright (c) 2004 by Simon Kaczor <skaczor@cox.net>
3
+ # Example from the NCurses Programming HOWTO
4
+ # This example uses module functions that are documented in the ncurses man page.
5
+ # For a more rubyish approach that uses Ruby objects see form2.rb
6
+ #
7
+ # The original example contained the following copyright:
8
+ # Copyright (c) 2001 by Pradeep Padala. This document may be distributed
9
+ # under the terms set forth in the LDP license at linuxdoc.org/COPYRIGHT.html.
10
+
11
+ require 'ncursesw.rb'
12
+
13
+ begin
14
+ scr = Ncurses.initscr()
15
+ Ncurses.cbreak()
16
+ Ncurses.noecho()
17
+ Ncurses.keypad(scr, true)
18
+
19
+ #create some fields
20
+ fields = Array.new
21
+ fields.push(Ncurses::Form.new_field(1,10,4,18,0,0))
22
+ fields.push(Ncurses::Form.new_field(1,10,6,18,0,0))
23
+
24
+ # set field options
25
+ Ncurses::Form.set_field_back(fields[0], Ncurses::A_UNDERLINE)
26
+ Ncurses::Form.field_opts_off(fields[0], Ncurses::Form::O_AUTOSKIP)
27
+
28
+ Ncurses::Form.set_field_back(fields[1], Ncurses::A_UNDERLINE)
29
+ Ncurses::Form.field_opts_off(fields[1], Ncurses::Form::O_AUTOSKIP)
30
+
31
+
32
+ # create a form
33
+ form = Ncurses::Form.new_form(fields)
34
+
35
+ # post the form and refresh the screen
36
+ Ncurses::Form.post_form(form)
37
+ scr.refresh()
38
+
39
+ Ncurses.mvprintw(4, 10, "Value 1:")
40
+ Ncurses.mvprintw(6, 10, "Value 2:")
41
+ scr.refresh()
42
+
43
+ buf = ""
44
+
45
+ # Loop through to get user requests
46
+ while(true) do
47
+ ret = Ncurses.get_wch()
48
+
49
+ ch = ret[1]
50
+
51
+ Ncurses.mvprintw(8, 10, "Got: #{ch.inspect} (#{[ch].pack("U")})")
52
+
53
+ case (ret[0])
54
+ when Ncurses::OK
55
+ # If this is a normal character, it gets Printed
56
+ #prbuf = fields[0].field_buffer 0
57
+ ##buf = buf.force_encoding('utf-8') + [ch].pack('U')
58
+ #buf = prbuf + [ch].pack('U')
59
+
60
+
61
+ ##buf = sbuf.force_encoding('utf-8') + [ch].pack('U')
62
+ #fields[0].set_field_buffer(0, buf)
63
+ #sbuf = fields[0].field_buffer 0
64
+ ##fields[0].working.add_wch 'a'
65
+ #Ncurses.mvprintw(12, 10, "buf: #{sbuf}")
66
+ #Ncurses.mvprintw(13, 10, "pbuf: #{prbuf}")
67
+ #Ncurses.mvprintw(14, 10, "mbuf: #{buf}")
68
+
69
+ #Ncurses.wadd_wch(form.win, ch)
70
+
71
+ #buf = fields[0].field_buffer(0)
72
+ #buf = buf.force_encoding('utf-8') + [ch].pack("U")
73
+ #fields[0].set_field_buffer(0, buf)
74
+ #fields[0].set_field_buffer(0, [ch].pack("U"))
75
+
76
+ Ncurses::Form.form_driver_w(form, ret[0], ret[1])
77
+ #puts "{fields[0].methods}"
78
+
79
+ #puts "#{form.methods}"
80
+ #puts "#{fields[0].methods}"
81
+ #Ncurses.mvprintw(9, 10, "Type: OK ")
82
+ when Ncurses::KEY_CODE_YES
83
+ Ncurses.mvprintw(9, 10, "Type: KEY_CODE_YES")
84
+ case(ch)
85
+ when Ncurses::KEY_DOWN
86
+ # Go to next field
87
+ Ncurses::Form.form_driver(form, Ncurses::Form::REQ_NEXT_FIELD)
88
+ # Go to the end of the present buffer
89
+ # Leaves nicely at the last character
90
+ Ncurses::Form.form_driver(form, Ncurses::Form::REQ_END_LINE)
91
+
92
+ when Ncurses::KEY_UP
93
+ #Go to previous field
94
+ Ncurses::Form.form_driver(form, Ncurses::Form::REQ_PREV_FIELD)
95
+ Ncurses::Form.form_driver(form, Ncurses::Form::REQ_END_LINE);
96
+ end
97
+ else
98
+ Ncurses.mvprintw(9, 10, "Type: Unknown: #{ret[0].inspect} ")
99
+ end
100
+ end
101
+
102
+ # unpost and free form
103
+ Ncurses::Form.unpost_form(form);
104
+ Ncurses::Form.free_form(form)
105
+ Ncurses::Form.free_field(fields[0]);
106
+ Ncurses::Form.free_field(fields[1]);
107
+
108
+
109
+ #using class methods this time
110
+ # form = Ncurses::Form::FORM.new(fields)
111
+ # puts "Created form: #{form.inspect}\n"
112
+ # form.free()
113
+
114
+ ensure
115
+ # put the screen back in its normal state
116
+ Ncurses.echo()
117
+ Ncurses.nocbreak()
118
+ Ncurses.nl()
119
+ Ncurses.endwin()
120
+ end
121
+
data/ncurses_wrap.c CHANGED
File without changes
data/panel_wrap.h CHANGED
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ncursesw
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.4.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-12-13 00:00:00.000000000 Z
13
+ date: 2014-01-14 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: Tweaked version of ncursesw from http://ncurses-ruby.berlios.de/.
16
16
  email:
@@ -22,14 +22,13 @@ extra_rdoc_files: []
22
22
  files:
23
23
  - Changes
24
24
  - COPYING
25
- - MANIFEST
26
25
  - README
27
26
  - THANKS
28
27
  - TODO
29
- - VERSION
30
28
  - examples/example.rb
31
29
  - examples/form.rb
32
30
  - examples/form2.rb
31
+ - examples/form_get_wch.rb
33
32
  - examples/hello_ncurses.rb
34
33
  - examples/LICENSES_for_examples
35
34
  - examples/rain.rb
@@ -39,7 +38,6 @@ files:
39
38
  - extconf.rb
40
39
  - form_wrap.c
41
40
  - form_wrap.h
42
- - make_dist.rb
43
41
  - ncurses_wrap.c
44
42
  - ncurses_wrap.h
45
43
  - lib/ncursesw.rb
data/MANIFEST DELETED
@@ -1,28 +0,0 @@
1
- Changes
2
- COPYING
3
- MANIFEST
4
- README
5
- THANKS
6
- TODO
7
- VERSION
8
- examples/example.rb
9
- examples/form.rb
10
- examples/form2.rb
11
- examples/hello_ncurses.rb
12
- examples/LICENSES_for_examples
13
- examples/rain.rb
14
- examples/tclock.rb
15
- examples/read_line.rb
16
- examples/test_scanw.rb
17
- extconf.rb
18
- form_wrap.c
19
- form_wrap.h
20
- make_dist.rb
21
- ncurses_wrap.c
22
- ncurses_wrap.h
23
- lib/ncurses.rb
24
- panel_wrap.c
25
- panel_wrap.h
26
- menu_wrap.c
27
- menu_wrap.h
28
-
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.4.2
data/make_dist.rb DELETED
@@ -1,38 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # (C) 2002-2011 Tobias Herzke
3
- # License: LGPL v2.1
4
- # $Id: make_dist.rb,v 1.8 2011-05-30 23:05:50 t-peters Exp $
5
-
6
- require "fileutils"
7
-
8
- def sys(i)
9
- puts("\"#{i}\"")
10
- system(i)
11
- end
12
-
13
- dir = File.dirname(__FILE__)
14
-
15
- %w(ncurses ncursesw).each{|flavor|
16
-
17
- base = flavor+"-ruby"
18
-
19
- files = IO.readlines(dir + "/MANIFEST_"+flavor).collect{|filename|filename.chomp}
20
-
21
- Version = File.new("#{dir}/VERSION").readline.chomp
22
-
23
- FileUtils.mkdir "#{base}-#{Version}"
24
- files.each{|filename|
25
- if filename.index "/"
26
- FileUtils.mkdir_p "#{base}-#{Version}/#{File.dirname(filename)}"
27
- end
28
- if filename.index("example")
29
- sys "sed -e '/require/ s/ncurses/#{flavor}/' <#{dir}/#{filename} >#{base}-#{Version}/#{filename}"
30
- else
31
- sys "cp #{dir}/#{filename} #{base}-#{Version}/#{filename}"
32
- end
33
- }
34
- sys "cp #{dir}/extconf_#{flavor}.rb #{base}-#{Version}/extconf.rb"
35
- sys "tar cjf #{base}-#{Version}.tar.bz2 --owner=0 --group=0 #{base}-#{Version}"
36
-
37
- sys "rm -r #{base}-#{Version}/"
38
- }