~ubuntu-branches/ubuntu/oneiric/irssi/oneiric

« back to all changes in this revision

Viewing changes to src/fe-text/term-curses.c

  • Committer: Bazaar Package Importer
  • Author(s): Christian Bjälevik
  • Date: 2007-04-28 02:52:01 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070428025201-2c4swxnpn4wr7fpg
Tags: 0.8.11-0ubuntu1
* New upstream release:
  - http://www.irssi.org/news/ChangeLog
* debian/{control,compat}:
  - Bump Standards.
* debian/patches/00list:
  - Disable 05upgrade-check-binary.patch, applied upstream.
  - Disable 08doublefree.patch, applied upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
#include "term.h"
25
25
#include "mainwindows.h"
26
 
 
27
 
#if defined(USE_NCURSES) && !defined(RENAMED_NCURSES)
28
 
#  include <ncurses.h>
29
 
#else
30
 
#  include <curses.h>
 
26
#ifdef HAVE_CUIX
 
27
#include "cuix.h"
31
28
#endif
 
29
 
 
30
#include "term-curses.h"
 
31
 
32
32
#include <termios.h>
33
33
#include <signal.h>
34
34
 
44
44
#  define _POSIX_VDISABLE 0
45
45
#endif
46
46
 
47
 
struct _TERM_WINDOW {
48
 
        int x, y;
49
 
        int width, height;
50
 
        WINDOW *win;
51
 
};
52
 
 
53
47
TERM_WINDOW *root_window;
54
48
 
55
49
static int curs_x, curs_y;
276
270
 
277
271
        if (!term_use_colors)
278
272
                attr = (color & 0x70) ? A_REVERSE : 0;
279
 
        else if (((color & 0x0f) == 8) && (color & ATTR_BOLD) == 0)
280
 
                attr = (A_DIM | COLOR_PAIR(63));
 
273
        else if ((color & 0xff) == 8 || (color & (0xff | ATTR_RESETFG)) == 0)
 
274
                attr = COLOR_PAIR(63);
281
275
        else if ((color & 0x77) == 0)
282
276
                attr = A_NORMAL;
283
277
        else {
285
279
                        color &= ~0x0f;
286
280
                        color |= settings_get_int("default_color");
287
281
                }
288
 
                attr = (COLOR_PAIR((color&7) + (color&0x70)/2));
 
282
                attr = COLOR_PAIR((color&7) | ((color&0x70)>>1));
289
283
        }
290
284
 
291
285
        if ((color & 0x08) || (color & ATTR_BOLD)) attr |= A_BOLD;
315
309
 
316
310
void term_add_unichar(TERM_WINDOW *window, unichar chr)
317
311
{
 
312
#ifdef WIDEC_CURSES
 
313
        cchar_t wch;
 
314
        wchar_t temp[2];
 
315
        temp[0] = chr;
 
316
        temp[1] = 0;
 
317
        if (setcchar(&wch, temp, A_NORMAL, 0, NULL) == OK)
 
318
                wadd_wch(window->win, &wch);
 
319
        else
 
320
#endif
318
321
        waddch(window->win, chr);
319
322
}
320
323
 
349
352
 
350
353
void term_refresh(TERM_WINDOW *window)
351
354
{
 
355
#ifdef HAVE_CUIX
 
356
    if (!cuix_active) {
 
357
#endif
352
358
        if (window != NULL)
353
359
                wnoutrefresh(window->win);
354
360
 
355
361
        if (freeze_refresh == 0) {
356
362
                move(curs_y, curs_x);
357
363
                wnoutrefresh(stdscr);
 
364
#ifdef HAVE_CUIX
 
365
                cuix_refresh ();
 
366
#endif
358
367
                doupdate();
359
368
        }
 
369
#ifdef HAVE_CUIX
 
370
    } else {
 
371
        update_panels ();
 
372
        doupdate ();
 
373
    }
 
374
#endif
360
375
}
361
376
 
362
377
void term_stop(void)
377
392
 
378
393
int term_gets(unichar *buffer, int size)
379
394
{
380
 
        int key, count;
 
395
        int count;
 
396
#ifdef WIDEC_CURSES
 
397
        wint_t key;
 
398
#else
 
399
        int key;
 
400
#endif
381
401
 
382
402
        for (count = 0; count < size; ) {
383
 
                key = getch();
 
403
#ifdef WIDEC_CURSES
 
404
                if (get_wch(&key) == ERR)
 
405
#else
 
406
                if ((key = getch()) == ERR)
 
407
#endif
 
408
                        break;
384
409
#ifdef KEY_RESIZE
385
410
                if (key == KEY_RESIZE)
386
411
                        continue;
387
412
#endif
388
413
 
389
 
                if (key == ERR)
390
 
                        break;
391
 
 
392
 
                buffer[count] = key;
393
 
                count++;
 
414
                buffer[count++] = key;
394
415
        }
395
416
 
396
417
        return count;