diff --git a/src/statusbar.vala b/src/statusbar.vala index ced4015..cd08dd3 100644 --- a/src/statusbar.vala +++ b/src/statusbar.vala @@ -15,14 +15,50 @@ class Statusbar : Gtk.Box { var cursor_position_label = new Gtk.Label(null); text_editor_widget.bind_property("cursor-position", cursor_position_label, "label", BindingFlags.SYNC_CREATE); + text_editor_widget.bind_property("cursor-position", cursor_position_label, "tooltip-text", BindingFlags.SYNC_CREATE, (binding, from_value, ref to_value) => { + var from_values = ((string)from_value).split(":"); + int row = int.parse(from_values[0]); + int column = int.parse(from_values[1]); + to_value = "Line %d, Column %d".printf(row, column); + return true; + }); pack_start(pack(cursor_position_label), false); var selection_count_label = new Gtk.Label(null); - text_editor_widget.bind_property("selection-count", selection_count_label, "label", BindingFlags.SYNC_CREATE); + text_editor_widget.bind_property("selection-count", selection_count_label, "visible", BindingFlags.SYNC_CREATE, (binding, from_value, ref to_value) => { + to_value = ((string)from_value).length > 0; + return true; + }); + text_editor_widget.bind_property("selection-count", selection_count_label, "label", BindingFlags.SYNC_CREATE, (binding, from_value, ref to_value) => { + if (((string)from_value).length == 0) { + to_value = ""; + } else { + var from_values = ((string)from_value).split(":"); + int line_count = int.parse(from_values[0]); + int count = int.parse(from_values[1]); + to_value = "(%d, %d)".printf(line_count, count); + } + return true; + }); + text_editor_widget.bind_property("selection-count", selection_count_label, "tooltip-text", BindingFlags.SYNC_CREATE, (binding, from_value, ref to_value) => { + if (((string)from_value).length == 0) { + to_value = ""; + } else { + var from_values = ((string)from_value).split(":"); + int line_count = int.parse(from_values[0]); + int count = int.parse(from_values[1]); + to_value = "%s, %s selected".printf(pluralize(line_count, "line"), pluralize(count, "character")); + } + return true; + }); pack_start(pack(selection_count_label), false); var grammar_label = new Gtk.Label(null); text_editor_widget.bind_property("grammar", grammar_label, "label", BindingFlags.SYNC_CREATE); + text_editor_widget.bind_property("grammar", grammar_label, "tooltip-text", BindingFlags.SYNC_CREATE, (binding, from_value, ref to_value) => { + to_value = "File uses the %s grammar".printf((string)from_value); + return true; + }); pack_end(pack(grammar_label), false); var encoding_label = new Gtk.Label("UTF-8"); @@ -42,6 +78,14 @@ class Statusbar : Gtk.Box { frame.add(box); return frame; } + + private static string pluralize(int count, string singular) { + if (count == 1) { + return "%d %s".printf(count, singular); + } else { + return "%d %ss".printf(count, singular); + } + } } } diff --git a/src/text-editor-widget.cc b/src/text-editor-widget.cc index 4028f94..d3eff5d 100644 --- a/src/text-editor-widget.cc +++ b/src/text-editor-widget.cc @@ -823,7 +823,7 @@ gchar *atom_text_editor_widget_get_cursor_position(AtomTextEditorWidget *self) { Point position = priv->text_editor->getCursorBufferPosition(); double row = position.row + 1; double column = position.column + 1; - return g_strdup_printf("%.0f:%.0f", row, column); + return g_strdup_printf("%g:%g", row, column); } gchar *atom_text_editor_widget_get_selection_count(AtomTextEditorWidget *self) { @@ -835,7 +835,7 @@ gchar *atom_text_editor_widget_get_selection_count(AtomTextEditorWidget *self) { lineCount -= 1; } if (count > 0) { - return g_strdup_printf("(%.0f, %.0f)", lineCount, count); + return g_strdup_printf("%g:%g", lineCount, count); } else { return g_strdup(""); } diff --git a/subprojects/atom-native b/subprojects/atom-native index 81cc991..4cbf99a 160000 --- a/subprojects/atom-native +++ b/subprojects/atom-native @@ -1 +1 @@ -Subproject commit 81cc991a9db1b4a961b04daa3cbd1ef6ce1b8185 +Subproject commit 4cbf99a0d0bae75b45e61d52a82d8452958d0cfc