Subversion Repositories Kolibri OS

Rev

Rev 6536 | Rev 8930 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
6068 serge 1
#include <_ansi.h>
8777 turbocat 2
#include 
6068 serge 3
#include 
4
#include "io.h"
8777 turbocat 5
#include 
6
 
6068 serge 7
 
8
void load_libconsole();
9
void     __stdcall con_init(unsigned w_w, unsigned w_h, unsigned s_w, unsigned s_h, const char* t);
10
void     __stdcall con_exit(char bCloseWindow);
11
unsigned __stdcall con_get_flags(void);
12
unsigned __stdcall con_set_flags(unsigned new_flags);
13
void     __stdcall con_cls(void);
14
void     __stdcall con_write_string(const char* string, unsigned length);
6536 serge 15
short    __stdcall con_getch2(void);
8777 turbocat 16
char*    __stdcall con_gets(char*, unsigned);
6068 serge 17
 
18
int __gui_mode;
19
 
6536 serge 20
static int console_read(const char *path, void *buff,
21
           size_t offset, size_t count, size_t *done)
22
{
23
    char *p = buff;
8777 turbocat 24
    /*int   cnt = 0;
6536 serge 25
    short c;
8777 turbocat 26
    char  ch;*/
27
    con_gets(p, count+1);
28
    *done = strlen(p);
6536 serge 29
 
30
//   __asm__ volatile("int3");
8777 turbocat 31
/*
6536 serge 32
    do
33
    {
34
        c = con_getch2();
8777 turbocat 35
        printf("%d\n",(char)c);
6536 serge 36
        ch = (char)c;
37
        if(ch != 0)
38
        {
39
            p[cnt] = ch != 0x0D ? ch : 0x0A;
40
            con_write_string(p+cnt, 1);
41
            cnt++;
42
        }
43
    }while(ch != 0x0D);
44
    *done = cnt;
8777 turbocat 45
*/
6536 serge 46
    return 0;
47
}
48
 
6068 serge 49
static int console_write(const char *path, const void *buff,
50
                 size_t offset, size_t count, size_t *writes)
51
{
52
    con_write_string(buff, count);
53
 
54
    *writes = count;
6536 serge 55
    return 0;
6068 serge 56
};
57
 
6074 serge 58
void __init_conio()
6068 serge 59
{
60
    __io_handle *ioh;
61
 
62
    load_libconsole();
6074 serge 63
    con_init(80, 25, 80, 500, "Console application");
6068 serge 64
 
6536 serge 65
    ioh = &__io_tab[STDIN_FILENO];
66
    ioh->mode  = _READ|_ISTTY;
67
    ioh->read  = &console_read;
68
 
6068 serge 69
    ioh = &__io_tab[STDOUT_FILENO];
70
    ioh->mode  = _WRITE|_ISTTY;
71
    ioh->write = &console_write;
72
};
73
 
6074 serge 74
void __fini_conio()
6068 serge 75
{
76
    con_exit(0);
77
}
78