File: console.m

package info (click to toggle)
vice 2.3.dfsg-4
  • links: PTS
  • area: contrib
  • in suites: wheezy
  • size: 59,228 kB
  • sloc: ansic: 383,974; cpp: 19,069; sh: 12,805; objc: 11,657; makefile: 6,875; perl: 2,492; yacc: 813; lex: 370; asm: 25
file content (95 lines) | stat: -rw-r--r-- 2,521 bytes parent folder | download | duplicates (4)
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
/*
 * console.m - MacVICE console interface
 *
 * Written by
 *  Christian Vogelgsang <chris@vogelgsang.org>
 *  Michael Klein <michael.klein@puffin.lb.shuttle.de>
 *
 * This file is part of VICE, the Versatile Commodore Emulator.
 * See README for copyright notice.
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 *  02111-1307  USA.
 *
 */

#include "vice.h"
#include "console.h"
#include "lib.h"

#import "consolewindow.h"

int console_init(void)
{
    return 0;
}

console_t *console_open(const char *id)
{
    // open console window
    ConsoleWindow *window = [[ConsoleWindow alloc] 
                        initWithContentRect:NSMakeRect(600, 140, 500, 200)
                                      title:[NSString stringWithCString:id
                                            encoding:NSUTF8StringEncoding]];

    // create VICE console structure
    console_t * console;
    console = lib_malloc(sizeof(console_t));
    console->console_xres = 80;
    console->console_yres = 25;
    console->console_can_stay_open = 0;
    console->private = (struct console_private_s*)window;
    return console;
}

int console_close(console_t *log)
{
    // close console window
    ConsoleWindow *window = (ConsoleWindow *)log->private;
    if (window!=nil)
        [window release];

    // close VICE console structure
    lib_free(log);
    return 0;
}

int console_out(console_t *log, const char *format, ...)
{
    char *tmp;
    va_list ap;

    va_start(ap, format);
    tmp = lib_mvsprintf(format, ap);
    va_end(ap);

    if (log && (log->private!=nil) && tmp)
        [(ConsoleWindow*)log->private appendText:[NSString stringWithCString:tmp encoding:NSUTF8StringEncoding]];

    lib_free(tmp);
    return 0;
}

char *console_in(console_t * log, const char * prompt)
{
    // NOT USED
    return NULL;
}

int console_close_all(void)
{
    return 0;
}