File: edit.c

package info (click to toggle)
aca 0.1.6
  • links: PTS
  • area: main
  • in suites: woody
  • size: 492 kB
  • ctags: 569
  • sloc: ansic: 4,254; sh: 2,237; makefile: 256
file content (69 lines) | stat: -rw-r--r-- 1,911 bytes parent folder | download | duplicates (2)
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

//#define EXAMPLE_EDIT

/* 
	--- ACA example ---
*/	

#include <aca/aca.h>
#include <aca/aca_widget.h>

#include "examples_colors.h"

   void spec_resize(void *data)
   {
   	W_redraw_session((SessW *) data);
   }

   void bgr_examp(SessW *s)
   {
      clean_box(0, 0, LINES, COLS, WHITE_BLUE); 
      center_addnstr(2, COLS/2, "ACA edit example\n{ QUIT: press button quit or key F10 }", 40);		
      mvaddstr(LINES-1, COLS-17,"(C) Zakkr - 1999");
   }

   int main() {
      char	str[] = 
   	   "First line\n2bla-bla-bla\n3bla bla\n4bla-bla-bla
5bla bla\n6bla-bla-bla\n7bla bla\n8bla-bla-bla\n9bla bla\n10bla-bla-bla
11bla bla\n12bla-bla-bla\n13bla bla\n14bla-bla-blabla bla\n15bla-bla-bla
16bla bla\nLast line";
 
      char	buff[BUFSIZ*10]; 
      Edata	edata = { buff, BUFSIZ*10 };	
      Wmenu	m = { " Edit: ", 0, M_DESCRIPT|M_TITLE|M_COLORIN|M_BORDER|M_SHTMENU|M_EDIT|M_OPEN,
   	   0,0,0,8,0,0,0,10,0,0, alistN, (void *) &edata, mpr_edit, mpr_descript, 
   	   "This text is description."  };	
  
      Widget	w[] = {
   	   { TRUE, 7, 10,8,40, menu_fn,   (void *) &m, Wf_DEFAULT, NULL },
   	   { TRUE, 20,10,0,0,  button_fn, (void *) &def_button[_BUTT_QUIT], Wf_DEFAULT, ACA_TD },
   	   W_NULL
      };
      SessW	s;

      setlocale(LC_MESSAGES, "");

      strcpy(buff, str);
      init_edit(&m, &edata);
      
      init_aca(TRUE);
      examples_colors(); 
      init_keys((aca_INI *) NULL); 	
      aca.extra_resize		= TRUE;
      aca.extra_resize_call_fn 	= spec_resize;
      aca.extra_resize_data	= (void *) &s;

      init_sessw(&s, 0, FALSE, w, bgr_examp, Sf_DEFAULT);

      W_redraw_session(&s);
      do {
         if (s.key == K_SCREEN_RESIZED) continue;
         if (run_act_widget(&s) & Wr_BUTTON_PRESS) 
            exit(RE_OK);							
         W_key_to_widgets(&s);		
         W_default_go(&s);
      } while((s.key = get_k()) != KEY_F(10));  
   
      exit(RE_OK);							
   }