void set_status_from_gdb(const string& text) { if (private_gdb_input) return; if (!show_next_line_in_status && !text.contains(gdb->prompt(), -1)) return; // Fetch line before prompt in GDB window String s = XmTextGetString(gdb_w); string message = s + messagePosition; XtFree(s); if (message.empty() && text.contains('\n')) message = text; if (show_next_line_in_status && (message.empty() || message[message.length() - 1] != '\n')) return; // Skip prompt and uncomplete lines int idx = message.index('\n', -1); if (idx >= 0) message = message.before(idx); strip_trailing_newlines(message); if (message.empty() && text.contains('\n')) message = text; if (show_next_line_in_status) { messagePosition = XmTextGetLastPosition(gdb_w) + text.length(); show_next_line_in_status = false; message.gsub('\n', ' '); } else { // Show first line only while (!message.empty() && message[0] == '\n') message = message.after('\n'); if (message.contains('\n')) message = message.before('\n'); } strip_trailing_newlines(message); message.gsub('\t', ' '); if (message.empty()) return; // Don't log this stuff - it's already logged bool old_log_status = log_status; log_status = false; set_status(message); log_status = old_log_status; }
void delete_or_controlAct(Widget, XEvent *e, String *params, Cardinal *num_params) { clear_isearch(); string input = current_line(); strip_trailing_newlines(input); if (input.empty()) XtCallActionProc(gdb_w, "gdb-control", e, params, *num_params); else XtCallActionProc(gdb_w, "delete-next-character", e, params, *num_params); }
static gchar * parse_subviewer (ParserState * state, const gchar * line) { guint h1, m1, s1, ms1; guint h2, m2, s2, ms2; gchar *ret; /* TODO: Maybe also parse the fields in the header, especially DELAY. * For examples see the unit test or * http://www.doom9.org/index.html?/sub.htm */ switch (state->state) { case 0: /* looking for start_time,end_time */ if (sscanf (line, "%u:%u:%u.%u,%u:%u:%u.%u", &h1, &m1, &s1, &ms1, &h2, &m2, &s2, &ms2) == 8) { state->state = 1; state->start_time = (((guint64) h1) * 3600 + m1 * 60 + s1) * GST_SECOND + ms1 * GST_MSECOND; state->duration = (((guint64) h2) * 3600 + m2 * 60 + s2) * GST_SECOND + ms2 * GST_MSECOND - state->start_time; } return NULL; case 1: { /* No need to parse that text if it's out of segment */ gint64 clip_start = 0, clip_stop = 0; gboolean in_seg = FALSE; /* Check our segment start/stop */ in_seg = gst_segment_clip (state->segment, GST_FORMAT_TIME, state->start_time, state->start_time + state->duration, &clip_start, &clip_stop); if (in_seg) { state->start_time = clip_start; state->duration = clip_stop - clip_start; } else { state->state = 0; return NULL; } } /* looking for subtitle text; empty line ends this subtitle entry */ if (state->buf->len) g_string_append_c (state->buf, '\n'); g_string_append (state->buf, line); if (strlen (line) == 0) { ret = g_strdup (state->buf->str); subviewer_unescape_newlines (ret); strip_trailing_newlines (ret); g_string_truncate (state->buf, 0); state->state = 0; return ret; } return NULL; default: g_assert_not_reached (); return NULL; } }
static gchar * parse_subrip (ParserState * state, const gchar * line) { guint h1, m1, s1, ms1; guint h2, m2, s2, ms2; int subnum; gchar *ret; switch (state->state) { case 0: /* looking for a single integer */ if (sscanf (line, "%u", &subnum) == 1) state->state = 1; return NULL; case 1: /* looking for start_time --> end_time */ if (sscanf (line, "%u:%u:%u,%u --> %u:%u:%u,%u", &h1, &m1, &s1, &ms1, &h2, &m2, &s2, &ms2) == 8) { state->state = 2; state->start_time = (((guint64) h1) * 3600 + m1 * 60 + s1) * GST_SECOND + ms1 * GST_MSECOND; state->duration = (((guint64) h2) * 3600 + m2 * 60 + s2) * GST_SECOND + ms2 * GST_MSECOND - state->start_time; } else { GST_DEBUG ("error parsing subrip time line"); state->state = 0; } return NULL; case 2: { /* No need to parse that text if it's out of segment */ gint64 clip_start = 0, clip_stop = 0; gboolean in_seg = FALSE; /* Check our segment start/stop */ in_seg = gst_segment_clip (state->segment, GST_FORMAT_TIME, state->start_time, state->start_time + state->duration, &clip_start, &clip_stop); if (in_seg) { state->start_time = clip_start; state->duration = clip_stop - clip_start; } else { state->state = 0; return NULL; } } /* looking for subtitle text; empty line ends this subtitle entry */ if (state->buf->len) g_string_append_c (state->buf, '\n'); g_string_append (state->buf, line); if (strlen (line) == 0) { ret = g_markup_escape_text (state->buf->str, state->buf->len); g_string_truncate (state->buf, 0); state->state = 0; subrip_unescape_formatting (ret); subrip_remove_unhandled_tags (ret); strip_trailing_newlines (ret); subrip_fix_up_markup (&ret); return ret; } return NULL; default: g_return_val_if_reached (NULL); } }