| 1 | /* |
|---|
| 2 | * Gaycko Text mode web browser |
|---|
| 3 | * Copyright (c) 2011 Jean-Yves Lamoureux <jylam@lnxscene.org> |
|---|
| 4 | * All Rights Reserved |
|---|
| 5 | * |
|---|
| 6 | * This library is free software. It comes without any warranty, to |
|---|
| 7 | * the extent permitted by applicable law. You can redistribute it |
|---|
| 8 | * and/or modify it under the terms of the Do What The Fuck You Want |
|---|
| 9 | * To Public License, Version 2, as published by Sam Hocevar. See |
|---|
| 10 | * http://sam.zoy.org/wtfpl/COPYING for more details. |
|---|
| 11 | */ |
|---|
| 12 | extern "C" { |
|---|
| 13 | #include "gaycko.h" |
|---|
| 14 | #include "io/io.h" |
|---|
| 15 | #include "parse.h" |
|---|
| 16 | #include "js/glue.h" |
|---|
| 17 | #include "renderer.h" |
|---|
| 18 | #include "window.h" |
|---|
| 19 | #include <caca.h> |
|---|
| 20 | } |
|---|
| 21 | |
|---|
| 22 | int main(int argc, char *argv[]) { |
|---|
| 23 | |
|---|
| 24 | caca_display_t *dp; |
|---|
| 25 | caca_event_t ev; |
|---|
| 26 | |
|---|
| 27 | char *tstr = testV8(); |
|---|
| 28 | if(strncmp(tstr, "Hello, World!", 13)) { |
|---|
| 29 | printf("V8 doesn't seem to work : returned '%s', should return 'Hello, World!'\n", tstr); |
|---|
| 30 | } else { |
|---|
| 31 | printf("V8 Javascript engine seems to work ok ('%s')\n", tstr); |
|---|
| 32 | } |
|---|
| 33 | |
|---|
| 34 | if(argc!=2) { |
|---|
| 35 | printf("Usage : %s URL\n", argv[0]); |
|---|
| 36 | return -1; |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | printf("Opening %s\n", argv[1]); |
|---|
| 40 | |
|---|
| 41 | gIO *stream = gaycko_open(argv[1]); |
|---|
| 42 | if(!stream) { |
|---|
| 43 | printf("Can't open %s\n", argv[1]); |
|---|
| 44 | return -1; |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | char *data = gaycko_get_data(stream); |
|---|
| 48 | int size = gaycko_get_size(stream); |
|---|
| 49 | |
|---|
| 50 | gDOM *dom = gaycko_parse(data, size); |
|---|
| 51 | gaycko_close(stream); |
|---|
| 52 | |
|---|
| 53 | gWindow *window = gaycko_create_window(0, 0); |
|---|
| 54 | gaycko_window_set_dom(window, dom); |
|---|
| 55 | gaycko_render(window); |
|---|
| 56 | |
|---|
| 57 | gaycko_display_window(window); |
|---|
| 58 | |
|---|
| 59 | dp = caca_create_display(window->cv); |
|---|
| 60 | if(!dp) { |
|---|
| 61 | printf("Can't open window. CACA_DRIVER problem ?\n"); |
|---|
| 62 | return -1; |
|---|
| 63 | } |
|---|
| 64 | caca_refresh_display(dp); |
|---|
| 65 | caca_get_event(dp, CACA_EVENT_KEY_PRESS, &ev, -1); |
|---|
| 66 | |
|---|
| 67 | destroy_node(dom->root); |
|---|
| 68 | |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | |
|---|