Esempio n. 1
0
    void fhs_table_row(const std::vector<std::string> cells)
    {
        ensure(html_locations::in_table,"Table row must be placed inside table body!");
        const static std::string row_open_text=filesystem::read_file(files::fhs_tbody_tr_open);
        const static std::string row_close_text=filesystem::read_file(files::fhs_tbody_tr_close);
        const static std::string cell_text=filesystem::read_file(files::fhs_tbody_td);

        insert_text(row_open_text);
        for(const std::string cell: cells)
            insert_text(easytext::replace_once(cell_text,"{cell}",cell));
        insert_text(row_close_text);
    }
Esempio n. 2
0
static void
virtual_keyboard_commit_preedit(struct virtual_keyboard *keyboard)
{
	char *surrounding_text;

	if (!keyboard->preedit_string ||
	    strlen(keyboard->preedit_string) == 0)
		return;

	wl_input_method_context_cursor_position(keyboard->context,
						0, 0);
	wl_input_method_context_commit_string(keyboard->context,
					      keyboard->serial,
					      keyboard->preedit_string);

	if (keyboard->surrounding_text) {
		surrounding_text = insert_text(keyboard->surrounding_text,
					       keyboard->surrounding_cursor,
					       keyboard->preedit_string);
		free(keyboard->surrounding_text);
		keyboard->surrounding_text = surrounding_text;
		keyboard->surrounding_cursor += strlen(keyboard->preedit_string);
	} else {
		keyboard->surrounding_text = strdup(keyboard->preedit_string);
		keyboard->surrounding_cursor = strlen(keyboard->preedit_string);
	}

	free(keyboard->preedit_string);
	keyboard->preedit_string = strdup("");
}
Esempio n. 3
0
 void h2(std::string title)
 {
     ensure(html_locations::in_body,"Large pen is not valid out of body!");
     ensure(html_locations::out_table,"Large pen cannot be used inside table!");
     static std::string h2_t=filesystem::read_file(files::html_h2);
     insert_text(easytext::replace_once(h2_t,"{title}",title));
 }
Esempio n. 4
0
/******************************************************************
 Shows a given mail (part)
*******************************************************************/
static void show_mail(struct Read_Data *data, struct mail *m)
{
	char *buf;
	int buf_len;

	mail_decode(m);
	mail_decoded_data(m,(void**)&buf,&buf_len);

	if (!mystricmp(m->content_type,"text") && !mystricmp(m->content_subtype,"plain"))
	{
		char *html_mail;

		html_mail = text2html(buf, buf_len,TEXT2HTML_ENDBODY_TAG|TEXT2HTML_FIXED_FONT/*|(user.config.read_wordwrap?0:TEXT2HTML_NOWRAP)*/,"");//<FONT FACE=\"fixedmail\" SIZE=\"+1\">");
		if (html_mail)
		{
			#if 0
			GtkTextBuffer *buffer;
			GtkTextIter iter;
			buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(data->text_view));
			gtk_text_buffer_get_iter_at_line(buffer,&iter,0);
			gtk_text_buffer_insert(buffer,&iter,m->html_header,strlen(m->html_header));
			gtk_text_buffer_insert(buffer,&iter,html_mail,strlen(html_mail));
			#else
			html_document_clear(data->html_document);

			if (html_document_open_stream(data->html_document, "text/html"))
			{
				if (m->html_header) html_document_write_stream(data->html_document, m->html_header, strlen(m->html_header)-14 /* FIXME: hacky, remove </BODY></HTML>*/);
				html_document_write_stream(data->html_document, html_mail, strlen(html_mail));
				html_document_close_stream(data->html_document);
			}

			//printf("%s%s\n",m->html_header,html_mail);
			#endif
		}

	} else
	{
		#if 0
		GtkTextBuffer *buffer;
		GtkTextIter iter;
		buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(data->text_view));
		gtk_text_buffer_get_iter_at_line(buffer,&iter,0);
		gtk_text_buffer_insert(buffer,&iter,m->html_header,strlen(m->html_header));
		gtk_text_buffer_insert(buffer,&iter,html_mail,strlen(html_mail));
		gtk_text_buffer_insert(buffer,&iter,buf,buf_len);
		#endif
	}

#if 0
	if (!data->attachments_group)
	{
		mail_decode(m);
		insert_text(data, m);
	} else
	{
		DoMethod(data->attachments_group, MUIM_SetUDataOnce, m, MUIA_Selected, 1);
	}
