mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Move and make sense of the common code
This commit is contained in:
parent
1812e20212
commit
03118059ee
@ -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. */
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user