Пример #1
0
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);
}
Пример #2
0
/* Inspired by Vim this is used to hook into the stdout write method so written
 * data is displayed in a nice message box. */
static VALUE
erb_module_message(VALUE self, VALUE str)
{
	unsigned char *message, *line_end;
	struct terminal *term;

	str = rb_obj_as_string(str);
	message = memacpy(RSTRING(str)->ptr, RSTRING(str)->len);
	if (!message) return Qnil;

	line_end = strchr(message, '\n');
	if (line_end) *line_end = '\0';

	term = get_default_terminal();
	if (!term) {
		usrerror("[Ruby] %s", message);
		mem_free(message);
		return Qnil;
	}

	info_box(term, MSGBOX_NO_TEXT_INTL | MSGBOX_FREE_TEXT,
		 N_("Ruby Message"), ALIGN_LEFT, message);

	return Qnil;
}
Пример #3
0
void
menu_about(struct terminal *term, void *xxx, void *xxxx)
{
	info_box(term, MSGBOX_FREE_TEXT,
		 N_("About"), ALIGN_CENTER,
		 get_dyn_full_version(term, 1));
}
Пример #4
0
void download_error_dialog( struct file_download *file_download, int saved_errno )
{
  struct terminal *term;
  strerror( saved_errno );
  term = file_download->term;
  if ( file_download->ses )
  {
    info_box( &term[0], MSGBOX_FREE_TEXT, "Download error", ALIGN_CENTER );
  }
  return;
}
Пример #5
0
static void
error_reporter(JSContext *ctx, const char *message, JSErrorReport *report)
{
	struct ecmascript_interpreter *interpreter = JS_GetContextPrivate(ctx);
	struct session *ses = interpreter->vs->doc_view->session;
	struct terminal *term;
	unsigned char *strict, *exception, *warning, *error;
	struct string msg;

	assert(interpreter && interpreter->vs && interpreter->vs->doc_view
	       && ses && ses->tab);
	if_assert_failed goto reported;

	term = ses->tab->term;

#ifdef CONFIG_LEDS
	set_led_value(ses->status.ecmascript_led, 'J');
#endif

	if (!get_opt_bool("ecmascript.error_reporting", ses)
	    || !init_string(&msg))
		goto reported;

	strict	  = JSREPORT_IS_STRICT(report->flags) ? " strict" : "";
	exception = JSREPORT_IS_EXCEPTION(report->flags) ? " exception" : "";
	warning   = JSREPORT_IS_WARNING(report->flags) ? " warning" : "";
	error	  = !report->flags ? " error" : "";

	add_format_to_string(&msg, _("A script embedded in the current "
			"document raised the following%s%s%s%s", term),
			strict, exception, warning, error);

	add_to_string(&msg, ":\n\n");
	add_to_string(&msg, message);

	if (report->linebuf && report->tokenptr) {
		int pos = report->tokenptr - report->linebuf;

		add_format_to_string(&msg, "\n\n%s\n.%*s^%*s.",
			       report->linebuf,
			       pos - 2, " ",
			       strlen(report->linebuf) - pos - 1, " ");
	}

	info_box(term, MSGBOX_FREE_TEXT, N_("JavaScript Error"), ALIGN_CENTER,
		 msg.source);

reported:
	/* Im clu'les. --pasky */
	JS_ClearPendingException(ctx);
}
Пример #6
0
/* The global Kernel::p method will for each object, directly write
 * object.inspect() followed by the current output record separator to the
 * program's standard output and will bypass the Ruby I/O libraries.
 *
 * Inspired by Vim we hook into the method and pop up a nice message box so it
 * can be used to easily debug scripts without dirtying the screen. */