#endif
}
Esempio n. 5
0
static void
mathText (xmlNode * node, int action)
{
  if (ud->stack[ud->top] == mtext)
    mathTrans ();
  insert_text (node);
}
Esempio n. 6
0
 void style(boost::filesystem::path filepath)
 {
     open_tag("style");
     insert_text(filesystem::read_file(filepath));
     next_line();
     close_tag("style");
 }
Esempio n. 7
0
 void js_inline(boost::filesystem::path filepath)
 {
     ensure(html_locations::in_head,"Cannot link to script out of head!");
     open_tag("script");
     insert_text(filesystem::read_file(filepath));
     next_line();
     close_tag("script");
 }
MessageText::MessageText()
{
  set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);

  add(m_TextView);
  insert_text();

  show_all_children();
}
Esempio n. 9
0
int
change_table (xmlNode * node)
{
  xmlNode *child;
  int branchCount = 0;
  const char *oldTable;
  const char *newTable;
  char completePath[MAXNAMELEN];
  newTable = (char *) get_attr_value (node);
  if (strlen ((char *) newTable) < 5)
    return 0;
  if (!find_file (newTable, completePath))
    {
      logMessage (LOU_LOG_ERROR, "Table %s cannot be found", newTable);
      return 0;
    }
  if (!lou_getTable (completePath))
    return 0;
  insert_translation (ud->main_braille_table);
  oldTable = ud->main_braille_table;
  ud->main_braille_table = completePath;
  child = node->children;
  while (child)
    {
      switch (child->type)
	{
	case XML_ELEMENT_NODE:
	  insert_code (node, branchCount);
	  branchCount++;
	  if (child->children)
	    transcribe_paragraph (child, 1);
	  break;
	case XML_TEXT_NODE:
	  insert_text (child);
	  break;
	default:
	  break;
	}
      child = child->next;
    }
  insert_code (node, branchCount);
  insert_code (node, -1);
  insert_translation (ud->main_braille_table);
  ud->main_braille_table = oldTable;
  pop_sem_stack ();
  return 1;
}
Esempio n. 10
0
gboolean
gimp_text_buffer_deserialize (GtkTextBuffer *register_buffer,
                              GtkTextBuffer *content_buffer,
                              GtkTextIter   *iter,
                              const guint8  *text,
                              gsize          length,
                              gboolean       create_tags,
                              gpointer       user_data,
                              GError       **error)
{
  GMarkupParseContext *context;
  ParseInfo            info;
  gboolean             retval = FALSE;

  static const GMarkupParser markup_parser =
  {
    start_element_handler,
    end_element_handler,
    text_handler,
    NULL,
    NULL
  };

  parse_info_init (&info, register_buffer, content_buffer);

  context = g_markup_parse_context_new (&markup_parser, 0, &info, NULL);

  if (! g_markup_parse_context_parse (context,
                                      (const gchar *) text,
                                      length,
                                      error))
    goto out;

  if (! g_markup_parse_context_end_parse (context, error))
    goto out;

  retval = TRUE;

  insert_text (&info, iter);

 out:
  parse_info_free (&info);

  g_markup_parse_context_free (context);

  return retval;
}
Esempio n. 11
0
/******************************************************************
 An Icon has selected
*******************************************************************/
void icon_selected(int **pdata)
{
	struct Read_Data *data = (struct Read_Data*)(pdata[0]);
	Object *icon = (Object*)(pdata[1]);
	struct mail *mail;

	if (icon == data->attachments_last_selected) return;
	if (data->attachments_last_selected)
		set(data->attachments_last_selected, MUIA_Selected, 0);

	if ((mail = (struct mail*)xget(icon,MUIA_UserData)))
	{
		mail_decode(mail);
		insert_text(data,mail);
	}
	data->attachments_last_selected = icon;
}
void PythonCodeContainer::insertFromMimeData(const QMimeData *source){
  if (source->hasText())
    insert_text(source->text());
  if (source->hasFormat("application/x-qabstractitemmodeldatalist")){
    QString text;
    QList<const QListWidgetItem*> sorted_items;
    foreach (const QListWidgetItem* item, python_console->get_history_list_widget()->selectedItems()){
      QList<const QListWidgetItem*>::iterator itt=sorted_items.begin();
      for (;itt != sorted_items.end();itt++){
        if ((*itt)->type() > item->type())
          break;
      }
      sorted_items.insert(itt,item);
    }
    foreach (const QListWidgetItem* item, sorted_items){
      text.append(item->text()+"\n");
    }
Esempio n. 13
0
int
main (int argc, char **argv)
{
  GtkWidget *window, *textview, *sw, *button, *button2;
  GtkTextBuffer *buffer;
  GtkTextChildAnchor *anchor;

  gtk_init ();

  window   = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  sw       = gtk_scrolled_window_new (NULL, NULL);
  textview = g_object_new (my_text_view_get_type (), NULL);
  buffer   = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview));
  button   = gtk_button_new_with_label ("Fixed Child");
  button2   = gtk_button_new_with_label ("Flowed Child");

  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
                                  GTK_POLICY_AUTOMATIC,
                                  GTK_POLICY_AUTOMATIC);

  gtk_window_set_default_size (GTK_WINDOW (window), 400, 400);

  create_tags (buffer);
  anchor = insert_text (buffer);

  gtk_container_add (GTK_CONTAINER (window), sw);
  gtk_container_add (GTK_CONTAINER (sw), textview);
  gtk_text_view_add_child_in_window (GTK_TEXT_VIEW (textview),
                                     button,
                                     GTK_TEXT_WINDOW_TEXT,
                                     50, 150);

  gtk_text_view_add_child_at_anchor (GTK_TEXT_VIEW (textview),
                                     button2, anchor);

  gtk_widget_show (window);

  gtk_main ();

  return 0;
}
Esempio n. 14
0
File: t24.cpp Progetto: ombt/ombt
/* Create a scrolled text area that displays a "message" */
static GtkWidget *create_text( void )
{
   GtkWidget *scrolled_window;
   GtkWidget *view;
   GtkTextBuffer *buffer;

   view = gtk_text_view_new ();
   buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));

   scrolled_window = gtk_scrolled_window_new (NULL, NULL);
   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
		   	           GTK_POLICY_AUTOMATIC,
				   GTK_POLICY_AUTOMATIC);

   gtk_container_add (GTK_CONTAINER (scrolled_window), view);
   insert_text (buffer);

   gtk_widget_show_all (scrolled_window);

   return scrolled_window;
}
Esempio n. 15
0
unsigned ttext::insert_unicode(const unsigned offset, const ucs4::string& unicode)
{
	const utf8::string insert = unicode_cast<utf8::string>(unicode);
	return insert_text(offset, insert);
}
Esempio n. 16
0
static void
graphicText (xmlNode * node, int action)
{
insert_text (node);
}
Esempio n. 17
0
static cb_ret_t
query_callback (Dlg_head *h, dlg_msg_t msg, int parm)
{
    switch (msg) {
    case DLG_KEY:
	switch (parm) {
	case KEY_LEFT:
	case KEY_RIGHT:
	    h->ret_value = 0;
	    dlg_stop (h);
	    return 1;

	case KEY_BACKSPACE:
	    if (end == min_end) {
		h->ret_value = 0;
		dlg_stop (h);
		return 1;
	    } else {
		WLEntry *e, *e1;

		e1 = e = ((WListbox *) (h->current))->list;
		do {
		    if (!strncmp
			(input->buffer + start, e1->text,
			 end - start - 1)) {
			listbox_select_entry ((WListbox *) (h->current),
					      e1);
			handle_char (input, parm);
			end--;
			send_message (h->current, WIDGET_DRAW, 0);
			break;
		    }
		    e1 = e1->next;
		} while (e != e1);
	    }
	    return 1;

	default:
	    if (parm > 0xff || !is_printable (parm)) {
		if (is_in_input_map (input, parm) == 2) {
		    if (end == min_end)
			return 1;
		    h->ret_value = B_USER;	/* This means we want to refill the
						   list box and start again */
		    dlg_stop (h);
		    return 1;
		} else
		    return 0;
	    } else {
		WLEntry *e, *e1;
		int need_redraw = 0;
		int low = 4096;
		char *last_text = NULL;

		e1 = e = ((WListbox *) (h->current))->list;
		do {
		    if (!strncmp
			(input->buffer + start, e1->text, end - start)) {
			if (e1->text[end - start] == parm) {
			    if (need_redraw) {
				register int c1, c2, si;

				for (si = end - start + 1;
				     (c1 = last_text[si])
				     && (c2 = e1->text[si]); si++)
				    if (c1 != c2)
					break;
				if (low > si)
				    low = si;
				last_text = e1->text;
				need_redraw = 2;
			    } else {
				need_redraw = 1;
				listbox_select_entry ((WListbox *) (h->
								    current),
						      e1);
				last_text = e1->text;
			    }
			}
		    }
		    e1 = e1->next;
		} while (e != e1);
		if (need_redraw == 2) {
		    insert_text (input, last_text, low);
		    send_message (h->current, WIDGET_DRAW, 0);
		} else if (need_redraw == 1) {
		    h->ret_value = B_ENTER;
		    dlg_stop (h);
		}
	    }
	    return MSG_HANDLED;
	}
	break;

    default:
	return default_dlg_callback (h, msg, parm);
    }
}
Esempio n. 18
0
/* Returns 1 if the user would like to see us again */
static int
complete_engine (WInput *in, int what_to_do)
{
    if (in->completions && in->point != end)
    	free_completions (in);
    if (!in->completions){
    	end = in->point;
        for (start = end ? end - 1 : 0; start > -1; start--)
    	    if (strchr (" \t;|<>", in->buffer [start]))
    	        break;
    	if (start < end)
    	    start++;
    	in->completions = try_complete (in->buffer, &start, &end, in->completion_flags);
    }
    if (in->completions){
    	if (what_to_do & DO_INSERTION || ((what_to_do & DO_QUERY) && !in->completions[1])) {
    	    if (insert_text (in, in->completions [0], strlen (in->completions [0]))){
    	        if (in->completions [1])
    	    	    beep ();
		else
		    free_completions (in);
	    } else
	        beep ();
        }
    	if ((what_to_do & DO_QUERY) && in->completions && in->completions [1]) {
    	    int maxlen = 0, i, count = 0;
    	    int x, y, w, h;
    	    int start_x, start_y;
    	    char **p, *q;
    	    Dlg_head *query_dlg;
    	    WListbox *query_list;
    	    
    	    for (p=in->completions + 1; *p; count++, p++)
    	    	if ((i = strlen (*p)) > maxlen)
    	    	    maxlen = i;
    	    start_x = in->widget.x;
    	    start_y = in->widget.y;
    	    if (start_y - 2 >= count) {
    	    	y = start_y - 2 - count;
    	    	h = 2 + count;
    	    } else {
    	    	if (start_y >= LINES - start_y - 1) {
    	    	    y = 0;
    	    	    h = start_y;
    	    	} else {
    	    	    y = start_y + 1;
    	    	    h = LINES - start_y - 1;
    	    	}
    	    }
    	    x = start - in->first_shown - 2 + start_x;
    	    w = maxlen + 4;
    	    if (x + w > COLS)
    	    	x = COLS - w;
    	    if (x < 0)
    	    	x = 0;
    	    if (x + w > COLS)
    	    	w = COLS;
    	    input = in;
    	    min_end = end;
	    query_height = h;
	    query_width  = w;
    	    query_dlg = create_dlg (y, x, query_height, query_width,
				    dialog_colors, query_callback,
				    "[Completion]", NULL, DLG_COMPACT);
    	    query_list = listbox_new (1, 1, w - 2, h - 2, NULL);
    	    add_widget (query_dlg, query_list);
    	    for (p = in->completions + 1; *p; p++)
    	    	listbox_add_item (query_list, 0, 0, *p, NULL);
    	    run_dlg (query_dlg);
    	    q = NULL;
    	    if (query_dlg->ret_value == B_ENTER){
    	    	listbox_get_current (query_list, &q, NULL);
    	    	if (q)
    	    	    insert_text (in, q, strlen (q));
    	    }
    	    if (q || end != min_end)
    	    	free_completions (in);
    	    i = query_dlg->ret_value; /* B_USER if user wants to start over again */
    	    destroy_dlg (query_dlg);
    	    if (i == B_USER)
    	    	return 1;
    	}
    } else
    	beep ();
    return 0;
}
Esempio n. 19
0
static int
complete_engine (WInput * in, int what_to_do)
{
    if (in->completions != NULL && str_offset_to_pos (in->buffer, in->point) != end)
        input_free_completions (in);
    if (in->completions == NULL)
    {
        char *s;

        end = str_offset_to_pos (in->buffer, in->point);

        s = in->buffer;
        if (in->point != 0)
        {
            /* get symbol before in->point */
            size_t i;
            for (i = in->point - 1; i > 0; i--)
                str_next_char (&s);
        }

        for (; s >= in->buffer; str_prev_char (&s))
        {
            start = s - in->buffer;
            if (strchr (" \t;|<>", *s) != NULL)
                break;
        }

        if (start < end)
        {
            str_next_char (&s);
            start = s - in->buffer;
        }

        in->completions = try_complete (in->buffer, &start, &end, in->completion_flags);
    }

    if (in->completions != NULL)
    {
        if (what_to_do & DO_INSERTION || ((what_to_do & DO_QUERY) && !in->completions[1]))
        {
            char *lc_complete = in->completions[0];
            if (insert_text (in, lc_complete, strlen (lc_complete)))
            {
                if (in->completions[1])
                    tty_beep ();
                else
                    input_free_completions (in);
            }
            else
                tty_beep ();
        }
        if ((what_to_do & DO_QUERY) && in->completions && in->completions[1])
        {
            int maxlen = 0, i, count = 0;
            int x, y, w, h;
            int start_x, start_y;
            char **p, *q;
            Dlg_head *query_dlg;
            WListbox *query_list;

            for (p = in->completions + 1; *p != NULL; count++, p++)
            {
                i = str_term_width1 (*p);
                if (i > maxlen)
                    maxlen = i;
            }
            start_x = in->widget.x;
            start_y = in->widget.y;
            if (start_y - 2 >= count)
            {
                y = start_y - 2 - count;
                h = 2 + count;
            }
            else
            {
                if (start_y >= LINES - start_y - 1)
                {
                    y = 0;
                    h = start_y;
                }
                else
                {
                    y = start_y + 1;
                    h = LINES - start_y - 1;
                }
            }
            x = start - in->term_first_shown - 2 + start_x;
            w = maxlen + 4;
            if (x + w > COLS)
                x = COLS - w;
            if (x < 0)
                x = 0;
            if (x + w > COLS)
                w = COLS;
            input = in;
            min_end = end;
            query_height = h;
            query_width = w;
            query_dlg = create_dlg (TRUE, y, x, query_height, query_width,
                                    dialog_colors, query_callback, NULL,
                                    "[Completion]", NULL, DLG_COMPACT);
            query_list = listbox_new (1, 1, h - 2, w - 2, FALSE, NULL);
            add_widget (query_dlg, query_list);
            for (p = in->completions + 1; *p; p++)
                listbox_add_item (query_list, LISTBOX_APPEND_AT_END, 0, *p, NULL);
            run_dlg (query_dlg);
            q = NULL;
            if (query_dlg->ret_value == B_ENTER)
            {
                listbox_get_current (query_list, &q, NULL);
                if (q)
                    insert_text (in, q, strlen (q));
            }
            if (q || end != min_end)
                input_free_completions (in);
            i = query_dlg->ret_value;   /* B_USER if user wants to start over again */
            destroy_dlg (query_dlg);
            if (i == B_USER)
                return 1;
        }
    }
    else
        tty_beep ();
    return 0;
}
Esempio n. 20
0
 void insert_template(boost::filesystem::path filepath)
 {
     std::string text=filesystem::read_file(filepath);
     insert_text(text);
 }
