<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    It looks like the text actually has the bytes "Enter" at the
    newlines, rather than, say, a '\n'?<br>
    <br>
    <div class="moz-cite-prefix">On 04/18/2014 03:52 AM, Manuel Bachmann
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAJBSuGZgdaQpyxZeVoLx_RQaCvrAmXzBqP4nEJ3vQQhvCQQ68w@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>This fixes :<br>
          <a moz-do-not-send="true"
            href="https://bugs.freedesktop.org/show_bug.cgi?id=77496">https://bugs.freedesktop.org/show_bug.cgi?id=77496</a><br>
          <br>
        </div>
        Regards,<br>
        Manuel<br>
      </div>
      <div class="gmail_extra"><br>
        <br>
        <div class="gmail_quote">2014-04-18 12:50 GMT+02:00 Manuel
          Bachmann <span dir="ltr"><<a moz-do-not-send="true"
              href="mailto:manuel.bachmann@open.eurogiciel.org"
              target="_blank">manuel.bachmann@open.eurogiciel.org</a>></span>:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            The editor will now insert new lines and tabulations when<br>
            pressing the corresponding keys on the virtual keyboard.<br>
            <br>
            The Up and Down arrows can be used to navigate through<br>
            lines.<br>
            <br>
            Signed-off-by: Manuel Bachmann <<a moz-do-not-send="true"
              href="mailto:manuel.bachmann@open.eurogiciel.org">manuel.bachmann@open.eurogiciel.org</a>><br>
            ---<br>
             clients/editor.c |   97
            ++++++++++++++++++++++++++++++++++++++++++++++++------<br>
             1 file changed, 87 insertions(+), 10 deletions(-)<br>
            <br>
            diff --git a/clients/editor.c b/clients/editor.c<br>
            index 76e2346..4c5c427 100644<br>
            --- a/clients/editor.c<br>
            +++ b/clients/editor.c<br>
            @@ -110,6 +110,47 @@ utf8_next_char(const char *p)<br>
                    return NULL;<br>
             }<br>
            <br>
            +static void<br>
            +move_up(const char *p, uint32_t *cursor)<br>
            +{<br>
            +       const char *posr, *posr_i;<br>
            +       char text[16];<br>
            +<br>
            +       xkb_keysym_to_utf8(XKB_KEY_Return, text,
            sizeof(text));<br>
            +<br>
            +       posr = strstr(p, text);<br>
            +       while (posr) {<br>
            +               if (*cursor > (unsigned)(posr-p)) {<br>
            +                       posr_i = strstr(posr+1, text);<br>
            +                       if (!posr_i || !(*cursor >
            (unsigned)(posr_i-p))) {<br>
            +                               *cursor = posr-p;<br>
            +                               break;<br>
            +                       }<br>
            +                       posr = posr_i;<br>
            +               } else {<br>
            +                       break;<br>
            +               }<br>
            +       }<br>
            +}<br>
            +<br>
            +static void<br>
            +move_down(const char *p, uint32_t *cursor)<br>
            +{<br>
            +       const char *posr;<br>
            +       char text[16];<br>
            +<br>
            +       xkb_keysym_to_utf8(XKB_KEY_Return, text,
            sizeof(text));<br>
            +<br>
            +       posr = strstr(p, text);<br>
            +       while (posr) {<br>
            +               if (*cursor <= (unsigned)(posr-p)) {<br>
            +                       *cursor = posr-p + 1;<br>
            +                       break;<br>
            +               }<br>
            +               posr = strstr(posr+1, text);<br>
            +       }<br>
            +}<br>
            +<br>
             static void text_entry_redraw_handler(struct widget
            *widget, void *data);<br>
             static void text_entry_button_handler(struct widget
            *widget,<br>
                                                  struct input *input,
            uint32_t time,<br>
            @@ -374,6 +415,23 @@ text_input_keysym(void *data,<br>
                            return;<br>
                    }<br>
            <br>
            +       if (key == XKB_KEY_Up ||<br>
            +           key == XKB_KEY_Down) {<br>
            +               if (state != WL_KEYBOARD_KEY_STATE_RELEASED)<br>
            +                       return;<br>
            +<br>
            +               if (key == XKB_KEY_Up)<br>
            +                       move_up(entry->text,
            &entry->cursor);<br>
            +               else<br>
            +                       move_down(entry->text,
            &entry->cursor);<br>
            +<br>
            +               if (!(modifiers &
            entry->keysym.shift_mask))<br>
            +                       entry->anchor = entry->cursor;<br>
            +               widget_schedule_redraw(entry->widget);<br>
            +<br>
            +               return;<br>
            +       }<br>
            +<br>
                    if (key == XKB_KEY_BackSpace) {<br>
                            const char *start, *end;<br>
            <br>
            @@ -395,17 +453,20 @@ text_input_keysym(void *data,<br>
                            return;<br>
                    }<br>
            <br>
            -       switch (key) {<br>
            -               case XKB_KEY_Tab:<br>
            -                       key_label = "Tab";<br>
            -                       break;<br>
            -               case XKB_KEY_KP_Enter:<br>
            -               case XKB_KEY_Return:<br>
            -                       key_label = "Enter";<br>
            -                       break;<br>
            -       }<br>
            +       if (key == XKB_KEY_Tab ||<br>
            +           key == XKB_KEY_KP_Enter ||<br>
            +           key == XKB_KEY_Return) {<br>
            +               char text[16];<br>
            +<br>
            +               if (state != WL_KEYBOARD_KEY_STATE_RELEASED)<br>
            +                       return;<br>
            +<br>
            +               xkb_keysym_to_utf8(key, text, sizeof(text));<br>
            <br>
            -       fprintf(stderr, "%s key was %s.\n", key_label,
            state_label);<br>
            +               text_entry_insert_at_cursor(entry, text, 0,
            0);<br>
            +<br>
            +               return;<br>
            +       }<br>
             }<br>
            <br>
             static void<br>
            @@ -1208,6 +1269,22 @@ key_handler(struct window *window,<br>
                                           
            widget_schedule_redraw(entry->widget);<br>
                                    }<br>
                                    break;<br>
            +               case XKB_KEY_Up:<br>
            +                       text_entry_commit_and_reset(entry);<br>
            +<br>
            +                       move_up(entry->text,
            &entry->cursor);<br>
            +                       if (!(input_get_modifiers(input)
            & MOD_SHIFT_MASK))<br>
            +                               entry->anchor =
            entry->cursor;<br>
            +                      
            widget_schedule_redraw(entry->widget);<br>
            +                       break;<br>
            +               case XKB_KEY_Down:<br>
            +                       text_entry_commit_and_reset(entry);<br>
            +<br>
            +                       move_down(entry->text,
            &entry->cursor);<br>
            +                       if (!(input_get_modifiers(input)
            & MOD_SHIFT_MASK))<br>
            +                               entry->anchor =
            entry->cursor;<br>
            +                      
            widget_schedule_redraw(entry->widget);<br>
            +                       break;<br>
                            case XKB_KEY_Escape:<br>
                                    break;<br>
                            default:<br>
            <span class="HOEnZb"><font color="#888888">--<br>
                1.7.10.4<br>
                <br>
              </font></span></blockquote>
        </div>
        <br>
        <br clear="all">
        <br>
        -- <br>
        <div dir="ltr"><font>Regards,<br>
            <br>
            <i><b>Manuel BACHMANN</b><br>
              Tizen Project<br>
              VANNES-FR</i><br>
          </font></div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
wayland-devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:wayland-devel@lists.freedesktop.org">wayland-devel@lists.freedesktop.org</a>
<a class="moz-txt-link-freetext" href="http://lists.freedesktop.org/mailman/listinfo/wayland-devel">http://lists.freedesktop.org/mailman/listinfo/wayland-devel</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>