Formatted C++ source files in fox-gui directory - gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
diff options
context:
space:
mode:
authorFrancesco Abbate <francesco.bbt@gmail.com>2012年07月31日 18:05:48 +0200
committerFrancesco Abbate <francesco.bbt@gmail.com>2012年07月31日 18:05:48 +0200
commit9ba5202f25c24549b957d1ac4999f020b91db05b (patch)
treee000d807baeae91dbb26a779fa2dea18383f4cbc
parent816557deba04dc5d2e8735e49de51728c2457382 (diff)
downloadgsl-shell-9ba5202f25c24549b957d1ac4999f020b91db05b.tar.gz
Formatted C++ source files in fox-gui directory
Formatted using AStyle with allman style
Diffstat
-rw-r--r--fox-gui/fox_gsl_shell.cpp 20
-rw-r--r--fox-gui/fox_gsl_shell.h 15
-rw-r--r--fox-gui/fx_console.cpp 141
-rw-r--r--fox-gui/fx_console.h 60
-rw-r--r--fox-gui/fx_plot_canvas.cpp 163
-rw-r--r--fox-gui/fx_plot_canvas.h 74
-rw-r--r--fox-gui/fx_plot_window.cpp 25
-rw-r--r--fox-gui/fx_plot_window.h 29
-rw-r--r--fox-gui/gsl-shell-fox.cpp 16
-rw-r--r--fox-gui/gsl_shell_app.cpp 47
-rw-r--r--fox-gui/gsl_shell_app.h 52
-rw-r--r--fox-gui/gsl_shell_interp.cpp 215
-rw-r--r--fox-gui/gsl_shell_interp.h 40
-rw-r--r--fox-gui/gsl_shell_thread.cpp 90
-rw-r--r--fox-gui/gsl_shell_thread.h 69
-rw-r--r--fox-gui/gsl_shell_window.cpp 37
-rw-r--r--fox-gui/gsl_shell_window.h 33
-rw-r--r--fox-gui/image_buf.h 88
-rw-r--r--fox-gui/io_thread.cpp 32
-rw-r--r--fox-gui/io_thread.h 19
-rw-r--r--fox-gui/lua_plot_window.cpp 164
-rw-r--r--fox-gui/redirect.cpp 36
-rw-r--r--fox-gui/redirect.h 14
23 files changed, 773 insertions, 706 deletions
diff --git a/fox-gui/fox_gsl_shell.cpp b/fox-gui/fox_gsl_shell.cpp
index fad85334..ebe6f5dd 100644
--- a/fox-gui/fox_gsl_shell.cpp
+++ b/fox-gui/fox_gsl_shell.cpp
@@ -5,26 +5,26 @@
void fox_gsl_shell::init()
{
- gsl_shell_thread::init();
- fox_window_register(L);
+ gsl_shell_thread::init();
+ fox_window_register(L);
}
void
fox_gsl_shell::before_eval()
{
- unsigned n = m_window_close_queue.size();
- for (unsigned k = 0; k < n; k++)
+ unsigned n = m_window_close_queue.size();
+ for (unsigned k = 0; k < n; k++)
{
- window_index_remove (L, m_window_close_queue[k]);
+ window_index_remove (L, m_window_close_queue[k]);
}
- m_window_close_queue.clear();
+ m_window_close_queue.clear();
}
void
fox_gsl_shell::window_close_notify(int window_id)
{
- pthread::mutex& eval = eval_mutex();
- eval.lock();
- m_window_close_queue.add(window_id);
- eval.unlock();
+ pthread::mutex& eval = eval_mutex();
+ eval.lock();
+ m_window_close_queue.add(window_id);
+ eval.unlock();
}
diff --git a/fox-gui/fox_gsl_shell.h b/fox-gui/fox_gsl_shell.h
index 6ed4eb8d..049802be 100644
--- a/fox-gui/fox_gsl_shell.h
+++ b/fox-gui/fox_gsl_shell.h
@@ -6,18 +6,19 @@
#include "gsl_shell_thread.h"
-class fox_gsl_shell : public gsl_shell_thread {
+class fox_gsl_shell : public gsl_shell_thread
+{
public:
- fox_gsl_shell(FXApp* app): m_app(app) { }
+ fox_gsl_shell(FXApp* app): m_app(app) { }
- virtual void init();
- virtual void before_eval();
+ virtual void init();
+ virtual void before_eval();
- void window_close_notify(int window_id);
+ void window_close_notify(int window_id);
private:
- FXApp* m_app;
- agg::pod_bvector<int> m_window_close_queue;
+ FXApp* m_app;
+ agg::pod_bvector<int> m_window_close_queue;
};
#endif
diff --git a/fox-gui/fx_console.cpp b/fox-gui/fx_console.cpp
index 6037812b..fe30fc75 100644
--- a/fox-gui/fx_console.cpp
+++ b/fox-gui/fx_console.cpp
@@ -8,9 +8,10 @@
#include "gsl_shell_thread.h"
#include "fx_plot_window.h"
-FXDEFMAP(fx_console) fx_console_map[]={
- FXMAPFUNC(SEL_KEYPRESS, 0, fx_console::on_key_press),
- FXMAPFUNC(SEL_IO_READ, fx_console::ID_LUA_OUTPUT, fx_console::on_lua_output),
+FXDEFMAP(fx_console) fx_console_map[]=
+{
+ FXMAPFUNC(SEL_KEYPRESS, 0, fx_console::on_key_press),
+ FXMAPFUNC(SEL_IO_READ, fx_console::ID_LUA_OUTPUT, fx_console::on_lua_output),
};
FXIMPLEMENT(fx_console,FXText,fx_console_map,ARRAYNUMBER(fx_console_map))
@@ -18,115 +19,115 @@ FXIMPLEMENT(fx_console,FXText,fx_console_map,ARRAYNUMBER(fx_console_map))
char const * const fx_console::prompt = "> ";
fx_console::fx_console(gsl_shell_thread* gs, FXComposite *p, FXObject* tgt, FXSelector sel, FXuint opts, FXint x, FXint y, FXint w, FXint h, FXint pl, FXint pr, FXint pt, FXint pb):
- FXText(p, tgt, sel, opts, x, y, w, h, pl, pr, pt, pb),
- m_status(not_ready), m_engine(gs)
+ FXText(p, tgt, sel, opts, x, y, w, h, pl, pr, pt, pb),
+ m_status(not_ready), m_engine(gs)
{
- FXApp* app = getApp();
- m_lua_io_signal = new FXGUISignal(app, this, ID_LUA_OUTPUT);
- m_lua_io_thread = new lua_io_thread(m_engine, m_lua_io_signal, &m_lua_io_mutex, &m_lua_io_buffer);
+ FXApp* app = getApp();
+ m_lua_io_signal = new FXGUISignal(app, this, ID_LUA_OUTPUT);
+ m_lua_io_thread = new lua_io_thread(m_engine, m_lua_io_signal, &m_lua_io_mutex, &m_lua_io_buffer);
}
fx_console::~fx_console()
{
- delete m_lua_io_thread;
- delete m_lua_io_signal;
+ delete m_lua_io_thread;
+ delete m_lua_io_signal;
}
void fx_console::prepare_input()
{
- appendText(prompt, strlen(prompt));
- m_status = input_mode;
- m_input_begin = getCursorPos();
+ appendText(prompt, strlen(prompt));
+ m_status = input_mode;
+ m_input_begin = getCursorPos();
}
void fx_console::show_errors()
{
- if (m_engine->eval_status() == gsl_shell::eval_error)
+ if (m_engine->eval_status() == gsl_shell::eval_error)
{
- appendText("Error reported: ");
- appendText(m_engine->error_msg());
- appendText("\n");
- makePositionVisible(getCursorPos());
+ appendText("Error reported: ");
+ appendText(m_engine->error_msg());
+ appendText("\n");
+ makePositionVisible(getCursorPos());
}
}
void fx_console::create()
{
- FXText::create();
- FXString msg;
- msg.format("GSL Shell %s, Copyright (C) 2009-2012 Francesco Abbate\n"
- "GNU Scientific Library, Copyright (C) The GSL Team\n"
- "%s -- %s\n",
- GSL_SHELL_RELEASE, LUAJIT_VERSION, LUAJIT_COPYRIGHT);
- init(msg);
- setFocus();
- m_lua_io_thread->start();
+ FXText::create();
+ FXString msg;
+ msg.format("GSL Shell %s, Copyright (C) 2009-2012 Francesco Abbate\n"
+ "GNU Scientific Library, Copyright (C) The GSL Team\n"
+ "%s -- %s\n",
+ GSL_SHELL_RELEASE, LUAJIT_VERSION, LUAJIT_COPYRIGHT);
+ init(msg);
+ setFocus();
+ m_lua_io_thread->start();
}
void fx_console::init(const FXString& greeting)
{
- appendText(greeting);
- prepare_input();
+ appendText(greeting);
+ prepare_input();
}
long fx_console::on_key_press(FXObject* obj, FXSelector sel, void* ptr)
{
- FXEvent* event = (FXEvent*)ptr;
- if (event->code == KEY_Return && m_status == input_mode)
+ FXEvent* event = (FXEvent*)ptr;
+ if (event->code == KEY_Return && m_status == input_mode)
{
- FXint pos = getCursorPos();
- FXint line_end = lineEnd(pos), line_start = m_input_begin;
- extractText(m_input, line_start, line_end - line_start);
- appendText("\n");
+ FXint pos = getCursorPos();
+ FXint line_end = lineEnd(pos), line_start = m_input_begin;
+ extractText(m_input, line_start, line_end - line_start);
+ appendText("\n");
- this->m_status = output_mode;
- m_engine->input(m_input.text());
+ this->m_status = output_mode;
+ m_engine->input(m_input.text());
- return 1;
+ return 1;
}
- return FXText::onKeyPress(obj, sel, ptr);
+ return FXText::onKeyPress(obj, sel, ptr);
}
long fx_console::on_lua_output(FXObject* obj, FXSelector sel, void* ptr)
{
- bool eot = false;
+ bool eot = false;
- m_lua_io_mutex.lock();
- FXint len = m_lua_io_buffer.length();
- if (len > 0)
+ m_lua_io_mutex.lock();
+ FXint len = m_lua_io_buffer.length();
+ if (len > 0)
{
- if (m_lua_io_buffer[len-1] == gsl_shell_thread::eot_character)
- {
- eot = true;
- m_lua_io_buffer.trunc(len-1);
- }
+ if (m_lua_io_buffer[len-1] == gsl_shell_thread::eot_character)
+ {
+ eot = true;
+ m_lua_io_buffer.trunc(len-1);
+ }
}
- appendText(m_lua_io_buffer);
- makePositionVisible(getCursorPos());
+ appendText(m_lua_io_buffer);
+ makePositionVisible(getCursorPos());
- m_lua_io_buffer.clear();
- m_lua_io_mutex.unlock();
+ m_lua_io_buffer.clear();
+ m_lua_io_mutex.unlock();
- if (eot)
+ if (eot)
{
- int status = m_engine->eval_status();
-
- if (status == gsl_shell::incomplete_input)
- {
- m_status = input_mode;
- }
- else if (status == gsl_shell::exit_request)
- {
- FXApp* app = getApp();
- app->handle(this, FXSEL(SEL_COMMAND,FXApp::ID_QUIT), NULL);
- }
- else
- {
- show_errors();
- prepare_input();
- }
+ int status = m_engine->eval_status();
+
+ if (status == gsl_shell::incomplete_input)
+ {
+ m_status = input_mode;
+ }
+ else if (status == gsl_shell::exit_request)
+ {
+ FXApp* app = getApp();
+ app->handle(this, FXSEL(SEL_COMMAND,FXApp::ID_QUIT), NULL);
+ }
+ else
+ {
+ show_errors();
+ prepare_input();
+ }
}
- return 1;
+ return 1;
}
diff --git a/fox-gui/fx_console.h b/fox-gui/fx_console.h
index cc5394fb..48199c2a 100644
--- a/fox-gui/fx_console.h
+++ b/fox-gui/fx_console.h
@@ -8,51 +8,53 @@
#include "gsl_shell_thread.h"
#include "io_thread.h"
-class fx_console : public FXText {
- FXDECLARE(fx_console)
+class fx_console : public FXText
+{
+ FXDECLARE(fx_console)
private:
- enum status_e { not_ready, input_mode, output_mode };
+ enum status_e { not_ready, input_mode, output_mode };
- static char const * const prompt;
+ static char const * const prompt;
public:
- fx_console(gsl_shell_thread* gs, FXComposite *p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=3,FXint pr=3,FXint pt=2,FXint pb=2);
+ fx_console(gsl_shell_thread* gs, FXComposite *p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=3,FXint pr=3,FXint pt=2,FXint pb=2);
- ~fx_console();
+ ~fx_console();
- // prepare to accept input
- void init(const FXString& greeting);
- void prepare_input();
- void show_errors();
+ // prepare to accept input
+ void init(const FXString& greeting);
+ void prepare_input();
+ void show_errors();
public:
- virtual void create();
+ virtual void create();
- // void stop() { m_engine.stop(); }
+ // void stop() { m_engine.stop(); }
- long on_key_press(FXObject*,FXSelector,void*);
- long on_lua_output(FXObject*,FXSelector,void*);
+ long on_key_press(FXObject*,FXSelector,void*);
+ long on_lua_output(FXObject*,FXSelector,void*);
- enum {
- ID_READ_INPUT = FXText::ID_LAST,
- ID_LUA_OUTPUT,
- ID_LAST,
- };
+ enum
+ {
+ ID_READ_INPUT = FXText::ID_LAST,
+ ID_LUA_OUTPUT,
+ ID_LAST,
+ };
protected:
- fx_console() {}
+ fx_console() {}
private:
- FXint m_input_begin;
- FXString m_input;
- status_e m_status;
- gsl_shell_thread* m_engine;
-
- lua_io_thread* m_lua_io_thread;
- FXGUISignal* m_lua_io_signal;
- FXMutex m_lua_io_mutex;
- FXString m_lua_io_buffer;
+ FXint m_input_begin;
+ FXString m_input;
+ status_e m_status;
+ gsl_shell_thread* m_engine;
+
+ lua_io_thread* m_lua_io_thread;
+ FXGUISignal* m_lua_io_signal;
+ FXMutex m_lua_io_mutex;
+ FXString m_lua_io_buffer;
};
#endif
diff --git a/fox-gui/fx_plot_canvas.cpp b/fox-gui/fx_plot_canvas.cpp
index cbd9b605..509e8170 100644
--- a/fox-gui/fx_plot_canvas.cpp
+++ b/fox-gui/fx_plot_canvas.cpp
@@ -5,167 +5,168 @@
#include "fatal.h"
#include "lua-graph.h"
-FXDEFMAP(fx_plot_canvas) fx_plot_canvas_map[]={
- FXMAPFUNC(SEL_PAINT, 0, fx_plot_canvas::on_cmd_paint),
- FXMAPFUNC(SEL_UPDATE, 0, fx_plot_canvas::on_update),
+FXDEFMAP(fx_plot_canvas) fx_plot_canvas_map[]=
+{
+ FXMAPFUNC(SEL_PAINT, 0, fx_plot_canvas::on_cmd_paint),
+ FXMAPFUNC(SEL_UPDATE, 0, fx_plot_canvas::on_update),
};
FXIMPLEMENT(fx_plot_canvas,FXCanvas,fx_plot_canvas_map,ARRAYNUMBER(fx_plot_canvas_map));
fx_plot_canvas::fx_plot_canvas(FXComposite* p, FXObject* tgt, FXSelector sel, FXuint opts, FXint x, FXint y, FXint w, FXint h):
- FXCanvas(p, tgt, sel, opts, x, y, w, h),
- m_plot(0), m_canvas(0), m_dirty_flag(true)
+ FXCanvas(p, tgt, sel, opts, x, y, w, h),
+ m_plot(0), m_canvas(0), m_dirty_flag(true)
{
}
fx_plot_canvas::~fx_plot_canvas()
{
- delete m_canvas;
+ delete m_canvas;
}
void fx_plot_canvas::prepare_image_buffer(unsigned ww, unsigned hh)
{
- m_img.resize(ww, hh);
- m_canvas = new canvas(m_img, ww, hh, colors::white);
+ m_img.resize(ww, hh);
+ m_canvas = new canvas(m_img, ww, hh, colors::white);
}
void fx_plot_canvas::ensure_canvas_size(unsigned ww, unsigned hh)
{
- if (m_img.width() != ww || m_img.height() != hh)
+ if (m_img.width() != ww || m_img.height() != hh)
{
- m_area_mtx.sx = ww;
- m_area_mtx.sy = hh;
- prepare_image_buffer(ww, hh);
+ m_area_mtx.sx = ww;
+ m_area_mtx.sy = hh;
+ prepare_image_buffer(ww, hh);
}
}
void fx_plot_canvas::plot_render(agg::trans_affine& m)
{
- m_canvas->clear(colors::white);
- AGG_LOCK();
- m_plot->draw(*m_canvas, m);
- AGG_UNLOCK();
+ m_canvas->clear(colors::white);
+ AGG_LOCK();
+ m_plot->draw(*m_canvas, m);
+ AGG_UNLOCK();
}
void fx_plot_canvas::plot_draw(agg::trans_affine& m)
{
- FXDCWindow dc(this);
- int ww = getWidth(), hh = getHeight();
+ FXDCWindow dc(this);
+ int ww = getWidth(), hh = getHeight();
- ensure_canvas_size(ww, hh);
+ ensure_canvas_size(ww, hh);
- if (m_canvas && m_plot)
+ if (m_canvas && m_plot)
{
- plot_render(m);
+ plot_render(m);
- FXImage img(getApp(), NULL, IMAGE_OWNED|IMAGE_SHMI|IMAGE_SHMP, ww, hh);
- agg::int8u* data = (agg::int8u*) img.getData();
- agg::rendering_buffer rbuf_tmp(data, ww, hh, - ww * 4);
- my_color_conv(&rbuf_tmp, &m_img, color_conv_rgb24_to_rgba32());
- img.create();
+ FXImage img(getApp(), NULL, IMAGE_OWNED|IMAGE_SHMI|IMAGE_SHMP, ww, hh);
+ agg::int8u* data = (agg::int8u*) img.getData();
+ agg::rendering_buffer rbuf_tmp(data, ww, hh, - ww * 4);
+ my_color_conv(&rbuf_tmp, &m_img, color_conv_rgb24_to_rgba32());
+ img.create();
- dc.drawImage(&img, 0, 0);
+ dc.drawImage(&img, 0, 0);
}
- else
+ else
{
- dc.setForeground(FXRGB(255,255,255));
- dc.fillRectangle(0, 0, ww, hh);
+ dc.setForeground(FXRGB(255,255,255));
+ dc.fillRectangle(0, 0, ww, hh);
}
- m_dirty_flag = false;
+ m_dirty_flag = false;
}
void fx_plot_canvas::update_region(const agg::rect_base<int>& _r)
{
- int iw = m_img.width(), ih = m_img.height();
- const agg::rect_base<int> b(0, 0, iw, ih);
- agg::rect_base<int> r = agg::intersect_rectangles(_r, b);
+ int iw = m_img.width(), ih = m_img.height();
+ const agg::rect_base<int> b(0, 0, iw, ih);
+ agg::rect_base<int> r = agg::intersect_rectangles(_r, b);
- FXshort ww = r.x2 - r.x1, hh= r.y2 - r.y1;
- FXImage img(getApp(), NULL, IMAGE_OWNED|IMAGE_SHMI|IMAGE_SHMP, ww, hh);
+ FXshort ww = r.x2 - r.x1, hh= r.y2 - r.y1;
+ FXImage img(getApp(), NULL, IMAGE_OWNED|IMAGE_SHMI|IMAGE_SHMP, ww, hh);
- const unsigned bpp = 32;
- const unsigned pixel_size = bpp / 8;
+ const unsigned bpp = 32;
+ const unsigned pixel_size = bpp / 8;
- agg::rendering_buffer dest;
- dest.attach((agg::int8u*) img.getData(), ww, hh, -ww * pixel_size);
+ agg::rendering_buffer dest;
+ dest.attach((agg::int8u*) img.getData(), ww, hh, -ww * pixel_size);
- rendering_buffer_ro src;
- rendering_buffer_get_const_view(src, m_img, r, gslshell::bpp / 8, true);
+ rendering_buffer_ro src;
+ rendering_buffer_get_const_view(src, m_img, r, gslshell::bpp / 8, true);
- my_color_conv(&dest, &src, color_conv_rgb24_to_rgba32());
+ my_color_conv(&dest, &src, color_conv_rgb24_to_rgba32());
- img.create();
+ img.create();
- FXDCWindow dc(this);
- dc.drawImage(&img, r.x1, getHeight() - r.y2);
+ FXDCWindow dc(this);
+ dc.drawImage(&img, r.x1, getHeight() - r.y2);
}
void fx_plot_canvas::attach(plot_type* p)
{
- m_plot = p;
- m_dirty_flag = true;
+ m_plot = p;
+ m_dirty_flag = true;
}
opt_rect<double> fx_plot_canvas::plot_render_queue(agg::trans_affine& m)
{
- opt_rect<double> r, draw_rect;
- AGG_LOCK();
- m_plot->draw_queue(*m_canvas, m, draw_rect);
- AGG_UNLOCK();
- r.add<rect_union>(draw_rect);
- r.add<rect_union>(m_dirty_rect);
- m_dirty_rect = draw_rect;
- return r;
+ opt_rect<double> r, draw_rect;
+ AGG_LOCK();
+ m_plot->draw_queue(*m_canvas, m, draw_rect);
+ AGG_UNLOCK();
+ r.add<rect_union>(draw_rect);
+ r.add<rect_union>(m_dirty_rect);
+ m_dirty_rect = draw_rect;
+ return r;
}
void fx_plot_canvas::plot_draw_queue(agg::trans_affine& m, bool draw_all)
{
- if (!m_canvas || !m_plot) return;
+ if (!m_canvas || !m_plot) return;
- opt_rect<double> rect = plot_render_queue(m);
+ opt_rect<double> rect = plot_render_queue(m);
- if (draw_all)
+ if (draw_all)
{
- const agg::rect_base<int> ri(0, 0, getWidth(), getHeight());
- update_region(ri);
+ const agg::rect_base<int> ri(0, 0, getWidth(), getHeight());
+ update_region(ri);
}
- else if (rect.is_defined())
+ else if (rect.is_defined())
{
- const int pd = 4;
- const agg::rect_base<double>& r = rect.rect();
- const agg::rect_base<int> ri(r.x1 - pd, r.y1 - pd, r.x2 + pd, r.y2 + pd);
- update_region(ri);
+ const int pd = 4;
+ const agg::rect_base<double>& r = rect.rect();
+ const agg::rect_base<int> ri(r.x1 - pd, r.y1 - pd, r.x2 + pd, r.y2 + pd);
+ update_region(ri);
}
}
bool fx_plot_canvas::save_image()
{
- int ww = getWidth(), hh = getHeight();
- if (!m_img.defined() || !m_save_img.resize(ww, hh)) return false;
- m_save_img.copy_from(m_img);
- return true;
+ int ww = getWidth(), hh = getHeight();
+ if (!m_img.defined() || !m_save_img.resize(ww, hh)) return false;
+ m_save_img.copy_from(m_img);
+ return true;
}
bool fx_plot_canvas::restore_image()
{
- if (!image::match(m_img, m_save_img))
- return false;
- m_img.copy_from(m_save_img);
- return true;
+ if (!image::match(m_img, m_save_img))
+ return false;
+ m_img.copy_from(m_save_img);
+ return true;
}
long fx_plot_canvas::on_cmd_paint(FXObject *, FXSelector, void *ptr)
{
- FXEvent* ev = (FXEvent*) ptr;
- plot_draw(m_area_mtx);
- return 1;
+ FXEvent* ev = (FXEvent*) ptr;
+ plot_draw(m_area_mtx);
+ return 1;
}
long fx_plot_canvas::on_update(FXObject *, FXSelector, void *)
{
- bool need_upd = m_dirty_flag;
- if (need_upd)
- plot_draw(m_area_mtx);
- return (need_upd ? 1 : 0);
+ bool need_upd = m_dirty_flag;
+ if (need_upd)
+ plot_draw(m_area_mtx);
+ return (need_upd ? 1 : 0);
}
diff --git a/fox-gui/fx_plot_canvas.h b/fox-gui/fx_plot_canvas.h
index 778c517f..1fcc163a 100644
--- a/fox-gui/fx_plot_canvas.h
+++ b/fox-gui/fx_plot_canvas.h
@@ -11,53 +11,63 @@
#include "canvas.h"
#include "rect.h"
-class fx_plot_canvas : public FXCanvas {
- FXDECLARE(fx_plot_canvas)
+class fx_plot_canvas : public FXCanvas
+{
+ FXDECLARE(fx_plot_canvas)
- typedef image_gen<3, true> image;
+ typedef image_gen<3, true> image;
public:
- typedef plot<manage_owner> plot_type;
+ typedef plot<manage_owner> plot_type;
- fx_plot_canvas(FXComposite* p, FXObject* tgt=NULL, FXSelector sel=0,
- FXuint opts=FRAME_NORMAL,
- FXint x=0, FXint y=0, FXint w=0, FXint h=0);
+ fx_plot_canvas(FXComposite* p, FXObject* tgt=NULL, FXSelector sel=0,
+ FXuint opts=FRAME_NORMAL,
+ FXint x=0, FXint y=0, FXint w=0, FXint h=0);
- ~fx_plot_canvas();
+ ~fx_plot_canvas();
- void attach(plot_type* p);
- void update_region(const agg::rect_base<int>& r);
+ void attach(plot_type* p);
+ void update_region(const agg::rect_base<int>& r);
- plot_type* get_plot() { return m_plot; }
+ plot_type* get_plot()
+ {
+ return m_plot;
+ }
- void plot_render(agg::trans_affine& m);
- void plot_draw(agg::trans_affine& m);
- opt_rect<double> plot_render_queue(agg::trans_affine& m);
- void plot_draw_queue(agg::trans_affine& m, bool draw_all);
+ void plot_render(agg::trans_affine& m);
+ void plot_draw(agg::trans_affine& m);
+ opt_rect<double> plot_render_queue(agg::trans_affine& m);
+ void plot_draw_queue(agg::trans_affine& m, bool draw_all);
- agg::trans_affine& plot_matrix() { return m_area_mtx; }
- bool is_ready() const { return m_canvas && m_plot; }
+ agg::trans_affine& plot_matrix()
+ {
+ return m_area_mtx;
+ }
+ bool is_ready() const
+ {
+ return m_canvas && m_plot;
+ }
- bool save_image();
- bool restore_image();
+ bool save_image();
+ bool restore_image();
- long on_cmd_paint(FXObject *, FXSelector, void *);
- long on_update(FXObject *, FXSelector, void *);
+ long on_cmd_paint(FXObject *, FXSelector, void *);
+ long on_update(FXObject *, FXSelector, void *);
protected:
- fx_plot_canvas() {}
+ fx_plot_canvas() {}
private:
- void prepare_image_buffer(unsigned ww, unsigned hh);
- void ensure_canvas_size(unsigned ww, unsigned hh);
-
- image m_img;
- image m_save_img;
- plot_type* m_plot;
- canvas* m_canvas;
- bool m_dirty_flag;
- opt_rect<double> m_dirty_rect;
- agg::trans_affine m_area_mtx;
+ void prepare_image_buffer(unsigned ww, unsigned hh);
+ void ensure_canvas_size(unsigned ww, unsigned hh);
+
+ image m_img;
+ image m_save_img;
+ plot_type* m_plot;
+ canvas* m_canvas;
+ bool m_dirty_flag;
+ opt_rect<double> m_dirty_rect;
+ agg::trans_affine m_area_mtx;
};
#endif
diff --git a/fox-gui/fx_plot_window.cpp b/fox-gui/fx_plot_window.cpp
index 6a57a84d..b75e42d4 100644
--- a/fox-gui/fx_plot_window.cpp
+++ b/fox-gui/fx_plot_window.cpp
@@ -1,30 +1,31 @@
#include "fx_plot_window.h"
-FXDEFMAP(fx_plot_window) fx_plot_window_map[]={
+FXDEFMAP(fx_plot_window) fx_plot_window_map[]=
+{
};
FXIMPLEMENT(fx_plot_window,FXMainWindow,fx_plot_window_map,ARRAYNUMBER(fx_plot_window_map))
fx_plot_window::fx_plot_window(FXApp* app, const FXString& name, FXIcon *ic, FXIcon *mi, FXint w, FXint h):
- FXMainWindow(app, name, ic, mi, DECOR_ALL, 0, 0, w, h)
+ FXMainWindow(app, name, ic, mi, DECOR_ALL, 0, 0, w, h)
{
- m_menu_bar = new FXMenuBar(this, LAYOUT_SIDE_TOP|LAYOUT_FILL_X);
+ m_menu_bar = new FXMenuBar(this, LAYOUT_SIDE_TOP|LAYOUT_FILL_X);
- m_plot_menu = new FXMenuPane(this);
- new FXMenuCommand(m_plot_menu, "&Close\tCtl-C", NULL, app, FXApp::ID_QUIT);
- new FXMenuTitle(m_menu_bar, "&Plot", NULL, m_plot_menu);
+ m_plot_menu = new FXMenuPane(this);
+ new FXMenuCommand(m_plot_menu, "&Close\tCtl-C", NULL, app, FXApp::ID_QUIT);
+ new FXMenuTitle(m_menu_bar, "&Plot", NULL, m_plot_menu);
- FXVerticalFrame* frame = new FXVerticalFrame(this, LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y);
+ FXVerticalFrame* frame = new FXVerticalFrame(this, LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y);
- // Sunken border for text widget
- FXHorizontalFrame *cbox = new FXHorizontalFrame(frame, FRAME_SUNKEN|LAYOUT_FILL_X|LAYOUT_FILL_Y,0,0,0,0, 0,0,0,0);
+ // Sunken border for text widget
+ FXHorizontalFrame *cbox = new FXHorizontalFrame(frame, FRAME_SUNKEN|LAYOUT_FILL_X|LAYOUT_FILL_Y,0,0,0,0, 0,0,0,0);
- m_canvas = new fx_plot_canvas(cbox, NULL, 0, LAYOUT_FILL_X|LAYOUT_FILL_Y);
+ m_canvas = new fx_plot_canvas(cbox, NULL, 0, LAYOUT_FILL_X|LAYOUT_FILL_Y);
}
fx_plot_window::~fx_plot_window()
{
- delete m_canvas;
- delete m_plot_menu;
+ delete m_canvas;
+ delete m_plot_menu;
}
diff --git a/fox-gui/fx_plot_window.h b/fox-gui/fx_plot_window.h
index e7b11927..a016b248 100644
--- a/fox-gui/fx_plot_window.h
+++ b/fox-gui/fx_plot_window.h
@@ -6,25 +6,32 @@
#include "gsl_shell_app.h"
#include "fx_plot_canvas.h"
-class fx_plot_window : public FXMainWindow {
- FXDECLARE(fx_plot_window)
+class fx_plot_window : public FXMainWindow
+{
+ FXDECLARE(fx_plot_window)
public:
- fx_plot_window(FXApp* a, const FXString& name, FXIcon *ic=NULL, FXIcon *mi=NULL, FXint w=0, FXint h=0);
+ fx_plot_window(FXApp* a, const FXString& name, FXIcon *ic=NULL, FXIcon *mi=NULL, FXint w=0, FXint h=0);
- ~fx_plot_window();
+ ~fx_plot_window();
- fx_plot_canvas* canvas() { return m_canvas; }
- gsl_shell_app* get_app() { return (gsl_shell_app*) getApp(); }
+ fx_plot_canvas* canvas()
+ {
+ return m_canvas;
+ }
+ gsl_shell_app* get_app()
+ {
+ return (gsl_shell_app*) getApp();
+ }
- int lua_id; // the following is used by Lua to keep trace of the window
+ int lua_id; // the following is used by Lua to keep trace of the window
protected:
- fx_plot_window() {}
+ fx_plot_window() {}
private:
- FXMenuBar* m_menu_bar;
- FXMenuPane* m_plot_menu;
- fx_plot_canvas* m_canvas;
+ FXMenuBar* m_menu_bar;
+ FXMenuPane* m_plot_menu;
+ fx_plot_canvas* m_canvas;
};
#endif
diff --git a/fox-gui/gsl-shell-fox.cpp b/fox-gui/gsl-shell-fox.cpp
index ac761443..d80ec775 100644
--- a/fox-gui/gsl-shell-fox.cpp
+++ b/fox-gui/gsl-shell-fox.cpp
@@ -5,17 +5,17 @@
#include "lua_plot_window.h"
struct window_hooks app_window_hooks[1] = {{
- fox_window_new, fox_window_attach,
- fox_window_slot_update, fox_window_slot_refresh,
- fox_window_save_slot_image, fox_window_restore_slot_image,
- }
+ fox_window_new, fox_window_attach,
+ fox_window_slot_update, fox_window_slot_refresh,
+ fox_window_save_slot_image, fox_window_restore_slot_image,
+ }
};
int
main (int argc, char *argv[])
{
- gsl_shell_app app;
- app.init(argc, argv);
- app.create();
- return app.run();
+ gsl_shell_app app;
+ app.init(argc, argv);
+ app.create();
+ return app.run();
}
diff --git a/fox-gui/gsl_shell_app.cpp b/fox-gui/gsl_shell_app.cpp
index e66abd63..00b996d8 100644
--- a/fox-gui/gsl_shell_app.cpp
+++ b/fox-gui/gsl_shell_app.cpp
@@ -5,9 +5,10 @@
#include "lua_plot_window.h"
#include "fatal.h"
-FXDEFMAP(gsl_shell_app) gsl_shell_app_map[]={
- FXMAPFUNC(SEL_IO_READ, gsl_shell_app::ID_LUA_REQUEST, gsl_shell_app::on_lua_request),
- FXMAPFUNC(SEL_CLOSE, 0, gsl_shell_app::on_window_close),
+FXDEFMAP(gsl_shell_app) gsl_shell_app_map[]=
+{
+ FXMAPFUNC(SEL_IO_READ, gsl_shell_app::ID_LUA_REQUEST, gsl_shell_app::on_lua_request),
+ FXMAPFUNC(SEL_CLOSE, 0, gsl_shell_app::on_window_close),
};
FXIMPLEMENT(gsl_shell_app,FXApp,gsl_shell_app_map,ARRAYNUMBER(gsl_shell_app_map))
@@ -15,48 +16,48 @@ FXIMPLEMENT(gsl_shell_app,FXApp,gsl_shell_app_map,ARRAYNUMBER(gsl_shell_app_map)
gsl_shell_app* global_app;
gsl_shell_app::gsl_shell_app() : FXApp("GSL Shell", "GSL Shell"),
- m_engine(this)
+ m_engine(this)
{
- m_lua_request = new FXGUISignal(this, this, ID_LUA_REQUEST);
- global_app = this;
- m_engine.start();
+ m_lua_request = new FXGUISignal(this, this, ID_LUA_REQUEST);
+ global_app = this;
+ m_engine.start();
- new gsl_shell_window(&m_engine, this, "GSL Shell Console", NULL, NULL, 600, 500);
+ new gsl_shell_window(&m_engine, this, "GSL Shell Console", NULL, NULL, 600, 500);
}
gsl_shell_app::~gsl_shell_app()
{
- delete m_lua_request;
+ delete m_lua_request;
}
long gsl_shell_app::on_lua_request(FXObject*, FXSelector, void*)
{
- for (unsigned k = 0; k < m_win_queue.size(); k++)
+ for (unsigned k = 0; k < m_win_queue.size(); k++)
{
- FXMainWindow* win = m_win_queue[k];
- win->create();
- win->show(PLACEMENT_SCREEN);
+ FXMainWindow* win = m_win_queue[k];
+ win->create();
+ win->show(PLACEMENT_SCREEN);
}
- m_win_queue.clear();
- m_window_mapping.signal();
- return 1;
+ m_win_queue.clear();
+ m_window_mapping.signal();
+ return 1;
}
void gsl_shell_app::window_create_request(FXMainWindow* win)
{
- m_win_queue.add(win);
- m_lua_request->signal();
+ m_win_queue.add(win);
+ m_lua_request->signal();
}
long gsl_shell_app::on_window_close(FXObject* sender, FXSelector, void*)
{
- fx_plot_window* win = (fx_plot_window*) sender;
- m_engine.window_close_notify(win->lua_id);
- return 0;
+ fx_plot_window* win = (fx_plot_window*) sender;
+ m_engine.window_close_notify(win->lua_id);
+ return 0;
}
void gsl_shell_app::wait_window_mapping()
{
- FXMutex& app_mutex = mutex();
- m_window_mapping.wait(app_mutex);
+ FXMutex& app_mutex = mutex();
+ m_window_mapping.wait(app_mutex);
}
diff --git a/fox-gui/gsl_shell_app.h b/fox-gui/gsl_shell_app.h
index 8834c051..25111935 100644
--- a/fox-gui/gsl_shell_app.h
+++ b/fox-gui/gsl_shell_app.h
@@ -6,31 +6,39 @@
#include "agg_array.h"
#include "fox_gsl_shell.h"
-class gsl_shell_app : public FXApp {
- FXDECLARE(gsl_shell_app)
+class gsl_shell_app : public FXApp
+{
+ FXDECLARE(gsl_shell_app)
public:
- gsl_shell_app();
- ~gsl_shell_app();
-
- void lock() { mutex().lock(); }
- void unlock() { mutex().unlock(); }
-
- void window_create_request(FXMainWindow* win);
- void wait_window_mapping();
-
- long on_lua_request(FXObject*,FXSelector,void*);
- long on_window_close(FXObject*,FXSelector,void*);
-
- enum {
- ID_LUA_REQUEST = FXApp::ID_LAST,
- ID_LAST
- };
+ gsl_shell_app();
+ ~gsl_shell_app();
+
+ void lock()
+ {
+ mutex().lock();
+ }
+ void unlock()
+ {
+ mutex().unlock();
+ }
+
+ void window_create_request(FXMainWindow* win);
+ void wait_window_mapping();
+
+ long on_lua_request(FXObject*,FXSelector,void*);
+ long on_window_close(FXObject*,FXSelector,void*);
+
+ enum
+ {
+ ID_LUA_REQUEST = FXApp::ID_LAST,
+ ID_LAST
+ };
private:
- fox_gsl_shell m_engine;
- FXGUISignal* m_lua_request;
- agg::pod_bvector<FXMainWindow*> m_win_queue;
- FXCondition m_window_mapping;
+ fox_gsl_shell m_engine;
+ FXGUISignal* m_lua_request;
+ agg::pod_bvector<FXMainWindow*> m_win_queue;
+ FXCondition m_window_mapping;
};
extern gsl_shell_app* global_app;
diff --git a/fox-gui/gsl_shell_interp.cpp b/fox-gui/gsl_shell_interp.cpp
index 0aba9ccb..6cd077e5 100644
--- a/fox-gui/gsl_shell_interp.cpp
+++ b/fox-gui/gsl_shell_interp.cpp
@@ -18,72 +18,75 @@ extern "C" {
static void stderr_message(const char *pname, const char *msg)
{
- if (pname) fprintf(stderr, "%s: ", pname);
- fprintf(stderr, "%s\n", msg);
- fflush(stderr);
+ if (pname) fprintf(stderr, "%s: ", pname);
+ fprintf(stderr, "%s\n", msg);
+ fflush(stderr);
}
static int stderr_report(lua_State *L, int status)
{
- if (status && !lua_isnil(L, -1)) {
- const char *msg = lua_tostring(L, -1);
- if (msg == NULL) msg = "(error object is not a string)";
- stderr_message("gsl-shell", msg);
- lua_pop(L, 1);
- }
- return status;
+ if (status && !lua_isnil(L, -1))
+ {
+ const char *msg = lua_tostring(L, -1);
+ if (msg == NULL) msg = "(error object is not a string)";
+ stderr_message("gsl-shell", msg);
+ lua_pop(L, 1);
+ }
+ return status;
}
static int traceback(lua_State *L)
{
- if (!lua_isstring(L, 1)) /* 'message' not a string? */
- return 1; /* keep it intact */
- lua_getfield(L, LUA_GLOBALSINDEX, "debug");
- if (!lua_istable(L, -1)) {
- lua_pop(L, 1);
- return 1;
- }
- lua_getfield(L, -1, "traceback");
- if (!lua_isfunction(L, -1)) {
- lua_pop(L, 2);
+ if (!lua_isstring(L, 1)) /* 'message' not a string? */
+ return 1; /* keep it intact */
+ lua_getfield(L, LUA_GLOBALSINDEX, "debug");
+ if (!lua_istable(L, -1))
+ {
+ lua_pop(L, 1);
+ return 1;
+ }
+ lua_getfield(L, -1, "traceback");
+ if (!lua_isfunction(L, -1))
+ {
+ lua_pop(L, 2);
+ return 1;
+ }
+ lua_pushvalue(L, 1); /* pass error message */
+ lua_pushinteger(L, 2); /* skip this function and traceback */
+ lua_call(L, 2, 1); /* call debug.traceback */
return 1;
- }
- lua_pushvalue(L, 1); /* pass error message */
- lua_pushinteger(L, 2); /* skip this function and traceback */
- lua_call(L, 2, 1); /* call debug.traceback */
- return 1;
}
static int docall(lua_State *L, int narg, int clear)
{
- int status;
- int base = lua_gettop(L) - narg; /* function index */
- lua_pushcfunction(L, traceback); /* push traceback function */
- lua_insert(L, base); /* put it under chunk and args */
- status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base);
- lua_remove(L, base); /* remove traceback function */
- /* force a complete garbage collection in case of errors */
- if (status != 0) lua_gc(L, LUA_GCCOLLECT, 0);
- return status;
+ int status;
+ int base = lua_gettop(L) - narg; /* function index */
+ lua_pushcfunction(L, traceback); /* push traceback function */
+ lua_insert(L, base); /* put it under chunk and args */
+ status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base);
+ lua_remove(L, base); /* remove traceback function */
+ /* force a complete garbage collection in case of errors */
+ if (status != 0) lua_gc(L, LUA_GCCOLLECT, 0);
+ return status;
}
static int dolibrary(lua_State *L, const char *name)
{
- lua_getglobal(L, "require");
- lua_pushstring(L, name);
- return stderr_report(L, docall(L, 1, 1));
+ lua_getglobal(L, "require");
+ lua_pushstring(L, name);
+ return stderr_report(L, docall(L, 1, 1));
}
static int pinit(lua_State *L)
{
- LUAJIT_VERSION_SYM(); /* linker-enforced version check */
- lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */
- luaL_openlibs(L); /* open libraries */
- luaopen_gsl (L);
- register_graph (L);
- lua_gc(L, LUA_GCRESTART, -1);
- dolibrary (L, "gslext");
- return 0;
+ LUAJIT_VERSION_SYM(); /* linker-enforced version check */
+ lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */
+ luaL_openlibs(L); /* open libraries */
+ luaopen_gsl (L);
+ register_graph (L);
+ lua_gc(L, LUA_GCRESTART, -1);
+ dolibrary (L, "gslext");
+ return 0;
}
/* If the input is an expression we load it preceded by "return" so
@@ -92,108 +95,108 @@ static int pinit(lua_State *L)
returns a non zero value. */
static int yield_expr(lua_State* L, const char* line, size_t len)
{
- const char *p;
- int status;
+ const char *p;
+ int status;
- for (p = line + len - 1; p >= line; p--)
+ for (p = line + len - 1; p >= line; p--)
{
- const char c = *p;
- if (c == ';')
- return 1;
- if (c != ' ')
- break;
+ const char c = *p;
+ if (c == ';')
+ return 1;
+ if (c != ' ')
+ break;
}
- str mline = str::print("return %s", line);
- status = luaL_loadbuffer(L, mline.cstr(), len+7, "=stdin");
- if (status != 0) lua_pop(L, 1); // remove the error message
- return status;
+ str mline = str::print("return %s", line);
+ status = luaL_loadbuffer(L, mline.cstr(), len+7, "=stdin");
+ if (status != 0) lua_pop(L, 1); // remove the error message
+ return status;
}
static int incomplete(lua_State *L, int status)
{
- if (status == LUA_ERRSYNTAX)
+ if (status == LUA_ERRSYNTAX)
{
- size_t lmsg;
- const char *msg = lua_tolstring(L, -1, &lmsg);
- const char *tp = msg + lmsg - (sizeof(LUA_QL("<eof>")) - 1);
- if (strstr(msg, LUA_QL("<eof>")) == tp)
- {
- lua_pop(L, 1);
- return 1;
- }
+ size_t lmsg;
+ const char *msg = lua_tolstring(L, -1, &lmsg);
+ const char *tp = msg + lmsg - (sizeof(LUA_QL("<eof>")) - 1);
+ if (strstr(msg, LUA_QL("<eof>")) == tp)
+ {
+ lua_pop(L, 1);
+ return 1;
+ }
}
- return 0; /* else... */
+ return 0; /* else... */
}
void gsl_shell::init()
{
- gsl_shell_open(this);
+ gsl_shell_open(this);
- int status = lua_cpcall(this->L, pinit, NULL);
+ int status = lua_cpcall(this->L, pinit, NULL);
- if (unlikely(stderr_report(this->L, status)))
+ if (unlikely(stderr_report(this->L, status)))
{
- lua_close(this->L);
- fatal_exception("cannot initialize Lua state");
+ lua_close(this->L);
+ fatal_exception("cannot initialize Lua state");
}
}
void gsl_shell::close()
{
- lua_close(this->L);
- this->L = NULL;
+ lua_close(this->L);
+ this->L = NULL;
}
int gsl_shell::error_report(int status)
{
- lua_State* L = this->L;
- if (status && !lua_isnil(L, -1))
+ lua_State* L = this->L;
+ if (status && !lua_isnil(L, -1))
{
- const char *msg = lua_tostring(L, -1);
- if (msg == NULL) msg = "(error object is not a string)";
- m_error_msg = msg;
- lua_pop(L, 1);
+ const char *msg = lua_tostring(L, -1);
+ if (msg == NULL) msg = "(error object is not a string)";
+ m_error_msg = msg;
+ lua_pop(L, 1);
}
- return status;
+ return status;
}
int gsl_shell::exec(const char *line)
{
- lua_State* L = this->L;
- size_t len = strlen(line);
+ lua_State* L = this->L;
+ size_t len = strlen(line);
- if (strcmp (line, "exit") == 0)
- return exit_request;
+ if (strcmp (line, "exit") == 0)
+ return exit_request;
- /* try to load the string as an expression */
- int status = yield_expr(L, line, len);
+ /* try to load the string as an expression */
+ int status = yield_expr(L, line, len);
- if (status != 0)
+ if (status != 0)
{
- status = luaL_loadbuffer(L, line, len, "=<user input>");
+ status = luaL_loadbuffer(L, line, len, "=<user input>");
- if (incomplete(L, status))
- return incomplete_input;
+ if (incomplete(L, status))
+ return incomplete_input;
}
- if (status == 0)
+ if (status == 0)
{
- status = docall(L, 0, 0);
- error_report(status);
- if (status == 0 && lua_gettop(L) > 0) /* any result to print? */
- {
- lua_pushvalue(L, -1);
- lua_setfield(L, LUA_GLOBALSINDEX, "_");
-
- lua_getglobal(L, "print");
- lua_insert(L, 1);
- if (lua_pcall(L, lua_gettop(L)-1, 0, 0) != 0)
- fprintf(stderr, "error calling print function");
- }
+ status = docall(L, 0, 0);
+ error_report(status);
+ if (status == 0 && lua_gettop(L) > 0) /* any result to print? */
+ {
+ lua_pushvalue(L, -1);
+ lua_setfield(L, LUA_GLOBALSINDEX, "_");
+
+ lua_getglobal(L, "print");
+ lua_insert(L, 1);
+ if (lua_pcall(L, lua_gettop(L)-1, 0, 0) != 0)
+ fprintf(stderr, "error calling print function");
+ }
}
- error_report(status);
+ error_report(status);
- return (status == 0 ? eval_success : eval_error);
+ return (status == 0 ? eval_success : eval_error);
}
diff --git a/fox-gui/gsl_shell_interp.h b/fox-gui/gsl_shell_interp.h
index d4669f99..2743a901 100644
--- a/fox-gui/gsl_shell_interp.h
+++ b/fox-gui/gsl_shell_interp.h
@@ -11,32 +11,36 @@ extern "C" {
#include "strpp.h"
#include "fatal.h"
-class gsl_shell : public gsl_shell_state {
+class gsl_shell : public gsl_shell_state
+{
public:
- enum eval_result_e { eval_success, eval_error, incomplete_input, exit_request };
+ enum eval_result_e { eval_success, eval_error, incomplete_input, exit_request };
- gsl_shell()
- {
- gsl_shell_init(this);
- }
+ gsl_shell()
+ {
+ gsl_shell_init(this);
+ }
- ~gsl_shell()
- {
- if (unlikely(this->L == NULL))
- fatal_exception("Attempt to dispose an open Lua state");
- gsl_shell_free(this);
- }
+ ~gsl_shell()
+ {
+ if (unlikely(this->L == NULL))
+ fatal_exception("Attempt to dispose an open Lua state");
+ gsl_shell_free(this);
+ }
- virtual void init();
- virtual void close();
+ virtual void init();
+ virtual void close();
- int exec(const char* line);
- const char* error_msg() const { return m_error_msg.cstr(); }
+ int exec(const char* line);
+ const char* error_msg() const
+ {
+ return m_error_msg.cstr();
+ }
private:
- int error_report(int status);
+ int error_report(int status);
- str m_error_msg;
+ str m_error_msg;
};
#endif
diff --git a/fox-gui/gsl_shell_thread.cpp b/fox-gui/gsl_shell_thread.cpp
index 261869b3..7dee4d89 100644
--- a/fox-gui/gsl_shell_thread.cpp
+++ b/fox-gui/gsl_shell_thread.cpp
@@ -8,98 +8,98 @@ extern "C" void * luajit_eval_thread (void *userdata);
void *
luajit_eval_thread (void *userdata)
{
- gsl_shell_thread* eng = (gsl_shell_thread*) userdata;
- eng->lock();
- eng->init();
- eng->run();
- pthread_exit(NULL);
- return NULL;
+ gsl_shell_thread* eng = (gsl_shell_thread*) userdata;
+ eng->lock();
+ eng->init();
+ eng->run();
+ pthread_exit(NULL);
+ return NULL;
}
gsl_shell_thread::gsl_shell_thread():
- m_status(starting), m_redirect(4096), m_exit_request(false)
+ m_status(starting), m_redirect(4096), m_exit_request(false)
{
}
gsl_shell_thread::~gsl_shell_thread()
{
- m_redirect.stop();
+ m_redirect.stop();
}
void gsl_shell_thread::start()
{
- m_redirect.start();
+ m_redirect.start();
- pthread_attr_t attr[1];
+ pthread_attr_t attr[1];
- pthread_attr_init (attr);
- pthread_attr_setdetachstate (attr, PTHREAD_CREATE_DETACHED);
+ pthread_attr_init (attr);
+ pthread_attr_setdetachstate (attr, PTHREAD_CREATE_DETACHED);
- if (pthread_create (&m_thread, attr, luajit_eval_thread, (void*)this))
+ if (pthread_create (&m_thread, attr, luajit_eval_thread, (void*)this))
{
- fprintf(stderr, "error creating thread");
+ fprintf(stderr, "error creating thread");
}
}
void
gsl_shell_thread::run()
{
- while (1)
+ while (1)
{
- m_eval.lock();
- m_status = ready;
+ m_eval.lock();
+ m_status = ready;
- this->unlock();
- m_eval.wait();
- this->lock();
+ this->unlock();
+ m_eval.wait();
+ this->lock();
- before_eval();
+ before_eval();
- if (m_exit_request)
- {
- m_eval.unlock();
- break;
- }
+ if (m_exit_request)
+ {
+ m_eval.unlock();
+ break;
+ }
- m_status = busy;
- m_eval.unlock();
+ m_status = busy;
+ m_eval.unlock();
- // here m_line_pending cannot be modified by the other thread
- // because we declared above m_status to "busy" befor unlocking m_eval
- const char* line = m_line_pending.cstr();
- m_eval_status = this->exec(line);
+ // here m_line_pending cannot be modified by the other thread
+ // because we declared above m_status to "busy" befor unlocking m_eval
+ const char* line = m_line_pending.cstr();
+ m_eval_status = this->exec(line);
- fputc(eot_character, stdout);
- fflush(stdout);
+ fputc(eot_character, stdout);
+ fflush(stdout);
}
- this->unlock();
- this->close();
+ this->unlock();
+ this->close();
}
void
gsl_shell_thread::stop()
{
- pthread::auto_lock lock(m_eval);
- m_exit_request = true;
- m_eval.signal();
- pthread_join(m_thread, NULL);
+ pthread::auto_lock lock(m_eval);
+ m_exit_request = true;
+ m_eval.signal();
+ pthread_join(m_thread, NULL);
}
void
gsl_shell_thread::input(const char* line)
{
- pthread::auto_lock lock(m_eval);
+ pthread::auto_lock lock(m_eval);
- if (m_status == ready)
+ if (m_status == ready)
{
- m_line_pending = line;
- m_eval.signal();
+ m_line_pending = line;
+ m_eval.signal();
}
}
int
gsl_shell_thread::read(char* buffer, unsigned buffer_size)
{
- return m_redirect.read(buffer, buffer_size);
+ return m_redirect.read(buffer, buffer_size);
}
diff --git a/fox-gui/gsl_shell_thread.h b/fox-gui/gsl_shell_thread.h
index 0cb10cc1..2fdb2791 100644
--- a/fox-gui/gsl_shell_thread.h
+++ b/fox-gui/gsl_shell_thread.h
@@ -10,37 +10,50 @@ extern "C" {
#include "redirect.h"
#include "str.h"
-class gsl_shell_thread : public gsl_shell {
+class gsl_shell_thread : public gsl_shell
+{
public:
- enum engine_status_e { starting, ready, busy, terminated };
- enum { eot_character = 0x04 };
-
- gsl_shell_thread();
- ~gsl_shell_thread();
-
- void input(const char* line);
- void start();
- void run();
- void stop();
-
- virtual void before_eval() { }
-
- void lock() { pthread_mutex_lock(&this->exec_mutex); }
- void unlock() { pthread_mutex_unlock(&this->exec_mutex); }
-
- int read(char* buffer, unsigned buffer_size);
-
- int eval_status() const { return m_eval_status; }
- pthread::mutex& eval_mutex() { return m_eval; }
+ enum engine_status_e { starting, ready, busy, terminated };
+ enum { eot_character = 0x04 };
+
+ gsl_shell_thread();
+ ~gsl_shell_thread();
+
+ void input(const char* line);
+ void start();
+ void run();
+ void stop();
+
+ virtual void before_eval() { }
+
+ void lock()
+ {
+ pthread_mutex_lock(&this->exec_mutex);
+ }
+ void unlock()
+ {
+ pthread_mutex_unlock(&this->exec_mutex);
+ }
+
+ int read(char* buffer, unsigned buffer_size);
+
+ int eval_status() const
+ {
+ return m_eval_status;
+ }
+ pthread::mutex& eval_mutex()
+ {
+ return m_eval;
+ }
private:
- pthread_t m_thread;
- engine_status_e m_status;
- stdout_redirect m_redirect;
- pthread::cond m_eval;
- str m_line_pending;
- int m_eval_status;
- bool m_exit_request;
+ pthread_t m_thread;
+ engine_status_e m_status;
+ stdout_redirect m_redirect;
+ pthread::cond m_eval;
+ str m_line_pending;
+ int m_eval_status;
+ bool m_exit_request;
};
#endif
diff --git a/fox-gui/gsl_shell_window.cpp b/fox-gui/gsl_shell_window.cpp
index 59d6a2eb..1a88efb9 100644
--- a/fox-gui/gsl_shell_window.cpp
+++ b/fox-gui/gsl_shell_window.cpp
@@ -6,41 +6,42 @@
#define CONSOLE_FONT "monospace"
#endif
-FXDEFMAP(gsl_shell_window) gsl_shell_window_map[]={
- FXMAPFUNC(SEL_CLOSE, 0, gsl_shell_window::on_close),
+FXDEFMAP(gsl_shell_window) gsl_shell_window_map[]=
+{
+ FXMAPFUNC(SEL_CLOSE, 0, gsl_shell_window::on_close),
};
FXIMPLEMENT(gsl_shell_window,FXMainWindow,gsl_shell_window_map,ARRAYNUMBER(gsl_shell_window_map))
gsl_shell_window::gsl_shell_window(gsl_shell_thread* gs, FXApp* app, const FXString& name, FXIcon *ic, FXIcon *mi, FXint w, FXint h):
- FXMainWindow(app, name, ic, mi, DECOR_ALL, 0, 0, w, h)
+ FXMainWindow(app, name, ic, mi, DECOR_ALL, 0, 0, w, h)
{
- m_menu_bar = new FXMenuBar(this, LAYOUT_SIDE_TOP|LAYOUT_FILL_X);
- m_status_bar = new FXStatusBar(this, LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|FRAME_RAISED|STATUSBAR_WITH_DRAGCORNER);
+ m_menu_bar = new FXMenuBar(this, LAYOUT_SIDE_TOP|LAYOUT_FILL_X);
+ m_status_bar = new FXStatusBar(this, LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|FRAME_RAISED|STATUSBAR_WITH_DRAGCORNER);
- m_file_menu = new FXMenuPane(this);
- new FXMenuCommand(m_file_menu, "&Quit\tCtl-Q", NULL, app, FXApp::ID_QUIT);
- new FXMenuTitle(m_menu_bar, "&File", NULL, m_file_menu);
+ m_file_menu = new FXMenuPane(this);
+ new FXMenuCommand(m_file_menu, "&Quit\tCtl-Q", NULL, app, FXApp::ID_QUIT);
+ new FXMenuTitle(m_menu_bar, "&File", NULL, m_file_menu);
- FXVerticalFrame* frame = new FXVerticalFrame(this, LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y);
+ FXVerticalFrame* frame = new FXVerticalFrame(this, LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y);
- // Sunken border for text widget
- FXHorizontalFrame *textbox = new FXHorizontalFrame(frame, FRAME_SUNKEN|LAYOUT_FILL_X|LAYOUT_FILL_Y,0,0,0,0, 0,0,0,0);
+ // Sunken border for text widget
+ FXHorizontalFrame *textbox = new FXHorizontalFrame(frame, FRAME_SUNKEN|LAYOUT_FILL_X|LAYOUT_FILL_Y,0,0,0,0, 0,0,0,0);
- m_text_font = new FXFont(app, CONSOLE_FONT, 10);
- m_text = new fx_console(gs, textbox, NULL, 0, LAYOUT_FILL_X|LAYOUT_FILL_Y);
- m_text->setFont(m_text_font);
+ m_text_font = new FXFont(app, CONSOLE_FONT, 10);
+ m_text = new fx_console(gs, textbox, NULL, 0, LAYOUT_FILL_X|LAYOUT_FILL_Y);
+ m_text->setFont(m_text_font);
}
void gsl_shell_window::create()
{
- FXMainWindow::create();
- show(PLACEMENT_SCREEN);
+ FXMainWindow::create();
+ show(PLACEMENT_SCREEN);
}
long gsl_shell_window::on_close(FXObject* obj, FXSelector sel, void* ptr)
{
- // m_text->stop();
- return FXMainWindow::close(FALSE);
+ // m_text->stop();
+ return FXMainWindow::close(FALSE);
}
diff --git a/fox-gui/gsl_shell_window.h b/fox-gui/gsl_shell_window.h
index 046f9d8d..c9d5c1e3 100644
--- a/fox-gui/gsl_shell_window.h
+++ b/fox-gui/gsl_shell_window.h
@@ -6,30 +6,31 @@
#include "gsl_shell_thread.h"
#include "fx_console.h"
-class gsl_shell_window : public FXMainWindow {
- FXDECLARE(gsl_shell_window)
+class gsl_shell_window : public FXMainWindow
+{
+ FXDECLARE(gsl_shell_window)
public:
- gsl_shell_window(gsl_shell_thread* gs, FXApp* a, const FXString& name, FXIcon *ic=NULL, FXIcon *mi=NULL, FXint w=0, FXint h=0);
+ gsl_shell_window(gsl_shell_thread* gs, FXApp* a, const FXString& name, FXIcon *ic=NULL, FXIcon *mi=NULL, FXint w=0, FXint h=0);
- virtual ~gsl_shell_window()
- {
- delete m_file_menu;
- delete m_text_font;
- }
+ virtual ~gsl_shell_window()
+ {
+ delete m_file_menu;
+ delete m_text_font;
+ }
- virtual void create();
+ virtual void create();
- long on_close(FXObject* obj, FXSelector sel, void* ptr);
+ long on_close(FXObject* obj, FXSelector sel, void* ptr);
protected:
- gsl_shell_window() {}
+ gsl_shell_window() {}
private:
- fx_console* m_text;
- FXStatusBar* m_status_bar;
- FXMenuBar* m_menu_bar;
- FXMenuPane* m_file_menu;
- FXFont* m_text_font;
+ fx_console* m_text;
+ FXStatusBar* m_status_bar;
+ FXMenuBar* m_menu_bar;
+ FXMenuPane* m_file_menu;
+ FXFont* m_text_font;
};
#endif
diff --git a/fox-gui/image_buf.h b/fox-gui/image_buf.h
index 10017b4b..ecca662d 100644
--- a/fox-gui/image_buf.h
+++ b/fox-gui/image_buf.h
@@ -4,47 +4,57 @@
#include <agg_rendering_buffer.h>
template <unsigned PixelSize, bool FlipY>
-struct image_gen : agg::rendering_buffer {
- image_gen() { }
- image_gen(unsigned w, unsigned h) { init(w, h); }
-
- ~image_gen() { dispose(); }
-
- bool defined() const { return (buf() != 0); }
-
- bool resize(unsigned w, unsigned h)
- {
- dispose();
- return init(w, h);
- }
-
- void clear()
- {
- dispose();
- attach(NULL, 0, 0, 0);
- }
-
- static bool match(const image_gen& a, const image_gen& b)
- {
- if (!a.defined() || !b.defined())
- return false;
- return (a.width() == b.width() && a.height() == b.height());
- }
+struct image_gen : agg::rendering_buffer
+{
+ image_gen() { }
+ image_gen(unsigned w, unsigned h)
+ {
+ init(w, h);
+ }
+
+ ~image_gen()
+ {
+ dispose();
+ }
+
+ bool defined() const
+ {
+ return (buf() != 0);
+ }
+
+ bool resize(unsigned w, unsigned h)
+ {
+ dispose();
+ return init(w, h);
+ }
+
+ void clear()
+ {
+ dispose();
+ attach(NULL, 0, 0, 0);
+ }
+
+ static bool match(const image_gen& a, const image_gen& b)
+ {
+ if (!a.defined() || !b.defined())
+ return false;
+ return (a.width() == b.width() && a.height() == b.height());
+ }
private:
- bool init(unsigned w, unsigned h)
- {
- agg::int8u* data = new(std::nothrow) agg::int8u[w * h * PixelSize];
- int stride = (FlipY ? - w * PixelSize : w * PixelSize);
- attach(data, w, h, stride);
- return (data != 0);
- }
-
- void dispose()
- {
- agg::int8u* data = buf();
- delete[] data;
- }
+ bool init(unsigned w, unsigned h)
+ {
+ agg::int8u* data = new(std::nothrow) agg::int8u[w * h * PixelSize];
+ int stride = (FlipY ? - w * PixelSize : w * PixelSize);
+ attach(data, w, h, stride);
+ return (data != 0);
+ }
+
+ void dispose()
+ {
+ agg::int8u* data = buf();
+ delete[] data;
+ }
};
#endif
diff --git a/fox-gui/io_thread.cpp b/fox-gui/io_thread.cpp
index 463652fb..98959836 100644
--- a/fox-gui/io_thread.cpp
+++ b/fox-gui/io_thread.cpp
@@ -4,27 +4,27 @@
FXint lua_io_thread::run()
{
- char buffer[128];
+ char buffer[128];
- while (1)
+ while (1)
{
- int nr = m_engine->read(buffer, 127);
- if (nr < 0)
- {
- fprintf(stderr, "ERROR on read: %d.\n", errno);
- break;
- }
- if (nr == 0)
- break;
+ int nr = m_engine->read(buffer, 127);
+ if (nr < 0)
+ {
+ fprintf(stderr, "ERROR on read: %d.\n", errno);
+ break;
+ }
+ if (nr == 0)
+ break;
- buffer[nr] = 0;
+ buffer[nr] = 0;
- m_io_protect->lock();
- m_io_buffer->append((const FXchar*)buffer);
- m_io_protect->unlock();
+ m_io_protect->lock();
+ m_io_buffer->append((const FXchar*)buffer);
+ m_io_protect->unlock();
- m_io_ready->signal();
+ m_io_ready->signal();
}
- return 0;
+ return 0;
}
diff --git a/fox-gui/io_thread.h b/fox-gui/io_thread.h
index 6433cd79..37241c92 100644
--- a/fox-gui/io_thread.h
+++ b/fox-gui/io_thread.h
@@ -5,19 +5,20 @@
#include "gsl_shell_thread.h"
-class lua_io_thread : public FXThread {
+class lua_io_thread : public FXThread
+{
public:
- lua_io_thread(gsl_shell_thread* eng, FXGUISignal* sig, FXMutex* mut, FXString* buf):
- m_engine(eng), m_io_ready(sig), m_io_protect(mut), m_io_buffer(buf)
- { }
+ lua_io_thread(gsl_shell_thread* eng, FXGUISignal* sig, FXMutex* mut, FXString* buf):
+ m_engine(eng), m_io_ready(sig), m_io_protect(mut), m_io_buffer(buf)
+ { }
- virtual FXint run();
+ virtual FXint run();
private:
- gsl_shell_thread* m_engine;
- FXGUISignal* m_io_ready;
- FXMutex* m_io_protect;
- FXString* m_io_buffer;
+ gsl_shell_thread* m_engine;
+ FXGUISignal* m_io_ready;
+ FXMutex* m_io_protect;
+ FXString* m_io_buffer;
};
#endif
diff --git a/fox-gui/lua_plot_window.cpp b/fox-gui/lua_plot_window.cpp
index 65159584..8dac4675 100644
--- a/fox-gui/lua_plot_window.cpp
+++ b/fox-gui/lua_plot_window.cpp
@@ -17,23 +17,25 @@ __BEGIN_DECLS
static int fox_window_close (lua_State *L);
-static const struct luaL_Reg fox_window_functions[] = {
- {"window", fox_window_new},
- {NULL, NULL}
+static const struct luaL_Reg fox_window_functions[] =
+{
+ {"window", fox_window_new},
+ {NULL, NULL}
};
-static const struct luaL_Reg fox_window_methods[] = {
- {"attach", fox_window_attach },
- {"close", fox_window_close },
- {"refresh", fox_window_slot_refresh },
- {"update", fox_window_slot_update },
- {NULL, NULL}
+static const struct luaL_Reg fox_window_methods[] =
+{
+ {"attach", fox_window_attach },
+ {"close", fox_window_close },
+ {"refresh", fox_window_slot_refresh },
+ {"update", fox_window_slot_update },
+ {NULL, NULL}
};
struct lua_fox_window
{
- fx_plot_window* window;
+ fx_plot_window* window;
};
__END_DECLS
@@ -43,127 +45,127 @@ typedef plot<manage_owner> sg_plot;
int
fox_window_new (lua_State *L)
{
- gsl_shell_app* app = global_app;
- app->lock();
+ gsl_shell_app* app = global_app;
+ app->lock();
- lua_fox_window* bwin = new(L, GS_FOX_WINDOW) lua_fox_window();
- fx_plot_window* win = new fx_plot_window(app, "GSL Shell FX plot", NULL, NULL, 480, 480);
- bwin->window = win;
+ lua_fox_window* bwin = new(L, GS_FOX_WINDOW) lua_fox_window();
+ fx_plot_window* win = new fx_plot_window(app, "GSL Shell FX plot", NULL, NULL, 480, 480);
+ bwin->window = win;
- win->setTarget(app);
- app->window_create_request(win);
+ win->setTarget(app);
+ app->window_create_request(win);
- win->lua_id = window_index_add (L, -1);
+ win->lua_id = window_index_add (L, -1);
- do
- app->wait_window_mapping();
- while (!win->shown());
+ do
+ app->wait_window_mapping();
+ while (!win->shown());
- app->unlock();
- return 1;
+ app->unlock();
+ return 1;
}
int
fox_window_attach (lua_State *L)
{
- fx_plot_window *win = object_check<lua_fox_window>(L, 1, GS_FOX_WINDOW)->window;
- sg_plot* p = object_check<sg_plot>(L, 2, GS_PLOT);
- gsl_shell_app* app = win->get_app();
- app->lock();
- win->canvas()->attach(p);
- app->unlock();
- int slot_id = 1;
- window_refs_add (L, slot_id, 1, 2);
- return 0;
+ fx_plot_window *win = object_check<lua_fox_window>(L, 1, GS_FOX_WINDOW)->window;
+ sg_plot* p = object_check<sg_plot>(L, 2, GS_PLOT);
+ gsl_shell_app* app = win->get_app();
+ app->lock();
+ win->canvas()->attach(p);
+ app->unlock();
+ int slot_id = 1;
+ window_refs_add (L, slot_id, 1, 2);
+ return 0;
}
int
fox_window_close (lua_State *L)
{
- return 0;
+ return 0;
}
int
fox_window_slot_refresh (lua_State *L)
{
- fx_plot_window *win = object_check<lua_fox_window>(L, 1, GS_FOX_WINDOW)->window;
- fx_plot_canvas* canvas = win->canvas();
- gsl_shell_app* app = win->get_app();
+ fx_plot_window *win = object_check<lua_fox_window>(L, 1, GS_FOX_WINDOW)->window;
+ fx_plot_canvas* canvas = win->canvas();
+ gsl_shell_app* app = win->get_app();
- app->lock();
+ app->lock();
- if (canvas->is_ready())
+ if (canvas->is_ready())
{
- agg::trans_affine& m = canvas->plot_matrix();
- bool redraw = canvas->get_plot()->need_redraw();
- if (redraw)
- canvas->plot_render(m);
- canvas->plot_draw_queue(m, redraw);
+ agg::trans_affine& m = canvas->plot_matrix();
+ bool redraw = canvas->get_plot()->need_redraw();
+ if (redraw)
+ canvas->plot_render(m);
+ canvas->plot_draw_queue(m, redraw);
}
- app->unlock();
- return 0;
+ app->unlock();
+ return 0;
}
int
fox_window_slot_update (lua_State *L)
{
- fx_plot_window *win = object_check<lua_fox_window>(L, 1, GS_FOX_WINDOW)->window;
- fx_plot_canvas* canvas = win->canvas();
- gsl_shell_app* app = win->get_app();
+ fx_plot_window *win = object_check<lua_fox_window>(L, 1, GS_FOX_WINDOW)->window;
+ fx_plot_canvas* canvas = win->canvas();
+ gsl_shell_app* app = win->get_app();
- app->lock();
+ app->lock();
- if (canvas->is_ready())
+ if (canvas->is_ready())
{
- agg::trans_affine& m = canvas->plot_matrix();
- canvas->plot_render(m);
- canvas->plot_draw_queue(m, true);
+ agg::trans_affine& m = canvas->plot_matrix();
+ canvas->plot_render(m);
+ canvas->plot_draw_queue(m, true);
}
- app->unlock();
- return 0;
+ app->unlock();
+ return 0;
}
int
fox_window_save_slot_image (lua_State *L)
{
- fx_plot_window *win = object_check<lua_fox_window>(L, 1, GS_FOX_WINDOW)->window;
- fx_plot_canvas* canvas = win->canvas();
- gsl_shell_app* app = win->get_app();
- app->lock();
- canvas->save_image();
- app->unlock();
- return 0;
+ fx_plot_window *win = object_check<lua_fox_window>(L, 1, GS_FOX_WINDOW)->window;
+ fx_plot_canvas* canvas = win->canvas();
+ gsl_shell_app* app = win->get_app();
+ app->lock();
+ canvas->save_image();
+ app->unlock();
+ return 0;
}
int
fox_window_restore_slot_image (lua_State *L)
{
- fx_plot_window *win = object_check<lua_fox_window>(L, 1, GS_FOX_WINDOW)->window;
- fx_plot_canvas* canvas = win->canvas();
- gsl_shell_app* app = win->get_app();
- app->lock();
- if (!canvas->restore_image())
+ fx_plot_window *win = object_check<lua_fox_window>(L, 1, GS_FOX_WINDOW)->window;
+ fx_plot_canvas* canvas = win->canvas();
+ gsl_shell_app* app = win->get_app();
+ app->lock();
+ if (!canvas->restore_image())
{
- agg::trans_affine& m = canvas->plot_matrix();
- canvas->plot_render(m);
- canvas->save_image();
+ agg::trans_affine& m = canvas->plot_matrix();
+ canvas->plot_render(m);
+ canvas->save_image();
}
- app->unlock();
- return 0;
+ app->unlock();
+ return 0;
}
int
fox_window_register (lua_State *L)
{
- luaL_newmetatable (L, GS_METATABLE(GS_FOX_WINDOW));
- lua_pushvalue (L, -1);
- lua_setfield (L, -2, "__index");
- luaL_register (L, NULL, fox_window_methods);
- lua_pop (L, 1);
-
- luaL_register (L, "fox", fox_window_functions);
- lua_pop (L, 1);
- return 0;
+ luaL_newmetatable (L, GS_METATABLE(GS_FOX_WINDOW));
+ lua_pushvalue (L, -1);
+ lua_setfield (L, -2, "__index");
+ luaL_register (L, NULL, fox_window_methods);
+ lua_pop (L, 1);
+
+ luaL_register (L, "fox", fox_window_functions);
+ lua_pop (L, 1);
+ return 0;
}
diff --git a/fox-gui/redirect.cpp b/fox-gui/redirect.cpp
index 9491e746..0aae5db8 100644
--- a/fox-gui/redirect.cpp
+++ b/fox-gui/redirect.cpp
@@ -18,44 +18,44 @@
stdout_redirect::~stdout_redirect()
{
- close(fd_stdout);
- close(fd_pipe[WRITE_FD]);
- close(fd_pipe[READ_FD]);
+ close(fd_stdout);
+ close(fd_pipe[WRITE_FD]);
+ close(fd_pipe[READ_FD]);
}
stdout_redirect::stdout_redirect(int bufferSize)
{
- int status;
+ int status;
#ifdef WIN32
- status = _pipe(fd_pipe, bufferSize, O_TEXT);
+ status = _pipe(fd_pipe, bufferSize, O_TEXT);
#else
- status = pipe(fd_pipe);
+ status = pipe(fd_pipe);
#endif
- assert(status == 0);
+ assert(status == 0);
- fd_stdout = dup(fileno(stdout));
+ fd_stdout = dup(fileno(stdout));
}
int stdout_redirect::start()
{
- fflush(stdout);
- CHECK(dup2(fd_pipe[WRITE_FD], fileno(stdout)));
- // ios::sync_with_stdio();
- setvbuf( stdout, NULL, _IONBF, 0 ); // absolutely needed
- return 0;
+ fflush(stdout);
+ CHECK(dup2(fd_pipe[WRITE_FD], fileno(stdout)));
+ // ios::sync_with_stdio();
+ setvbuf( stdout, NULL, _IONBF, 0 ); // absolutely needed
+ return 0;
}
int stdout_redirect::stop()
{
- CHECK(dup2(fd_stdout, fileno(stdout)));
- // ios::sync_with_stdio();
- return 0;
+ CHECK(dup2(fd_stdout, fileno(stdout)));
+ // ios::sync_with_stdio();
+ return 0;
}
int stdout_redirect::read(char *buffer, int size)
{
- int nOutRead = ::read(fd_pipe[READ_FD], buffer, size);
- return nOutRead;
+ int nOutRead = ::read(fd_pipe[READ_FD], buffer, size);
+ return nOutRead;
}
diff --git a/fox-gui/redirect.h b/fox-gui/redirect.h
index 9e424a38..94f883da 100644
--- a/fox-gui/redirect.h
+++ b/fox-gui/redirect.h
@@ -4,16 +4,16 @@
class stdout_redirect
{
public:
- stdout_redirect(int buffer_size);
- ~stdout_redirect();
+ stdout_redirect(int buffer_size);
+ ~stdout_redirect();
- int start();
- int stop();
- int read(char *buffer, int size);
+ int start();
+ int stop();
+ int read(char *buffer, int size);
private:
- int fd_pipe[2];
- int fd_stdout;
+ int fd_pipe[2];
+ int fd_stdout;
};
#endif
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月21日 14:23:51 +0000

AltStyle によって変換されたページ (->オリジナル) /