texmacs-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Texmacs-dev] Cursor left/right movement with wrapping


From: Joris van der Hoeven
Subject: Re: [Texmacs-dev] Cursor left/right movement with wrapping
Date: Wed, 8 Dec 2004 19:17:39 +0100 (CET)

Hi Josef,

On Wed, 8 Dec 2004, Josef Weidendorfer wrote:
> I find it a little irritating that pressing key "right" at the and of a line
> doesn't go the the start of the next line. This is obviously because cursor
> movement is done only in geometrical means, i.e. cursor right always tries to
> go to the right. I think that at least if this is not possible, it should
> follow the text structure "to the right".
>
> Attached is a small patch to allow left/right cursor movement to wrap at line
> starts/ends in the middle of a paragraph. Currently I don't jump among
> different tree levels. Aren't there any general document tree navigation
> functions? I only found specialized version e.g. for searching.
>
> Similar, I think the following navigation should work:
> * Home/End to start/end of line instead of start/end of paragraph
> * C+Left/Right to previous/next word
> * C+Up/Down to previous/next paragraph
> Are patches welcome for this, or is this already possible with keyboard
> bindings?

I agree that something has to be done about this, but a correct solution
is not that easy. First of all, we indeed need to implement logical tree
navigation. This is not that hard, but still needs to be implemented
with care; indeed, one has to use the DRD to avoid accessability problems.

But the hard part is the fact that we should detect that we are at
the start or end of a physical phrase box. Otherwise, things will not
work correctly in multi-column mode. I plan to take care of this problem
since a long time, but I need to find a day to work things out properly.

In the meantime, any provisional code for tree navigation is welcome.
With a few hours of work, you should at least be able to hack something
which does the job in 99% of the cases in non-multi-column-mode.
The patch below is the right way to proceed, but you should replace
the "path p = path_add(ref_p,dx);" stuff by better tree-navigation.

Best wishes, Joris

> RCS file: /texmacs/src/src/Edit/Interface/edit_cursor.cpp,v
> retrieving revision 1.7
> diff -u -p -b -r1.7 edit_cursor.cpp
> --- edit_cursor.cpp     23 Sep 2004 11:17:23 -0000      1.7
> +++ edit_cursor.cpp     8 Dec 2004 17:50:59 -0000
> @@ -48,7 +48,20 @@ edit_cursor_rep::cursor_move_sub (SI& x0
>    if (ref_p == tree_path (x0, y0, d0+ dx*DELTA)) {
>      for (i=1; i<DELTA; i=i<<1)
>        if (ref_p != tree_path (x0+ dx*i, y0+ dy*i, d0+ dx*DELTA)) break;
> -    if (i>=DELTA) return false;
> +    if (i>=DELTA) {
> +      if (dx == 0) return false;
> +
> +      // Try line wrapping for horizontal move
> +      path p = path_add(ref_p,dx);
> +      if (p == ref_p) return false;
> +      cursor cu = eb->find_check_cursor(p);
> +      if (!cu->valid) return false;
> +      x0 = cu->ox;
> +      y0 = cu->oy;
> +      d0 = cu->delta;
> +      tp = p;
> +      return true;
> +    }
>      for (d=i>>2; d>=1; d=d>>1)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]