static VALUE
erb_stdout_p(int argc, VALUE *argv, VALUE self)
{
	int i;
	struct string string;
	struct terminal *term;

	if (!init_string(&string))
		return Qnil;

	for (i = 0; i < argc; i++) {
		VALUE substr;
		unsigned char *ptr;
		int len;

		if (i > 0)
			add_to_string(&string, ", ");

		substr = rb_inspect(argv[i]);

		/* The Ruby p() function writes variable number of objects using
		 * the inspect() method, which adds quotes to the strings, so
		 * gently ignore them. */

		ptr = RSTRING(substr)->ptr;
		len = RSTRING(substr)->len;

		if (*ptr == '"')
			ptr++, len--;

		if (ptr[len - 1] == '"')
			len--;

		add_bytes_to_string(&string, ptr, len);
	}

	term = get_default_terminal();
	if (!term) {
		usrerror("[Ruby] %s", string.source);
		done_string(&string);
		return Qnil;
	}

	info_box(term, MSGBOX_NO_TEXT_INTL | MSGBOX_FREE_TEXT,
		N_("Ruby Message"), ALIGN_LEFT, string.source);

	return Qnil;
}
Пример #7
0
void
menu_copying(struct terminal *term, void *xxx, void *xxxx)
{
	info_box(term, MSGBOX_FREE_TEXT,
		 N_("Copying"), ALIGN_CENTER,
		 msg_text(term, N_("ELinks %s\n"
		 	 "\n"
			 "%s"
			  "et al.\n"
			 "\n"
			 "This program is free software; you can redistribute it "
			 "and/or modify it under the terms of the GNU General Public "
			 "License as published by the Free Software Foundation, "
			 "specifically version 2 of the License."),
			 VERSION_STRING, COPYRIGHT_STRING));
}
Пример #8
0
void update_finalize(pixel *vid_buf)
{
	if (!update_flag) return;
	info_box(vid_buf, "Finalizing update...");
	if (last_major>SAVE_VERSION || (last_major==SAVE_VERSION && last_minor>=MINOR_VERSION))
	{
		update_cleanup();
		error_ui(vid_buf, 0, "Update failed - try downloading a new version.");
	}
	else
	{
		if (update_finish())
			error_ui(vid_buf, 0, "Update failed - try downloading a new version.");
		else
			info_ui(vid_buf, "Update success", "You have successfully updated the Powder Toy!");
	}
	update_flag = 0;
}
Пример #9
0
static widget_handler_status_T
push_invalidate_button(struct dialog_data *dlg_data, struct widget_data *button)
{
	struct terminal *term = dlg_data->win->term;
	struct listbox_data *box = get_dlg_listbox_data(dlg_data);
	struct cache_entry *cached = box->sel->udata;

	if (!box->sel || !box->sel->udata) return EVENT_PROCESSED;

	assert(box->sel->type == BI_LEAF);

	cached->valid = 0;

	info_box(term, 0, N_("Cache entry invalidated"), ALIGN_CENTER,
		 N_("Cache entry invalidated."));

	return EVENT_PROCESSED;
}
Пример #10
0
widget_handler_status_T push_login_button( struct dialog_data *dlg_data, struct widget_data *button )
{
  int edx;
  struct listbox_data *box;
  struct terminal *term;
  &box[0] = &dlg_data->widgets_data->widget[0].ops[0].display[0];
  term = &dlg_data->box.width;
  &box[0] = &box->sel->next;
  if ( box->sel && box[1] )
  {
    if ( ( box->sel_offset/*.1_1of4*/ & 1 ) & 255 )
    {
      info_box( &term[0], 0, "Form not saved", ALIGN_CENTER, "No saved information for this URL.\nIf you want to save passwords for this URL, enable it by pressing the \"Toggle saving\" button." );
      &box[0] = 0;
      return 0;
    }
    &box[0] = &button->widget->ops->display[0];
    push_hierbox_goto_button( &dlg_data[0], button );
  }
  &box[0] = 0;
  return 0;
}
Пример #11
0
void
concater_rep::flag_ok (string s, path ip, color col) {
  path dip = decorate_right (ip);
  SI h= 4*env->fn->wfn/5;
  int r, g, b, a;
  get_rgb_color (col, r, g, b, a);
  //r= 255- (255 - r)/6;
  //g= 255- (255 - g)/6;
  //b= 255- (255 - b)/6;
  a= a/6;
  color light= rgb_color (r, g, b, a);
  int info= env->info_level;
  if (info == INFO_MINIMAL || info == INFO_SHORT || info == INFO_SHORT_PAPER) {
    box infob= info_box (dip, h, pencil (col, env->fn->wline), light);
    if (info == INFO_SHORT_PAPER) {
      box b= resize_box (ip, infob, 0, 0, 0, env->fn->yx);
      print (b);
    }
    else {
      box specb= specific_box (ip, infob, "screen", env->fn);
      print (specb);
    }
  }
  else if (info == INFO_DETAILED || info == INFO_PAPER) {
    int sz= script (env->fn_size, env->index_level+2);
    font gfn (tex_font ("ecrm", sz, (int) (env->magn*env->dpi)));
    box textb= text_box (decorate (ip), 0, s, gfn, col);
    box flagb= flag_box (dip, textb, h, pencil (col, env->fn->wline), light);
    if (info == INFO_DETAILED) {
      box specb= specific_box (ip, flagb, "screen", env->fn);
      print (specb);
    }
    else {
      box b= resize_box (ip, flagb, 0, 0, 0, env->fn->yx);
      print (b);
    }
  }
}
Пример #12
0
void download_data_store( struct download *download, struct file_download *file_download )
{
  struct terminal *term = file_download->term;
  assert_terminal_ptr_not_dangling( file_download->term );
  if ( assert_failed )
  {
    assert_failed = 0;
    file_download->term = 0;
    abort_download( &file_download[0] );
    term = &term[0];
    return;
  }
  else
  {
    if ( term[0].next == 0 )
    {
      abort_download( &file_download[0] );
      term = &term[0];
      return;
    }
    else
    {
      if ( download->state.basic >= 0 )
      {
        if ( file_download->dlg_data )
        {
          redraw_dialog( file_download->dlg_data, 1 );
          return;
        }
        else
        {
          return;
        }
      }
      else
      {
        if ( file_download->dlg_data != -100000 )
        {
          unsigned char *url = get_uri_string( file_download->uri, URI_PUBLIC );
          struct connection_state state = download->state;
          state.syserr = download->state.syserr;
          abort_download_and_beep( &file_download[0], &term[0] );
          if ( url )
          {
            info_box( &term[0], MSGBOX_FREE_TEXT, "Download error", ALIGN_CENTER );
            mem_free( (void*)url );
            return;
          }
          else
          {
            return;
          }
        }
        else
        {
          if ( file_download->external_handler )
          {
            close( file_download->handle );
            file_download->handle = -1;
            exec_on_terminal( &term[0], file_download->external_handler, file_download->file, ( (int)file_download->bits_at_104/*.1_1of4*/ >> 2 ) & 1 );
            file_download->bits_at_104/*.1_1of4*/ &= 254;
            abort_download_and_beep( &file_download[0], &term[0] );
            return;
          }
          else
          {
            if ( file_download->notify )
            {
              unsigned char *url;
              url[0] = get_uri_string( file_download->uri, URI_PUBLIC );
              done_download_display( &file_download[0] );
              if ( url[0] )
              {
                info_box( &term[0], MSGBOX_FREE_TEXT, "Download", ALIGN_CENTER );
                mem_free( &url[0] );
              }
            }
            if ( file_download->remotetime && *(int*)(get_opt_( config_options, (unsigned char*)config_options )) )
            {
              struct utimbuf foo;
              foo.modtime = file_download->remotetime;
              foo.actime = file_download->remotetime;
              utime( (char*)file_download->file, &foo.actime );
            }
            abort_download_and_beep( &file_download[0], &term[0] );
            return;
          }
        }
      }
    }
Пример #13
0
void
textarea_edit(int op, struct terminal *term_, struct form_state *fs_,
	      struct document_view *doc_view_, struct link *link_)
{
	struct textarea_data *td = NULL;

	assert ((op == 0 || op == 1) && term_);
	if_assert_failed return;

	if (op == 0 && get_cmd_opt_bool("anonymous")) {
		info_box(term_, 0, N_("Error"), ALIGN_CENTER,
			 N_("You cannot launch an external"
			    " editor in the anonymous mode."));
		return;
	}

	if (op == 0) {
		unsigned char *ed;
		unsigned char *ex;

		assert(fs_ && doc_view_ && link_ && term_);

		td = init_textarea_data(term_, fs_, doc_view_, link_);
		if (!td)
			return;

		ed = get_opt_str("document.browse.forms.editor",
		                 doc_view_->session);
		if (!ed || !*ed) {
			ed = getenv("EDITOR");
			if (!ed || !*ed) ed = "vi";
		}

		ex = straconcat(ed, " ", td->fn, (unsigned char *) NULL);
		if (!ex) {
			unlink(td->fn);
			done_textarea_data(td);
			return;
		}

		td->term->textarea_data = td;

		exec_on_terminal(td->term, ex, "", TERM_EXEC_FG);
		mem_free(ex);

		return;

	} else if (op == 1) {
		struct string file;

		td = term_->textarea_data;
		term_->textarea_data = NULL;
		assert(td);

		if (!td->fs || !init_string(&file)
		    || !add_file_to_string(&file, td->fn)) {
			done_textarea_data(td);
			return;
		}

		if (file.length > td->fc_maxlength) {
			file.source[td->fc_maxlength] = '\0';
			/* Casting size_t fc_maxlength to unsigned int
			 * and formatting it with "%u" is safe,
			 * because fc_maxlength is smaller than
			 * file.length, which is an int.  */
			info_box(td->term, MSGBOX_FREE_TEXT, N_("Warning"),
			         ALIGN_CENTER,
			         msg_text(td->term,
				          N_("You have exceeded the textarea's"
				             " size limit: your input is %d"
					     " bytes, but the maximum is %u"
					     " bytes.\n\n"
					     "Your input has been truncated,"
					     " but you can still recover the"
					     " text that you entered from"
					     " this file: %s"), file.length,
				             (unsigned int) td->fc_maxlength, td->fn));
		} else {
			unlink(td->fn);
		}

		mem_free(td->fs->value);
		td->fs->value = file.source;
		td->fs->state = file.length;

		if (td->doc_view && td->link)
			draw_form_entry(td->term, td->doc_view, td->link);
	}

	done_textarea_data(td);
}