-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwindow.rs
1136 lines (1014 loc) · 33.3 KB
/
window.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ------------------------------------------------------------------
// Copyright 2012 Derek A. Rhodes. All rights reserved.
// Use of this source code is governed by the ncurses
// license that can be found in the LICENSE file.
// ------------------------------------------------------------------
// Function Comments Copyright
// (c) 1998-2007,2008 Free Software Foundation, Inc.
// ------------------------------------------------------------------
use std::libc::types::os::arch::c95::{ c_char, c_int, c_short, c_long};
use std::libc::types::common::c95::{ c_void, FILE};
use std::rt::io::Writer;
use nc = ncurses;
use c = ncurses::c;
use t = types;
use types::{TRUE, FALSE, OK, ERR};
use std::char::from_u32;
use std::rt::io;
pub struct Window {
win: *t::WINDOW
}
/// Drop the window and cleanup the underlying C memory.
impl Drop for Window {
#[fixed_stack_segment]
fn drop(&mut self) {
unsafe {
c::delwin(self.win);
}
}
}
/// initscr() is used to initialize the ncurses data structures and to
/// read the proper terminfo file. Memory for and will be allocated. If an
/// error occurs, initscr will return Err, otherwise a pointer to will be
/// returned. Additionally, the screen will be erased and and will be
/// initialized.
#[fixed_stack_segment]
pub fn initscr() -> Window {
unsafe {
Window{win: c::initscr()}
}
}
/// Calling newwin creates and returns a pointer to a new window with the
/// given number of lines and columns. The upper left-hand corner of the
/// window is at line begin_y, column begin_x. If either nlines or ncols
/// is zero, they default to LINES - begin_y and COLS - begin_x. A new
/// full-screen window is created by calling newwin(0,0,0,0).
#[fixed_stack_segment]
pub fn newwin(nlines: i32, ncols: i32,
begin_y: i32, begin_x: i32) -> Window {
unsafe {
Window{win: c::newwin(nlines, ncols, begin_y, begin_x)}
}
}
impl Window {
/// screenShot dumps a verbatim copy of the window to a file, with the
/// exception of Newlines appended to the end of rows for human
/// readability
pub fn screenShot(&self, filename: ~str) {
let bottom = self.getmaxy();
let right = self.getmaxx();
let p = &Path::new(filename);
let mut of = io::file::open(p, io::Create, io::Write).unwrap();
// when chtype is understood better
// conform these to chars, not [u8]s
let mut bs: ~[u8] = ~[];
for row in range(0, bottom) {
for col in range(0, right) {
match self.mvwinch(row, col) {
Some(c) => {
bs.push(c as u8);
}
None => {
bs.push('?' as u8);
}
}
}
bs.push('\n' as u8);
}
of.write(bs);
}
#[fixed_stack_segment]
/// Endwin will clean up all allocated resources from ncurses and restore
/// the tty modes to the status they had before calling initscr(). It must
/// be called before any other function from the ncurses library and
/// endwin() must be called before your program exits. When you want to do
/// output to more than one terminal, you can use newterm(...) instead of
/// initscr().
pub fn endwin(&self) {
unsafe { c::endwin(); }
}
/// Write the characters of the string str on the window starting at
/// the current or specified position using the background rendition.
#[fixed_stack_segment]
pub fn addstr(&self, y: int, x: int, s: ~str) {
unsafe {
self.mv(y, x);
let cs = s.to_c_str().unwrap();
c::addstr(cs);
}
}
/// Move to a point in the window. The coordinate y always refers to
/// the row (of the window), and x always refers to the column. The
/// upper left-hand corner is always (0,0), not (1,1).
#[fixed_stack_segment]
pub fn mv (&self, y: int, x: int) -> int {
unsafe {
c::wmove(self.win, y as c_int, x as c_int) as int
}
}
/// Getter for C structure field: nodelay
#[fixed_stack_segment]
pub fn is_nodelay (&self) -> bool {
unsafe {
c::is_nodelay(self.win)
}
}
/// Getter for C WINDOW field: notimeout
#[fixed_stack_segment]
pub fn is_notimeout (&self) -> bool {
unsafe {
c::is_notimeout(self.win)
}
}
/// Getter for C WINDOW field: scrollok
#[fixed_stack_segment]
pub fn is_scrollok(&self) -> bool {
unsafe {
c::is_scrollok(self.win)
}
}
/// Getter for C WINDOW field: cleared
#[fixed_stack_segment]
pub fn is_cleared (&self) -> bool {
unsafe {
c::is_cleared(self.win)
}
}
/// Getter for C WINDOW field: idcok
#[fixed_stack_segment]
pub fn is_idcok (&self) -> bool {
unsafe {
c::is_idcok(self.win)
}
}
/// Getter for C WINDOW field: idlok
#[fixed_stack_segment]
pub fn is_idlok (&self) -> bool {
unsafe {
c::is_idlok(self.win)
}
}
/// Getter for C WINDOW field: immedok
#[fixed_stack_segment]
pub fn is_immedok (&self) -> bool {
unsafe {
c::is_immedok(self.win)
}
}
/// Getter for C WINDOW field: keypad
#[fixed_stack_segment]
pub fn is_keypad (&self) -> bool {
unsafe {
c::is_keypad(self.win)
}
}
/// Getter for C WINDOW field: leaveok
#[fixed_stack_segment]
pub fn is_leaveok (&self) -> bool {
unsafe {
c::is_leaveok(self.win)
}
}
/// Getter for C WINDOW field: syncok
#[fixed_stack_segment]
pub fn is_syncok (&self) -> bool {
unsafe {
c::is_syncok(self.win)
}
}
/// returns the top and bottom rows for the scrolling margin as set in wsetscrreg.
#[fixed_stack_segment]
pub fn wgetscrreg (&self) -> (int, int) {
unsafe {
let mut top: c_int = 0;
let mut bottom: c_int = 0;
let err = c::wgetscrreg(self.win, &top, &bottom);
if err != OK {
error!("window.wgetscreg produced an error.");
error!("Err: {}", err);
}
return (top as int, bottom as int);
}
}
/// box(win, verch, horch) is a shorthand for the following call:
/// wborder(win, verch, verch, horch, horch, 0, 0, 0, 0).
#[fixed_stack_segment]
pub fn box (&self, c1: int, c2: int) -> int {
unsafe {
let n1 = c1 as t::chtype;
let n2 = c2 as t::chtype;
return c::box(self.win, n1, n2) as int;
}
}
/// Calling derwin is the same as calling subwin, except that begin_y and
/// begin_x are relative to the origin of the window orig rather than the
/// screen. There is no difference between the subwindows and the derived
/// windows.
#[fixed_stack_segment]
pub fn derwin(&self, nlines: i32, ncols: i32,
begin_y: i32, begin_x: i32) -> Window {
unsafe {
Window{win: c::derwin(self.win, nlines, ncols, begin_y, begin_x)}
}
}
/// Duplicate the window, deep copy.
#[fixed_stack_segment]
pub fn dupwin (&self) -> Window {
unsafe {
let w = c::dupwin(self.win);
return Window{win: w};
}
}
/// Get the window's current background character/attribute pair.
#[fixed_stack_segment]
pub fn getbkgd (&self) -> t::chtype {
unsafe {
c::getbkgd(self.win)
}
}
/// If idcok is called with FALSE as second argument, curses no longer
/// considers using the hardware insert/delete character feature of
/// terminals so equipped. Use of character insert/delete is enabled by
/// default. Calling idcok with TRUE as second argument re-enables use of
/// character insertion and deletion.
#[fixed_stack_segment]
pub fn idcok (&self, b: bool) {
unsafe { c::idcok(self.win, b); }
}
/// If idlok is called with TRUE as second argument, curses considers
/// using the hardware insert/delete line feature of terminals so
/// equipped. Calling idlok with FALSE as second argument disables use of
/// line insertion and deletion. This option should be enabled only if the
/// application needs insert/delete line, for example, for a screen
/// editor. It is disabled by default because insert/delete line tends to
/// be visually annoying when used in applications where it is not really
/// needed. If insert/delete line cannot be used, curses redraws the
/// changed portions of all lines.
#[fixed_stack_segment]
pub fn idlok (&self, b: bool) {
unsafe { c::idlok(self.win, b); }
}
/// If immedok is called with TRUE as argument, any change in the window
/// image, such as the ones caused by waddch, wclrtobot, wscrl, etc.,
/// automatically cause a call to wrefresh. However, it may degrade
/// performance considerably, due to repeated calls to wrefresh. It is
/// disabled by default.
#[fixed_stack_segment]
pub fn immedok (&self, b: bool) {
unsafe { c::immedok(self.win, b); }
}
/// If the intrflush option is enabled, (b is TRUE), when an interrupt
/// key is pressed on the keyboard (interrupt, break, quit) all output in
/// the tty driver queue will be flushed, giving the effect of faster
/// response to the interrupt, but causing curses to have the wrong idea
/// of what is on the screen. Disabling (b is FALSE), the option prevents
/// the flush. The default for the option is inherited from the tty driver
/// settings. The window argument is ignored.
#[fixed_stack_segment]
pub fn intrflush (&self, b: bool) -> i32 {
unsafe { c::intrflush(self.win, b) }
}
/// is_linetouched() returns true if any of the specified lines have
/// been touched since the last refresh operation, else return false.
#[fixed_stack_segment]
pub fn is_linetouched (&self, n: i32) -> bool {
unsafe { c::is_linetouched(self.win, n as c_int) }
}
/// is_windtouched() returns true if any of the specified windows have
/// been touched since the last refresh operation, else return false.
#[fixed_stack_segment]
pub fn is_wintouched (&self) -> bool {
unsafe { c::is_wintouched(self.win) }
}
/// The keypad option enables the keypad of the user's terminal. If
/// enabled (b is TRUE), the user can press a function key (such as an
/// arrow key) and wgetch returns a single value representing the function
/// key, as in KEY_LEFT. If disabled (bf is FALSE), curses does not treat
/// function keys specially and the program has to interpret the escape
/// sequences itself. If the keypad in the terminal can be turned on (made
/// to transmit) and off (made to work locally), turning on this option
/// causes the terminal keypad to be turned on when wgetch is called. The
/// default value for keypad is false.
#[fixed_stack_segment]
pub fn keypad (&self, b: bool) -> i32 {
unsafe { c::keypad(self.win, b) }
}
/// The leaveok option allows the cursor to be left wherever the update
/// happens to leave it. It is useful for applications where the cursor is
/// not used, since it reduces the need for cursor motions.
#[fixed_stack_segment]
pub fn leaveok (&self, b: bool) -> i32 {
unsafe { c::leaveok(self.win, b) }
}
/// Initially, whether the terminal returns 7 or 8 significant bits on
/// input depends on the control mode of the tty driver. To force 8 bits
/// to be returned, invoke meta(win, TRUE); this is equivalent, under
/// POSIX, to setting the CS8 flag on the terminal. To force 7 bits to be
/// returned, invoke meta(win, FALSE); this is equivalent, under POSIX, to
/// setting the CS8 flag on the terminal. The window argument, win, is
/// always ignored. If the terminfo capabilities smm (meta_on) and rmm
/// (meta_off) are defined for the terminal, smm is sent to the terminal
/// when meta(win, TRUE) is called and rmm is sent when meta(win, FALSE)
/// is called.
#[fixed_stack_segment]
pub fn meta (&self, b: bool) -> i32 {
unsafe {c::meta(self.win, b)}
}
/// Calling mvderwin moves a derived window (or subwindow) inside its
/// parent window. The screen-relative parameters of the window are not
/// changed. This routine is used to display different parts of the parent
/// window at the same physical position on the screen.
#[fixed_stack_segment]
pub fn mvderwin (&self, n1: i32, c2: i32) -> i32 {
unsafe {
c::mvderwin(self.win, n1, c2)
}
}
/// mvwaddch puts the character c into the window at its current
/// window position, which is then advanced.
#[fixed_stack_segment]
pub fn mvwaddch (&self, y: i32, x: i32, c: char) -> i32 {
unsafe{
c::mvwaddch (self.win, y, x, c as u32)
}
}
// /// move to (y, x) and add up to n chars from the string `s`
// #[fixed_stack_segment]
// pub fn mvwaddchnstr (&self, y: i32, x: i32, s: ~str, n: i32) -> i32 {
// unsafe {
// // mvwaddchnstr (win: *t::WINDOW, n1: c_int, c2: c_int, ch3: *t::chtype, n4: c_int) -> c_int;
// //c::mvwaddchnstr(self.win, y, x, s.to_c_str().unwrap() as *u32, n)
// let cstr = s.to_c_str().unwrap();
// error!("%S", cstr);
// return c::mvwaddchnstr(self.win, y, x, cstr, n);
// // fn with_ref<T>(&self, f: &fn(*c_char) -> T) -> T
// s.slice(0, n)
// }
// }
/// Doesn't work, only shows the first couple characters, then garbage.
/// almost like it's expecting
#[fixed_stack_segment]
pub fn mvwaddchstr (&self, y: i32, x: i32, s: ~str) -> i32 {
unsafe{
let cs = s.to_c_str().unwrap();
c::mvwaddchstr(self.win, y, x, cs)
}
}
#[fixed_stack_segment]
pub fn mvwaddnstr (&self, n1: i32, c2: i32, s: ~str, n4: i32) -> i32 {
unsafe{
let cs = s.to_c_str().unwrap();
c::mvwaddnstr (self.win, n1, c2, cs, n4)
}
}
#[fixed_stack_segment]
pub fn mvwaddstr (&self, y: i32, x: i32, s: ~str) -> i32 {
unsafe{
let cs = s.to_c_str().unwrap();
c::mvwaddstr(self.win, y, x, cs)
}
}
// NEED TO FIX THIS ONE
// //#[fixed_stack_segment]
// // args clipped pub fn mvwchgat (&self, n1: i32, c2: i32, c3: i32, at4: t::attr_t, s: c_short, v {
// unsafe{
// c::mvwchgat (self.win, n1: i32, c2: i32, c3: i32, at4: t::attr_t, s: c_short, v {
// }
// //}
#[fixed_stack_segment]
pub fn mvwdelch (&self, n1: i32, c2: i32) -> i32 {
unsafe {
c::mvwdelch(self.win, n1, c2)
}
}
#[fixed_stack_segment]
pub fn mvwgetch (&self, n1: i32, c2: i32) -> i32 {
unsafe{
c::mvwgetch(self.win, n1, c2)
}
}
/// mvwgetnstr, moves to y, x and reads at most n characters, thus
/// preventing a possible over flow of the input buffer. Any attempt to
/// enter more characters (other than the terminating newline or carriage
/// return) causes a beep. Function keys also cause a beep and are
/// ignored.
#[fixed_stack_segment]
pub fn mvwgetnstr (&self, n1: i32, c2: i32, s: ~str, n4: i32) -> i32 {
unsafe{
let cs = s.to_c_str().unwrap();
c::mvwgetnstr(self.win, n1, c2, cs, n4)
}
}
/// insert a character into the window
#[fixed_stack_segment]
pub fn mvwinch (&self, y: i32, x: i32) -> Option<char> {
unsafe {
let ch = c::mvwinch(self.win, y, x);
from_u32(ch)
}
}
#[fixed_stack_segment]
pub fn getmaxx (&self) -> i32 {
unsafe {
c::getmaxx(self.win) as i32
}
}
#[fixed_stack_segment]
pub fn getmaxy (&self) -> i32 {
unsafe {
c::getmaxy(self.win) as i32
}
}
#[fixed_stack_segment]
pub fn mvwgetstr (&self, n1: i32, c2: i32, s: ~str) -> i32 {
unsafe {
let cs = s.to_c_str().unwrap();
c::mvwgetstr(self.win, n1, c2, cs)
}
}
// Same as whline except that wmove() is called to move the cursor
// to the position specified by y, x before the line is drawn on the
// window.
#[fixed_stack_segment]
pub fn mvwhline (&self, n1: i32, c2: i32, ch3: t::chtype, n4: i32) -> i32 {
unsafe {
c::mvwhline(self.win, n1, c2, ch3, n4)
}
}
/// Calling mvwin moves the window so that the upper left-hand corner is
/// at position (x, y). If the move would cause the window to be off the
/// screen, it is an error and the window is not moved. Moving subwindows
/// is allowed, but should be avoided.
#[fixed_stack_segment]
pub fn mvwin (&self, y: i32, x: i32) -> i32 {
unsafe {
c::mvwin(self.win, y, x)
}
}
#[fixed_stack_segment]
pub fn mvwinsch (&self, n1: i32, c2: i32, ch3: t::chtype) -> i32 {
unsafe {
c::mvwinsch(self.win, n1, c2, ch3)
}
}
/// These routines insert a character string, as many characters as
/// will fit on the line, before the character under the cursor.All
/// characters to the right of the cursor are shifted right with the
/// possibility of the rightmost characters on the line being lost.
/// The cursor position does not change (after moving to y, x, if
/// specified).The functions with nas the last argument insert a
/// leading substring of at most n characters. If n<=0, then the
/// entire string is inserted.
#[fixed_stack_segment]
pub fn mvwinchstr (&self, n1: i32, c2: i32, ch3: *t::chtype) -> i32 {
unsafe {
c::mvwinchstr(self.win, n1, c2, ch3)
}
}
#[fixed_stack_segment]
pub fn mvwinnstr (&self, n1: i32, c2: i32, s: ~str, n4: i32) -> i32 {
unsafe {
let cs = s.to_c_str().unwrap();
c::mvwinnstr(self.win, n1, c2, cs, n4)
}
}
#[fixed_stack_segment]
pub fn mvwinchnstr (&self, c1: i32, c2: i32, ch3: *t::chtype, n4: i32) -> i32 {
unsafe {
c::mvwinchnstr(self.win, c1, c2, ch3, n4)
}
}
#[fixed_stack_segment]
pub fn mvwinsnstr (&self, n1: i32, c2: i32, c3: ~str, n4: i32) -> i32 {
unsafe {
let cs = c3.to_c_str().unwrap();
c::mvwinsnstr(self.win, n1, c2, cs, n4)
}
}
#[fixed_stack_segment]
pub fn mvwinsstr (&self, y: i32, x: i32, s: ~str) -> i32 {
unsafe {
let cs = s.to_c_str().unwrap();
c::mvwinsstr(self.win, y, x, cs as *c_char)
}
}
#[fixed_stack_segment]
pub fn mvwinstr (&self, y: i32, x: i32, s: ~str) -> i32 {
unsafe {
let cs = s.to_c_str().unwrap();
c::mvwinstr(self.win, y, x , cs as *c_char)
}
}
#[fixed_stack_segment]
pub fn getcurx(&self) -> i32 {
unsafe {
c::getcurx(self.win)
}
}
#[fixed_stack_segment]
pub fn getcury(&self) -> i32 {
unsafe {
c::getcury(self.win)
}
}
#[fixed_stack_segment]
pub fn getbegx(&self) -> i32 {
unsafe {
c::getbegx(self.win)
}
}
#[fixed_stack_segment]
pub fn getbegy(&self) -> i32 {
unsafe {
c::getbegy(self.win)
}
}
#[fixed_stack_segment]
pub fn getparx(&self) -> i32 {
unsafe {
c::getparx(self.win)
}
}
#[fixed_stack_segment]
pub fn getpary(&self) -> i32 {
unsafe {
c::getpary(self.win)
}
}
#[fixed_stack_segment]
pub fn wstandout(&self) -> i32 {
unsafe {
c::wstandout(self.win)
}
}
#[fixed_stack_segment]
pub fn wstandend(&self) -> i32 {
unsafe {
c::wstandend(self.win)
}
}
#[fixed_stack_segment]
pub fn wclear(&self) -> i32 {
unsafe {
c::wclear(self.win)
}
}
#[fixed_stack_segment]
pub fn wclrtobot(&self) -> i32 {
unsafe {
c::wclrtobot(self.win)
}
}
#[fixed_stack_segment]
pub fn wclrtoeol(&self) -> i32 {
unsafe {
c::wclrtoeol(self.win)
}
}
#[fixed_stack_segment]
pub fn wdelch(&self) -> i32 {
unsafe {
c::wdelch(self.win)
}
}
#[fixed_stack_segment]
pub fn wdeleteln(&self) -> i32 {
unsafe {
c::wdeleteln(self.win)
}
}
#[fixed_stack_segment]
pub fn wrefresh(&self) -> i32 {
unsafe {
c::wrefresh(self.win)
}
}
#[fixed_stack_segment]
pub fn redrawwin(&self) -> i32 {
unsafe {
c::redrawwin(self.win)
}
}
#[fixed_stack_segment]
pub fn touchwin(&self) -> i32 {
unsafe {
c::touchwin(self.win)
}
}
#[fixed_stack_segment]
pub fn untouchwin(&self) -> i32 {
unsafe {
c::untouchwin(self.win)
}
}
#[fixed_stack_segment]
pub fn werase(&self) -> i32 {
unsafe {
c::werase(self.win)
}
}
#[fixed_stack_segment]
pub fn wgetch(&self) -> i32 {
unsafe {
c::wgetch(self.win)
}
}
#[fixed_stack_segment]
pub fn winsertln(&self) -> i32 {
unsafe {
c::winsertln(self.win)
}
}
#[fixed_stack_segment]
pub fn wnoutrefresh(&self) -> i32 {
unsafe {
c::wnoutrefresh(self.win)
}
}
#[fixed_stack_segment]
pub fn overlay(&self, other: Window) -> i32 {
unsafe {
c::overlay(self.win, other.win)
}
}
#[fixed_stack_segment]
pub fn overwrite(&self, other: Window) -> i32 {
unsafe {
c::overwrite(self.win, other.win)
}
}
// [u8]?
// #[fixed_stack_segment]
// pub fn wcolor_set(&self, s1: c_short, v2: *c_void) -> i32 {
// unsafe {
// c::wcolor_set(self.win, s1, )
// }
// }
#[fixed_stack_segment]
pub fn pnoutrefresh(&self, n1: i32, c2: i32, c3: i32, c4: i32, c5: i32, c6: i32) -> i32 {
unsafe {
c::pnoutrefresh(self.win, n1, c2, c3, c4, c5, c6)
}
}
#[fixed_stack_segment]
pub fn pechochar(&self, c1: t::chtype) -> i32 {
unsafe {
c::pechochar(self.win, c1)
}
}
#[fixed_stack_segment]
pub fn prefresh(&self, n1: i32, c2: i32, c3: i32, c4: i32, c5: i32, c6: i32) -> i32 {
unsafe {
c::prefresh(self.win, n1, c2, c3, c4, c5, c6)
}
}
#[fixed_stack_segment]
pub fn scrollok(&self, b1: bool) -> i32 {
unsafe {
c::scrollok(self.win, b1)
}
}
#[fixed_stack_segment]
pub fn subpad(&self, n1: i32, c2: i32, c3: i32, n4: i32) -> Window {
unsafe {
Window{win: c::subpad(self.win, n1, c2, c3, n4)}
}
}
#[fixed_stack_segment]
pub fn subwin(&self, n1: i32, c2: i32, c3: i32, n4: i32) -> Window {
unsafe {
Window{win: c::subwin(self.win, n1,c2,c3,n4)}
}
}
#[fixed_stack_segment]
pub fn syncok(&self, b1: bool) -> i32 {
unsafe {
c::syncok(self.win, b1)
}
}
#[fixed_stack_segment]
pub fn touchline(&self, n1: i32, c2: i32) -> i32 {
unsafe {
c::touchline(self.win, n1, c2)
}
}
// VARARGS CONUNDRUM
/*
// #[fixed_stack_segment]
// pub fn vwprintw(&self, c1: *char, va2: t::va_list) -> i32 {
// unsafe {
// c::vwprintw(self.win, c1, va2)
// }
// }
// #[fixed_stack_segment]
// pub fn vw_printw(&self, s: ~str, va2: t::va_list) -> i32 {
// unsafe {
// let cs = s.to_c_str().unwrap();
// c::vw_printw(self.win, cs, va2)
// }
// }
#[fixed_stack_segment]
pub fn vwscanw(&self, s: ~str, va2: t::va_list) -> i32 {
unsafe {
let cs = s.to_c_str().unwrap();
match len
c::vwscanw(self.win, cs, va2)
}
}
#[fixed_stack_segment]
pub fn vw_scanw(&self, c1: *char, va2: t::va_list) -> i32 {
unsafe {
c::vw_scanw(self.win)
}
}
-- END VARARGS CONUNDRUM
*/
/*
ok this is the ncurses source after preprocessor
int waddch(WINDOW *win, const chtype ch) {
int code = (-1);
chtype wch;
wch = (((ch) & (chtype)(((1U) << ((0) + 8)) - 1U))) | (((ch) & (chtype)((~(1U - 1U)) << ((0) + 8))));
if (win && (waddch_nosync(win, wch) != (-1))) {
_nc_synchook(win);
code = (0);
}
return (code);
}
*/
/// The addch, waddch, mvaddch and mvwaddch routines put the character ch
/// into the given window at its current window position, which is then
/// advanced. They are analogous to putchar in stdio(3). If the advance is
/// at the right margin, the cursor automatically wraps to the beginning
/// of the next line. At the bottom of the current scrolling region, if
/// scrollok is enabled, the scrolling region is scrolled up one line.
#[fixed_stack_segment]
pub fn waddch(&self, c1: char) -> i32 {
unsafe {
// // fn encode_utf8(&self, dst: &mut [u8]) -> uint;
// let mut dst = [0,0,0,0];
// c1.encode_utf8(dst);
// //error!("{} {} {} {}", dst[0], dst[1], dst[2], dst[3]);
// let r0 = dst[3] << 24;
// let r1 = dst[2] << 16;
// let r2 = dst[1] << 8;
// let r3 = dst[0];
// let mut r = r0 | r1 | r2 | r3;
// error!("{}", r);
c::waddch(self.win, c1 as t::chtype)
}
}
#[fixed_stack_segment]
pub fn waddchnstr(&self, ch1: *t::chtype, c2: i32) -> i32 {
unsafe {
c::waddchnstr(self.win, ch1, c2)
}
}
#[fixed_stack_segment]
pub fn waddchstr(&self, ch1: *t::chtype) -> i32 {
unsafe {
c::waddchstr(self.win, ch1)
}
}
#[fixed_stack_segment]
pub fn waddnstr(&self, s: ~str, c2: i32) -> i32 {
unsafe {
let cs = s.to_c_str().unwrap();
c::waddnstr(self.win, cs, c2)
}
}
#[fixed_stack_segment]
pub fn waddstr(&self, s: ~str) -> i32 {
unsafe {
let cs = s.to_c_str().unwrap();
c::waddstr(self.win, cs)
}
}
#[fixed_stack_segment]
pub fn wattron(&self, n1: i32) -> i32 {
unsafe {
c::wattron(self.win, n1)
}
}
#[fixed_stack_segment]
pub fn wattroff(&self, n1: i32) -> i32 {
unsafe {
c::wattroff(self.win, n1)
}
}
#[fixed_stack_segment]
pub fn wattrset(&self, n1: i32) -> i32 {
unsafe {
c::wattrset(self.win, n1)
}
}
// how to deal with void? &mut [u8] ?
// #[fixed_stack_segment]
// pub fn wattr_get(&self, at1: *t::attr_t, s2: *c_short, v3: *c_void) -> i32 {
// unsafe {
// c::wattr_get(self.win, at1, s2, v3)
// }
// }
// #[fixed_stack_segment]
// pub fn wattr_on(&self, at2: t::attr_t, v2: *c_void) -> i32 {
// unsafe {
// c::wattr_on(self.win, at2)
// }
// }
// #[fixed_stack_segment]
// pub fn wattr_off(&self, at2: t::attr_t, v2: *c_void) -> i32 {
// unsafe {
// c::wattr_off(self.win)
// }
// }
// #[fixed_stack_segment]
// pub fn wattr_set(&self, at2: t::attr_t, s2: c_short, v3: *c_void) -> i32 {
// unsafe {
// c::wattr_set(self.win)
// }
// }
#[fixed_stack_segment]
pub fn wbkgd(&self, c1: t::chtype) -> i32 {
unsafe {
c::wbkgd(self.win, c1)
}
}
#[fixed_stack_segment]
pub fn wbkgdset(&self, c1: t::chtype) -> c_void {
unsafe {
c::wbkgdset(self.win, c1)
}
}
// #[fixed_stack_segment]
// pub fn wchgat(&self, n1: i32, at: t::attr_t, s3: c_short, v: *c_void) -> i32 {
// unsafe {
// c::wchgat(self.win, n1, at, s4)
// }
// }
#[fixed_stack_segment]
pub fn wechochar(&self, c1: t::chtype) -> i32 {
unsafe {
c::wechochar(self.win, c1)
}
}
#[fixed_stack_segment]
pub fn wgetnstr(&self, s: ~str, c2: i32) -> i32 {
unsafe {
let cs = s.to_c_str().unwrap();
c::wgetnstr(self.win, cs, c2)
}
}
#[fixed_stack_segment]
pub fn wgetstr(&self, s: ~str) -> i32 {
unsafe {
let cs = s.to_c_str().unwrap();
c::wgetstr(self.win, cs)
}
}
#[fixed_stack_segment]
pub fn whline(&self, c1: t::chtype, c2: i32) -> i32 {
unsafe {
c::whline(self.win, c1, c2)
}
}
#[fixed_stack_segment]
pub fn winchnstr(&self, ch1: *t::chtype, c2: i32) -> i32 {
unsafe {
c::winchnstr(self.win, ch1, c2)
}
}
#[fixed_stack_segment]
pub fn winchstr(&self, ch1: *t::chtype) -> i32 {
unsafe {
c::winchstr(self.win, ch1)
}
}
#[fixed_stack_segment]
pub fn winnstr(&self, s: ~str, c2: i32) -> i32 {
unsafe {
let cs = s.to_c_str().unwrap();
c::winnstr(self.win, cs, c2)
}
}
#[fixed_stack_segment]
pub fn winsch(&self, ch: char) -> i32 {
unsafe {
c::winsch(self.win, ch as t::chtype)
}