Esempio n. 21
0
 void open_tag(std::string tagname)
 {
     insert_text(std::string("<")+tagname+">\n");
 }
Esempio n. 22
0
static cb_ret_t
query_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *data)
{
    static char buff[MB_LEN_MAX] = "";
    static int bl = 0;

    switch (msg)
    {
    case DLG_KEY:
        switch (parm)
        {
        case KEY_LEFT:
        case KEY_RIGHT:
            bl = 0;
            h->ret_value = 0;
            dlg_stop (h);
            return MSG_HANDLED;

        case KEY_BACKSPACE:
            bl = 0;
            /* exit from completion list if input line is empty */
            if (end == 0)
            {
                h->ret_value = 0;
                dlg_stop (h);
            }
            /* Refill the list box and start again */
            else if (end == min_end)
            {
                end = str_get_prev_char (&input->buffer[end]) - input->buffer;
                input_handle_char (input, parm);
                h->ret_value = B_USER;
                dlg_stop (h);
                return MSG_HANDLED;
            }
            else
            {
                int new_end;
                int i;
                GList *e;

                new_end = str_get_prev_char (&input->buffer[end]) - input->buffer;

                for (i = 0, e = ((WListbox *) h->current->data)->list;
                     e != NULL; i++, e = g_list_next (e))
                {
                    WLEntry *le = (WLEntry *) e->data;

                    if (strncmp (input->buffer + start, le->text, new_end - start) == 0)
                    {
                        listbox_select_entry ((WListbox *) h->current->data, i);
                        end = new_end;
                        input_handle_char (input, parm);
                        send_message ((Widget *) h->current->data, WIDGET_DRAW, 0);
                        break;
                    }
                }
            }
            return MSG_HANDLED;

        default:
            if (parm < 32 || parm > 255)
            {
                bl = 0;
                if (input_key_is_in_map (input, parm) != 2)
                    return MSG_NOT_HANDLED;

                if (end == min_end)
                    return MSG_HANDLED;

                /* This means we want to refill the list box and start again */
                h->ret_value = B_USER;
                dlg_stop (h);
                return MSG_HANDLED;
            }
            else
            {
                GList *e;
                int i;
                int need_redraw = 0;
                int low = 4096;
                char *last_text = NULL;

                buff[bl++] = (char) parm;
                buff[bl] = '\0';
                switch (str_is_valid_char (buff, bl))
                {
                case -1:
                    bl = 0;
                    /* fallthrough */
                case -2:
                    return MSG_HANDLED;
                }

                for (i = 0, e = ((WListbox *) h->current->data)->list;
                     e != NULL; i++, e = g_list_next (e))
                {
                    WLEntry *le = (WLEntry *) e->data;

                    if (strncmp (input->buffer + start, le->text, end - start) == 0
                        && strncmp (&le->text[end - start], buff, bl) == 0)
                    {
                        if (need_redraw == 0)
                        {
                            need_redraw = 1;
                            listbox_select_entry ((WListbox *) h->current->data, i);
                            last_text = le->text;
                        }
                        else
                        {
                            char *si, *sl;
                            int si_num = 0;
                            int sl_num = 0;

                            /* count symbols between start and end */
                            for (si = le->text + start; si < le->text + end;
                                 str_next_char (&si), si_num++)
                                ;
                            for (sl = last_text + start; sl < last_text + end;
                                 str_next_char (&sl), sl_num++)
                                ;

                            /* pointers to next symbols */
                            si = &le->text[str_offset_to_pos (le->text, ++si_num)];
                            sl = &last_text[str_offset_to_pos (last_text, ++sl_num)];

                            while (si[0] != '\0' && sl[0] != '\0')
                            {
                                char *nexti, *nextl;

                                nexti = str_get_next_char (si);
                                nextl = str_get_next_char (sl);

                                if (nexti - si != nextl - sl || strncmp (si, sl, nexti - si) != 0)
                                    break;

                                si = nexti;
                                sl = nextl;

                                si_num++;
                            }

                            last_text = le->text;

                            si = &last_text[str_offset_to_pos (last_text, si_num)];
                            if (low > si - last_text)
                                low = si - last_text;

                            need_redraw = 2;
                        }
                    }
                }

                if (need_redraw == 2)
                {
                    insert_text (input, last_text, low);
                    send_message ((Widget *) h->current->data, WIDGET_DRAW, 0);
                }
                else if (need_redraw == 1)
                {
                    h->ret_value = B_ENTER;
                    dlg_stop (h);
                }
                bl = 0;
            }
            return MSG_HANDLED;
        }
        break;

    default:
        return default_dlg_callback (h, sender, msg, parm, data);
    }
}
Esempio n. 23
0
GtkWidget *
do_textview (GtkWidget *do_widget)
{
  static GtkWidget *window = NULL;

  if (!window)
    {
      GtkWidget *vpaned;
      GtkWidget *view1;
      GtkWidget *view2;
      GtkWidget *sw;
      GtkTextBuffer *buffer;
      
      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
      gtk_window_set_screen (GTK_WINDOW (window),
			     gtk_widget_get_screen (do_widget));
      gtk_window_set_default_size (GTK_WINDOW (window),
				   450, 450);
      
      g_signal_connect (window, "destroy",
			G_CALLBACK (gtk_widget_destroyed), &window);

      gtk_window_set_title (GTK_WINDOW (window), "TextView");
      gtk_container_set_border_width (GTK_CONTAINER (window), 0);

      vpaned = gtk_vpaned_new ();
      gtk_container_set_border_width (GTK_CONTAINER(vpaned), 5);
      gtk_container_add (GTK_CONTAINER (window), vpaned);

      /* For convenience, we just use the autocreated buffer from
       * the first text view; you could also create the buffer
       * by itself with gtk_text_buffer_new(), then later create
       * a view widget.
       */
      view1 = gtk_text_view_new ();
      buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view1));
      view2 = gtk_text_view_new_with_buffer (buffer);
      
      sw = gtk_scrolled_window_new (NULL, NULL);
      gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
				      GTK_POLICY_AUTOMATIC,
				      GTK_POLICY_AUTOMATIC);
      gtk_paned_add1 (GTK_PANED (vpaned), sw);

      gtk_container_add (GTK_CONTAINER (sw), view1);

      sw = gtk_scrolled_window_new (NULL, NULL);
      gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
				      GTK_POLICY_AUTOMATIC,
				      GTK_POLICY_AUTOMATIC);
      gtk_paned_add2 (GTK_PANED (vpaned), sw);

      gtk_container_add (GTK_CONTAINER (sw), view2);

      create_tags (buffer);
      insert_text (buffer);

      attach_widgets (GTK_TEXT_VIEW (view1));
      attach_widgets (GTK_TEXT_VIEW (view2));
      
      gtk_widget_show_all (vpaned);
    }

  if (!gtk_widget_get_visible (window))
    {
      gtk_widget_show (window);
    }
  else
    {
      gtk_widget_destroy (window);
      window = NULL;
    }

  return window;
}
Esempio n. 24
0
xptr deep_copy_node(xptr left, xptr right, xptr parent, xptr node, upd_ns_map** nsupdmap, bool save_types, unsigned short depth)
{
    xptr result;
    xptr node_indir;
    schema_node_cptr scmnode;
    xmlscm_type scm_type;

    /* Rollback transaction if timeout value's been exceeded */
    CHECK_TIMER_FLAG

#ifdef SE_ENABLE_FTSEARCH
    if (!depth) init_ft_sequences(left,right,parent);
#endif
#ifdef SE_ENABLE_TRIGGERS
    if (parent == XNULL) {
        if (left != XNULL) {
            CHECKP(left);
            parent = nodeGetParent(left);
        } else {
            CHECKP(right);
            parent = nodeGetParent(right);
        }
    }

    node = apply_per_node_triggers(node, XNULL, parent, XNULL, TRIGGER_BEFORE,  TRIGGER_INSERT_EVENT);

    if (node == XNULL) {
        if (left == XNULL) { return XNULL; }
        CHECKP(left);
        return left;
    }
#endif

    node_indir = getIndirectionSafeCP(node);
    scmnode = getSchemaNode(node);

    switch (scmnode->type) {
        case element: {
            xptr result_indir;
            xmlns_ptr ns = scmnode->get_xmlns();

            if (nsupdmap != NULL && ns != NULL_XMLNS) {
                replaceNamespace(ns, *nsupdmap);
            }

            scm_type = (save_types) ? getScmType(node) : xs_untyped;
            result = insert_element(left, right, parent, scmnode->name, scm_type, ns);
            result_indir = get_last_mo_inderection();

            copy_node_content(result_indir, indirectionDereferenceCP(node_indir), XNULL, nsupdmap, save_types, depth);

            result = indirectionDereferenceCP(result_indir);
            CHECKP(result);
                      }
                      break;

        case text: {
            if (CommonTextNode(node).isEmpty()) {
                if (IS_DATA_BLOCK(node)) {
                    throw SYSTEM_EXCEPTION("BAD DATA!!!");
                } else {
                    return left;
                }
            } else {
                if (getTextFlags(node, cdata_section) > 0) {
                     cdataflag_hint = cdata_section | cdata_inherit;
                }
                result = insert_text(left, right, parent, text_source_node(node));
                cdataflag_hint = 0;
            }
                   }
                   break;

        case comment: {
            text_membuf_t buf(text_source_node(node));
            result = insert_comment(left, right, parent, buf.getCstr(), buf.getSize());
                      }
                      break;

        case pr_ins: {
            size_t tsize = PINode(node).getPITargetSize();
            text_membuf_t buf(text_source_node(node));
            result = insert_pi(left, right, parent, buf.getCstr(), tsize, buf.getCstr() + tsize + 1, buf.getSize() - tsize - 1);
        }
        break;

        case attribute: {
            xmlns_ptr ns = scmnode->get_xmlns();
            text_membuf_t buf(text_source_node(node));

            if (nsupdmap != NULL && ns != NULL_XMLNS) {
                replaceNamespace(ns, *nsupdmap);
            };

            if (depth == 0 && ns != NULL_XMLNS) {
                const xmlns_ptr new_ns = swizzle_namespace(parent, ns);
                if (new_ns != NULL_XMLNS) {
                    insert_namespace(left, right, parent, new_ns);
                    ns = new_ns;
                }
            }

            CHECKP(node);
            scm_type = (save_types) ? AttributeNode(node).getType() : xs_untypedAtomic;
            result = insert_attribute(left, right, parent, scmnode->name, scm_type, buf.getCstr(), buf.getSize(), ns);
        }
        break;

        case xml_namespace: {
            xmlns_ptr ns = NSNode(node).getNamespaceLocal();

            /* That is bad to copy default namespace alone without its node  */
            if (ns->has_prefix() || depth > 0) {
                if (nsupdmap != NULL && ns->has_prefix()) {
                    replaceNamespace(ns, *nsupdmap);
                }

                if (depth == 0) {
                    const xmlns_ptr new_ns = swizzle_namespace(parent, ns);
                    if (new_ns != NULL_XMLNS) {
                        if (nsupdmap != NULL) { (**nsupdmap)[ns] = new_ns; }
                        ns = new_ns;
                    }
                }

                result = insert_namespace(left, right, parent, ns);
            } else {
                return left;
            }
        }
        break;

        default:
            throw SYSTEM_EXCEPTION("Deep copy error: document node copied");
    }

    CHECKP(result);

#ifdef SE_ENABLE_FTSEARCH
    update_insert_sequence(result, getSchemaNode(result));
#endif

#ifdef SE_ENABLE_TRIGGERS
    if (parent==XNULL) parent= nodeGetParentIndirection(left);
    apply_per_node_triggers(result, XNULL, parent, XNULL, TRIGGER_AFTER, TRIGGER_INSERT_EVENT);
#endif

    CHECKP(result);

    return result;
}
Esempio n. 25
0
 void close_tag(std::string tagname)
 {
     insert_text(std::string("</")+tagname+">\n");
 }
