summaryrefslogtreecommitdiffstats
path: root/src/livecode/script.h
blob: 9891d5c2133cccff0f399fcb088d78ece12d0894 (plain)
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
// SPDX-License-Identifier: GPL-2.0-or-later
#ifndef INK_LIVECODE_SCRIPT_H
#define INK_LIVECODE_SCRIPT_H

/*
 * A Janet script for the livecoding experience
 *
 * Authors:
 *   Sol Bekic <s+inkscape@s-ol.nu>
 * Copyright (C) 2019 Authors
 *
 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
 */

#include <string>
#include <giomm/file.h>
#include <giomm/filemonitor.h>
#include <janet.h>

namespace Inkscape {
namespace Livecode {

class Script {
public:
    Script(JanetTable *env, std::string const &path);

    void frame();
    void commit();

private:
    JanetTable *env;
    JanetFunction *function;
    Glib::RefPtr<Gio::File> file;
    Glib::RefPtr<Gio::FileMonitor> monitor;

    void reload();
    void file_changed(const Glib::RefPtr<Gio::File>& file,
                      const Glib::RefPtr<Gio::File>& other_file,
                      Gio::FileMonitorEvent event);
};

}
}

#endif // INK_LIVECODE_SCRIPT_H

/*
  Local Variables:
  mode:c++
  c-file-style:"stroustrup"
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
  indent-tabs-mode:nil
  fill-column:99
  End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :