|
|
1.1 root 1: #include "curses.ext"
2: /* @(#) _init_cost.c: 1.1 10/17/83 (1.13 8/20/82) */
3:
4: /*
5: * Figure out (roughly) how much each of these capabilities costs.
6: * In the parameterized cases, we just take a typical case and
7: * use that value. This is done only once at startup, since it
8: * would be too expensive for intensive use.
9: */
10: _init_costs()
11: {
12: int c_il0, c_il100;
13: char *tparm();
14:
15: /*
16: * Insert line costs. These are a mess, they do not take into
17: * account parameterized insert line, but rather assume 1 at a time.
18: * Cost is # chars to insert one line k lines from bottom of screen.
19: */
20: if (insert_line) {
21: #ifdef DEBUG
22: if(outf) fprintf(outf, "real insert line\n");
23: #endif
24: c_il0 = _cost_fn(insert_line,0);
25: c_il100 = _cost_fn(insert_line,100);
26: } else if (change_scroll_region && save_cursor && restore_cursor) {
27: #ifdef DEBUG
28: if(outf) fprintf(outf, "use scrolling region\n");
29: #endif
30: c_il0 = 2*_cost_fn(change_scroll_region,lines-1) +
31: 2*_cost_fn(restore_cursor,0) +
32: _cost_fn(save_cursor,0) + _cost_fn(scroll_reverse,0);
33: c_il100 = c_il0;
34: } else {
35: #ifdef DEBUG
36: if(outf) fprintf(outf, "no insert line\n");
37: #endif
38: c_il0 = c_il100 = INFINITY;
39: }
40: _cost(ilfixed) = c_il0;
41: _cost(ilvar) = ((long)(c_il100 - c_il0)<<32) / 100 ;
42: #ifdef DEBUG
43: if(outf) fprintf(outf,"_init_costs, ilfixed %d, ilvar %d/32,\
44: c_il0 %d, c_il100 %d\n", _cost(ilfixed), _cost(ilvar), c_il0, c_il100);
45: #endif
46:
47: /* This is also a botch: treated as _cost to insert k characters */
48: _cost(icvar) = _cost(icfixed) = 0;
49: if (enter_insert_mode && exit_insert_mode)
50: _cost(icfixed) += _cost_fn(enter_insert_mode,0) +
51: _cost_fn(exit_insert_mode,0);
52: if (parm_ich)
53: _cost(icfixed) = _cost_fn(tparm(parm_ich, 10), 10);
54: else if (insert_character)
55: _cost(icfixed) = 0;
56: else if (_cost(icfixed) == 0)
57: _cost(icfixed) = INFINITY;
58: _cost(icvar) = 1<<5; /* for the character itself */
59: if (!parm_ich) {
60: if (insert_character)
61: _cost(icvar) += _cost_fn(insert_character,1)<<5;
62: if (insert_padding)
63: _cost(icvar) += _cost_fn(insert_padding,1)<<5;
64: }
65: #ifdef DEBUG
66: if (outf) fprintf(outf, "icfixed %d=%d+%d, icvar=%d/32\n",
67: _cost(icfixed), _cost_fn(enter_insert_mode,0),
68: _cost_fn(exit_insert_mode,0), _cost(icvar));
69: if (outf) fprintf(outf, "from ich1 %x '%s' %d\n",
70: insert_character, insert_character,
71: _cost_fn(insert_character,1));
72: if (outf) fprintf(outf, "ip %x '%s' %d\n", insert_padding,
73: insert_padding, _cost_fn(insert_padding));
74: #endif
75:
76: _cost(Cursor_address) = _cost_fn(tparm(cursor_address,8,10),1);
77: _cost(Cursor_home) = _cost_fn(cursor_home,1);
78: _cost(Carriage_return) = _cost_fn(carriage_return,1);
79: _cost(Tab) = _cost_fn(tab,1);
80: _cost(Back_tab) = _cost_fn(back_tab,1);
81: _cost(Cursor_left) = _cost_fn(cursor_left,1);
82: _cost(Cursor_right) = _cost_fn(cursor_right,1);
83: _cost(Right_base) = _cost(Cursor_right);
84: _cost(Cursor_down) = _cost_fn(cursor_down,1);
85: _cost(Cursor_up) = _cost_fn(cursor_up,1);
86: _cost(Parm_left_cursor) = _cost_fn(tparm(parm_left_cursor, 10),1);
87: _cost(Parm_right_cursor)= _cost_fn(tparm(parm_right_cursor, 10),1);
88: _cost(Parm_up_cursor) = _cost_fn(tparm(parm_up_cursor, 10),1);
89: _cost(Parm_down_cursor) = _cost_fn(tparm(parm_down_cursor, 10),1);
90: _cost(Column_address) = _cost_fn(tparm(column_address, 10),1);
91: _cost(Row_address) = _cost_fn(tparm(row_address, 8),1);
92: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.