1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-15 23:35:34 +00:00

Move and make sense of the common code

This commit is contained in:
Jonas Fonseca 2005-10-21 04:07:43 +02:00 committed by Jonas Fonseca
parent 1812e20212
commit 03118059ee
4 changed files with 51 additions and 44 deletions

View File

@ -15,10 +15,9 @@
#include "config/home.h"
#include "intl/gettext/libintl.h"
#include "main/module.h"
#include "scripting/scripting.h"
#include "scripting/ruby/core.h"
#include "session/session.h"
#include "terminal/terminal.h"
#include "terminal/window.h"
#include "scripting/ruby/ruby.h"
#include "util/error.h"
#include "util/file.h"
#include "util/string.h"
@ -36,25 +35,7 @@ VALUE erb_module;
void
alert_ruby_error(struct session *ses, unsigned char *msg)
{
struct terminal *term;
if (!ses) {
if (list_empty(terminals)) {
usrerror("[Ruby] %s", msg);
return;
}
term = terminals.next;
} else {
term = ses->tab->term;
}
msg = stracpy(msg);
if (!msg) return;
info_box(term, MSGBOX_NO_TEXT_INTL | MSGBOX_FREE_TEXT,
N_("Ruby Error"), ALIGN_LEFT, msg);
report_scripting_error(&ruby_scripting_module, ses, msg);
}
/* Another Vim treat. */

View File

@ -10,6 +10,9 @@
#include "intl/gettext/libintl.h"
#include "main/module.h"
#include "scripting/scripting.h"
#include "session/session.h"
#include "terminal/terminal.h"
#include "terminal/window.h"
/* Backends dynamic area: */
@ -22,6 +25,43 @@
#include "scripting/see/see.h"
/* Error reporting. */
#if defined(CONFIG_RUBY) || defined(CONFIG_SEE)
void
report_scripting_error(struct module *module, struct session *ses,
unsigned char *msg)
{
struct terminal *term;
struct string string;
if (!ses) {
if (list_empty(terminals)) {
usrerror("%s error] %s", module->name, msg);
return;
}
term = terminals.next;
} else {
term = ses->tab->term;
}
if (!init_string(&string))
return;
add_format_to_string(&string,
_("An error occurred while running a %s script", term),
module->name);
add_format_to_string(&string, ":\n\n%s", msg);
info_box(term, MSGBOX_NO_TEXT_INTL | MSGBOX_FREE_TEXT,
N_("Browser scripting error"), ALIGN_LEFT, string.source);
}
#endif
static struct module *scripting_modules[] = {
#ifdef CONFIG_LUA
&lua_scripting_module,

View File

@ -6,6 +6,11 @@
#ifdef CONFIG_SCRIPTING
struct module;
struct session;
void
report_scripting_error(struct module *module, struct session *ses,
unsigned char *msg);
extern struct module scripting_module;

View File

@ -13,10 +13,9 @@
#include "config/home.h"
#include "intl/gettext/libintl.h"
#include "main/module.h"
#include "scripting/scripting.h"
#include "scripting/see/core.h"
#include "session/session.h"
#include "terminal/terminal.h"
#include "terminal/window.h"
#include "scripting/see/see.h"
#include "util/error.h"
#include "util/file.h"
#include "util/string.h"
@ -62,25 +61,7 @@ convert_see_string(struct string *string, struct SEE_string *source)
void
alert_see_error(struct session *ses, unsigned char *msg)
{
struct terminal *term;
if (!ses) {
if (list_empty(terminals)) {
usrerror("[SEE script] %s", msg);
return;
}
term = terminals.next;
} else {
term = ses->tab->term;
}
msg = stracpy(msg);
if (!msg) return;
info_box(term, MSGBOX_NO_TEXT_INTL | MSGBOX_FREE_TEXT,
N_("SEE error"), ALIGN_LEFT, msg);
report_scripting_error(&see_scripting_module, ses, msg);
}