#define TEXT_SHOW_ADJ(text,adj,msg)
#endif
+#define AHX_DEBUG
+#if defined(AHX_DEBUG)
+# define XDEBUG(args) g_message args
+#else
+# define XDEBUG(args)
+#endif /* AHX_DEBUG */
+
/* Memory Management. */
static GMemChunk *params_mem_chunk = NULL;
static GMemChunk *text_property_chunk = NULL;
draw_cursor (text, FALSE);
}
+void
+gtk_stext_compact_buffer (GtkSText *text)
+{
+ GtkEditable *editable = GTK_EDITABLE (text);
+
+ g_return_if_fail (text != NULL);
+ g_return_if_fail (GTK_IS_STEXT (text));
+ move_gap (text, gtk_stext_get_length(text));
+}
+
void
gtk_stext_insert (GtkSText *text,
GdkFont *font,
switch (event->keyval)
{
case GDK_Home:
- if (event->state & GDK_CONTROL_MASK)
- move_cursor_buffer_ver (text, -1);
+ if (event->state & GDK_CONTROL_MASK) {
+ if (text->wrap_rmargin == 0) {
+ /* SYLPHEED: old behaviour */
+ move_cursor_buffer_ver (text, -1);
+ }
+ else {
+ /* SYLPHEED: contrived, but "trusty" */
+ move_cursor_buffer_ver(text, -1);
+ move_cursor_to_display_row_start(text);
+ }
+ }
else {
if (text->wrap_rmargin > 0) {
/* SYLPHEED: line start */
}
break;
case GDK_End:
- if (event->state & GDK_CONTROL_MASK)
- move_cursor_buffer_ver (text, +1);
+ if (event->state & GDK_CONTROL_MASK) {
+ /* SYLPHEED: a little bit contrived... */
+ if (text->wrap_rmargin == 0) {
+ /* old behaviour */
+ move_cursor_buffer_ver (text, +1);
+ }
+ else {
+ move_cursor_buffer_ver(text, +1);
+ move_cursor_to_display_row_end(text);
+ }
+ }
else {
if (text->wrap_rmargin > 0) {
/* SYLPHEED: line end */
break;
case GDK_Down:
move_cursor_to_display_row_down(text);
-// move_cursor_ver (text, +1);
+/* move_cursor_ver (text, +1); */
break;
case GDK_Left:
if (event->state & GDK_CONTROL_MASK)
}
break;
case GDK_Delete:
- if (event->state & GDK_CONTROL_MASK)
- gtk_stext_delete_forward_word (text);
- else if (event->state & GDK_SHIFT_MASK)
- {
- extend_selection = FALSE;
- gtk_editable_cut_clipboard (editable);
- }
- else
- gtk_stext_delete_forward_character (text);
+ {
+ if (event->state & GDK_CONTROL_MASK) {
+ gtk_stext_delete_forward_word (text);
+ }
+ else if (event->state & GDK_SHIFT_MASK)
+ {
+ extend_selection = FALSE;
+ gtk_editable_cut_clipboard (editable);
+ }
+ else {
+ gtk_stext_delete_forward_character (text);
+ }
+ }
break;
case GDK_Tab:
position = text->point.index;
* move_cursor_to_display_row_down() (line down)
*/
+/*
+ * SYLPHEED_TODO: for some reason the line fetcher also returns markers
+ * of just one character! should investigate this... -- alfons
+ */
static void move_cursor_to_display_row_end(GtkSText *text)
{
}
}
+/* dumb */
+static gboolean range_intersect(guint x1, guint x2, guint y1, guint y2)
+{
+ guint tmp;
+ if (x1 > x2) { tmp = x1; x1 = x2; x2 = tmp; }
+ if (y1 > y2) { tmp = y1; y1 = y2; y1 = tmp; }
+ if (y1 < x1) { tmp = x1; x1 = y1; y1 = tmp; tmp = x2; x2 = y2; y2 = tmp; }
+ return y1 <= x2;
+}
+
typedef struct {
int start, end;
gboolean found;
LineParams *params,
bdrf *data)
{
- if (data->start == params->start.index
- && data->end == params->end.index) {
+ if (range_intersect(data->start, data->end, params->start.index, params->end.index)) {
+ XDEBUG( ("%s(%d) - FOUND search (%d, %d), current (%d, %d)", __FILE__, __LINE__,
+ data->start, data->end,
+ params->start.index, params->end.index) );
data->found = TRUE;
return TRUE;
}
else {
+ XDEBUG( ("%s(%d) - NEXT search (%d, %d), current (%d, %d)", __FILE__, __LINE__,
+ data->start, data->end,
+ params->start.index, params->end.index) );
data->lp = *params;
return FALSE;
}
bdrf data = { 0 };
int new_index;
int col;
- GtkSPropertyMark mark = find_this_line_start_mark(text, text->cursor_mark.index, &text->cursor_mark);
+ GtkSPropertyMark mark;
+
+ mark = find_this_line_start_mark(text, text->cursor_mark.index, &text->cursor_mark);
/* top of buffer */
if (mark.index == 0) {
- return;
+ XDEBUG ( ("%s(%d) top of buffer", __FILE__, __LINE__) );
}
- /* we need to previous DISPLAY row not the previous BUFFER line, so we go one line back,
- * and iterate over the lines until we have a LineParams that matches the original */
-
+ /* we need previous DISPLAY row not the previous BUFFER line, so we go to start
+ * of paragraph, and iterate over the lines until we have a LineParams that matches
+ * the original */
lp = CACHE_DATA(text->current_line);
col = (text->cursor_mark.index - lp.start.index);
data.start = lp.start.index;
data.end = lp.end.index;
/* get the previous line */
- if (mark.index - 1 > 0) {
+ if (mark.index != 0) {
decrement_mark(&mark);
- if (mark.index - 1 > 0) {
- mark = find_this_line_start_mark(text, mark.index -1, &mark);
+ if (mark.index != 0) {
+ GtkSPropertyMark smark = mark;
+ XDEBUG( ("%s(%d) finding line start mark", __FILE__, __LINE__) );
+ mark = find_this_line_start_mark(text, smark.index -1, &smark);
}
}
/* let's get the previous display line */
+ XDEBUG( ("%s(%d) iterating to get display lines", __FILE__, __LINE__) );
line_params_iterate(text, &mark, NULL, FALSE, &data,
(LineIteratorFunction)back_display_row_fetcher);
+ XDEBUG( ("%s(%d) done iterating. found = %d", __FILE__, __LINE__, data.found) );
if (data.found) {
if (col < text->persist_column) col = text->persist_column;
else text->persist_column = col;
new_index = data.lp.start.index + col;
+ XDEBUG( ("%s(%d) - new index = %d", __FILE__, __LINE__, new_index) );
if (new_index > data.lp.end.index) {
new_index = data.lp.end.index;
}
/* and move the cursor */
+ XDEBUG( ("%s(%d) - setting index", __FILE__, __LINE__) );
gtk_stext_set_position_X(GTK_EDITABLE(text), new_index);
}
}
LineParams lp;
} fdrf;
+#if defined(AHX_DEBUG)
+static void print_line(GtkSText *text, guint start, guint end)
+{
+ gchar *buf = alloca(2048), *walk = buf;
+
+ memset(buf, 0, 2048);
+ for (; start <= end; start++) {
+ *walk++ = GTK_STEXT_INDEX(text, start);
+ }
+ XDEBUG( ("%s", buf) );
+}
+#endif
+
static gint forward_display_row_fetcher(GtkSText *text,
LineParams *lp,
fdrf *data)
{
if (data->found) {
+ XDEBUG( ("%s(%d) - FW RETURNS. search (%d, %d), current (%d, %d)",
+ __FILE__, __LINE__, data->start, data->end, lp->start.index, lp->end.index) );
data->lp = *lp;
data->completed = TRUE;
+ print_line(text, lp->start.index, lp->end.index);
return TRUE;
}
- else if (data->start == lp->start.index && data->end == lp->end.index) {
+ else if (range_intersect(data->start, data->end, lp->start.index, lp->end.index)) {
+ XDEBUG( ("%s(%d) - FW FOUND IT. search (%d, %d), current (%d, %d)",
+ __FILE__, __LINE__, data->start, data->end, lp->start.index, lp->end.index) );
data->found = TRUE;
return FALSE;
}
LineParams lp;
int new_index;
int col;
- GtkSPropertyMark mark = find_this_line_start_mark(text, text->cursor_mark.index, &text->cursor_mark);
+ GtkSPropertyMark mark;
fdrf data = { FALSE, FALSE };
+ mark = find_this_line_start_mark(text, text->cursor_mark.index, &text->cursor_mark);
lp = CACHE_DATA(text->current_line);
col = (text->cursor_mark.index - lp.start.index);
data.start = lp.start.index;
data.end = lp.end.index;
- /* find the next DISPLAY line */
+ /* find the next DISPLAY line */
+ XDEBUG( ("%s(%d) - FW iterating", __FILE__, __LINE__) ) ;
line_params_iterate(text, &mark, NULL, FALSE, &data,
(LineIteratorFunction)forward_display_row_fetcher);
+ XDEBUG( ("%s(%d) - FW done iterating", __FILE__, __LINE__) );
if (data.completed) {
if (col < text->persist_column) col = text->persist_column;
new_index = data.lp.end.index;
}
/* and move the cursor */
+ XDEBUG( ("%s(%d) - FW set pos %d", __FILE__, __LINE__, new_index) );
gtk_stext_set_position_X(GTK_EDITABLE(text), new_index);
}
}
gtk_stext_kill_word (GtkEditable *editable,
gint direction)
{
- if (editable->selection_start_pos != editable->selection_end_pos)
+ if (editable->selection_start_pos != editable->selection_end_pos) {
gtk_editable_delete_selection (editable);
+ }
else
{
gint old_pos = editable->current_pos;
draw_bg_rect (text, &text->cursor_mark,
text->cursor_pos_x - 1,
text->cursor_pos_y - text->cursor_char_offset - font->ascent,
- 2, font->ascent + 1, FALSE);
+ 2, font->descent + font->ascent + 1, FALSE);
}
gdk_gc_set_line_attributes(text->gc, 2, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_MITER);
gdk_gc_set_foreground(text->gc, >K_WIDGET (text)->style->text[GTK_STATE_NORMAL]);
gdk_draw_line(text->text_area, text->gc, text->cursor_pos_x,
- text->cursor_pos_y - text->cursor_char_offset,
+ text->cursor_pos_y + font->descent - text->cursor_char_offset,
text->cursor_pos_x,
- text->cursor_pos_y - text->cursor_char_offset - font->ascent);
+ text->cursor_pos_y - text->cursor_char_offset - font->ascent );
}
gdk_gc_copy(text->gc, gc);