3 * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org)
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
26 #include <libx/base.h>
27 #include <libx/object.h>
28 #include <libx/image.h>
29 #include <libx/cursor.h>
30 #include <libx/text.h>
36 #include "filemanager.h"
40 unsigned tview_act
= 0;
45 unsigned tview_open (char *name
)
47 if (tview_act
|| !name
)
50 file
= (char *) malloc (sizeof (char) * 2049);
56 int fd
= open (name
, O_RDONLY
);
66 ret
= read (fd
, file
+len
, 2048);
79 file = (char *) realloc ((void *) file, sizeof (char) * len + 512);
87 tview
= window_create (name
);
99 if (!tview_act
|| !tview
)
106 for (i
= 0; i
< len
; i
++) {
107 if (file
[i
] == '\n') {
112 xtext_putch (tview
->x
+1+(j
*5), tview
->y
+11+(k
*9), 0, file
[i
]);
114 if ((j
*5+1) > tview
->size_x
)
117 if ((11+(k
*9)) > tview
->size_y
)
124 unsigned init_tview ()