Esempio n. 26
0
 void fhs_table_column(std::string column)
 {
     const static std::string ct=filesystem::read_file(files::fhs_thead_column);
     insert_text(easytext::replace_once(ct,"{column_name}",column));
 }
Esempio n. 27
0
static void
chemText (xmlNode * node, int action)
{
insert_text (node);
}
Esempio n. 28
0
File: ui.c Progetto: senko/mawire
GtkWidget *
show_article_window (gchar *title, gchar *text)
{
  GtkWidget *win;
  GtkWidget *pannable;
  GtkWidget *vbox;
  GtkWidget *title_label;
  GtkWidget *text_box;
  GtkTextBuffer *buffer;
  GtkWidget *more;
  gchar *pango;

  win = hildon_stackable_window_new ();
  gtk_window_set_title (GTK_WINDOW (win), title);

  g_signal_connect (G_OBJECT (win), "delete-event",
      G_CALLBACK (gtk_widget_destroy), win);

  pannable = hildon_pannable_area_new ();

  g_object_set (pannable,
      "mov-mode", HILDON_MOVEMENT_MODE_VERT,
      "hscrollbar-policy", GTK_POLICY_NEVER,
      NULL);

  pango = g_markup_printf_escaped ("<span size='xx-large'>%s</span>", title);
  title_label = gtk_label_new (NULL);
  gtk_label_set_markup (GTK_LABEL (title_label), pango);
  gtk_misc_set_alignment (GTK_MISC (title_label), 0.0, 0.5);
  g_object_set (G_OBJECT (title_label), "wrap", TRUE, NULL);

  text_box = hildon_text_view_new ();
  gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (text_box), GTK_WRAP_WORD_CHAR);
  g_object_set (text_box, "editable", FALSE, NULL);
  buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_box));

  gtk_text_buffer_create_tag (buffer, "bold", "weight", PANGO_WEIGHT_BOLD,
      NULL);
  gtk_text_buffer_create_tag (buffer, "emph", "style", PANGO_STYLE_ITALIC,
      NULL);

  insert_text (buffer, text);
  vbox = gtk_vbox_new (FALSE, 10);

  gtk_box_pack_start (GTK_BOX (vbox), title_label, FALSE, FALSE, 10);
  gtk_box_pack_start (GTK_BOX (vbox), text_box, TRUE, TRUE, 0);

  more = hildon_button_new_with_text (
      HILDON_SIZE_FINGER_HEIGHT,
      HILDON_BUTTON_ARRANGEMENT_HORIZONTAL,
      "Read complete article on Wikipedia", NULL);
  gtk_box_pack_start (GTK_BOX (vbox), more, FALSE, FALSE, 0);

  gtk_container_add (GTK_CONTAINER (win), pannable);
  hildon_pannable_area_add_with_viewport (HILDON_PANNABLE_AREA (pannable),
      vbox);

  g_signal_connect (G_OBJECT (more), "clicked",
      G_CALLBACK (open_in_browser), g_strdup (title)); /* FIXME: memleak! */

  gtk_widget_show_all (win);
  return win;
}
Esempio n. 29
0
 void js_src(std::string js_url)
 {
     ensure(html_locations::in_head,"Cannot link to script out of head!");
     static std::string sc_hmtl=filesystem::read_file(files::js_src_template);
     insert_text(easytext::replace_once(sc_hmtl,"{src}",js_url));
 }