Commit 52eecb26 authored by Victor Ananjevsky's avatar Victor Ananjevsky

add --line option to text-info dialog

parent eb4110e9
......@@ -978,7 +978,10 @@ Default is \fIleft\fP.
Set text margins to \fINUMBER\fP.
.TP
.B \-\-tail
Autoscroll to end when new text appears. Works only when text is read from stdin.
Autoscroll to end when new text appears. This option works only when text is read from stdin.
.TP
.B \-\-line=\fINUMBER\fP
Jump to specific line at startup. This option works only when filename was specified
.TP
.B \-\-show-cursor
Show cursor in read-only mode.
......
......@@ -916,6 +916,8 @@ main (gint argc, gchar ** argv)
notebook_swallow_childs ();
else if (options.mode == YAD_MODE_PANED)
paned_swallow_childs ();
else if (options.mode == YAD_MODE_TEXTINFO)
text_goto_line ();
else if (options.mode == YAD_MODE_PICTURE)
{
if (options.picture_data.size == YAD_PICTURE_FIT)
......
......@@ -653,6 +653,8 @@ static GOptionEntry text_options[] = {
N_("Set justification (left, right, center or fill)"), N_("TYPE") },
{ "margins", 0, 0, G_OPTION_ARG_INT, &options.text_data.margins,
N_("Set text margins"), N_("SIZE") },
{ "line", 0, 0, G_OPTION_ARG_INT64, &options.text_data.line,
N_("Jump to specific line"), N_("NUMBER") },
{ "fore", 0, 0, G_OPTION_ARG_STRING, &options.text_data.fore,
N_("Use specified color for text"), N_("COLOR") },
{ "back", 0, 0, G_OPTION_ARG_STRING, &options.text_data.back,
......@@ -1869,6 +1871,7 @@ yad_options_init (void)
options.text_data.wrap = FALSE;
options.text_data.justify = GTK_JUSTIFY_LEFT;
options.text_data.margins = 0;
options.text_data.line = 0;
options.text_data.hide_cursor = TRUE;
options.text_data.fore = NULL;
options.text_data.back = NULL;
......
......@@ -609,13 +609,6 @@ fill_buffer_from_file ()
}
gtk_source_buffer_set_language (GTK_SOURCE_BUFFER (text_buffer), lang);
#endif
if (options.common_data.editable)
{
/* move cursor at the beginnging of a buffer */
gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (text_buffer), &iter, 0);
gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER (text_buffer), &iter);
}
}
static void
......@@ -635,6 +628,22 @@ text_changed_cb (GtkTextBuffer *b, gpointer d)
text_changed = TRUE;
}
void
text_goto_line ()
{
if (options.common_data.uri)
{
GtkTextIter iter;
while (gtk_events_pending ())
gtk_main_iteration ();
gtk_text_buffer_get_iter_at_line (GTK_TEXT_BUFFER (text_buffer), &iter, options.text_data.line);
gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER (text_buffer), &iter);
gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW (text_view), &iter, 0, TRUE, 0, 0.5);
}
}
GtkWidget *
text_create_widget (GtkWidget * dlg)
{
......
......@@ -473,6 +473,7 @@ typedef struct {
gboolean wrap;
GtkJustification justify;
gint margins;
gulong line;
gboolean uri;
gboolean hide_cursor;
gchar *uri_color;
......@@ -672,6 +673,7 @@ gboolean file_confirm_overwrite (GtkWidget *dlg);
void notebook_swallow_childs (void);
void paned_swallow_childs (void);
void picture_fit_to_window (void);
void text_goto_line (void);
void app_print_result (void);
void calendar_print_result (void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment