CHDK - virtual keyboard - testers needed! - page 7 - General Discussion and Assistance - CHDK Forum supplierdeeply

CHDK - virtual keyboard - testers needed!

  • 150 Replies
  • 31436 Views
Re: CHDK - typing / virtual keyboard / editor-style typing
« Reply #60 on: 06 / January / 2012, 10:36:31 »
Advertisements
Now looks much better.

KEY_SHOOT_HALF and KEY_SET also require    gui_tbox_redraw=1;

More bugs are visible:
- Can't reach/changes first symbol.
- Able to navigate with cursor out of last sym.
- Cursor after last sym never clear
- Locked cursor navigation before first sym entered. Possible have reason for new string, but not if default string exist.

Look like soon improvements (insertion, large sized strings, etc) could be started.

Re: CHDK - typing / virtual keyboard / editor-style typing
« Reply #61 on: 06 / January / 2012, 11:21:07 »
Quote
Can't reach/changes first symbol.

This is more complex bug I see... If you navigate inside the string and type any letter, new letter replaces letter on cursor's right side instead of left side.

BTW - as far as I remember you said you changed 'replace' by 'insert' mode? Did you mean that if cursor is inside the string and new character is written, then it should insert a character into the string? Now it works like werid replace :D

I'm getting lost in growing code. It becomes too much 'patched' than well-designed and clear. I see, that we have very simmilar problems that I had EDI 1 almost done. Then I realized, that knowing problems and the way to solve them I have to rewrite code. And then EDI code became more understandable. I'm worried we will have to rewrite the code at the end. But let first make it working.

Problem with cursor position and good place for new char was one of my problems with EDI. I have no time now to look at the EDI code to find a solution, but there was a little different style of inserting new characters.

EDIT

Just an idea - I probably know, what's the problem. Having a little time I just writ here instad of changing source.

When we write new character it have to be added beyond current lenght of the text. That's why cursor++ is before text[cursor]=...

We should have conditional check, wheter cursor is at the end - then it should work at now. When it's inside text there should be no cursor++. I hope I'll change the source this way after around 2 h. If you'll have time to do so before, you could do. I got to go now :)
« Last Edit: 06 / January / 2012, 11:31:34 by outslider »
if (2*b || !2*b) {
    cout<<question
}

Compile error: poor Yorick

Re: CHDK - typing / virtual keyboard / editor-style typing
« Reply #62 on: 06 / January / 2012, 11:38:28 »
I found another bad error in "tbox_move_cursor".
The line "if (cursor < (maxlen-1) && cursor+1 != '\0') {" should be "if (cursor < (maxlen-1) && text[cursor+1] != '\0') {".
Then the cursor only moves if there is a character otherwise every character after this cursor move this will not be shown.
Also I have made the cursor a little bit smaller so that it doesn't reach the top of the textfield and copied the "insert space" code from K-Mode to T-Mode.

Re: CHDK - typing / virtual keyboard / editor-style typing
« Reply #63 on: 06 / January / 2012, 12:18:58 »
BTW - as far as I remember you said you changed 'replace' by 'insert' mode? Did you mean that if cursor is inside the string and new character is written, then it should insert a character into the string? Now it works like werid replace :D
I wrote this in "opened issues". ;) This means that this should be implemented. Because replacing mode is more limited then insertion

Quote
I'm getting lost in growing code. It becomes too much 'patched' than well-designed and clear. I see, that we have very simmilar problems that I had EDI 1 almost done. Then I realized, that knowing problems and the way to solve them I have to rewrite code. And then EDI code became more understandable. I'm worried we will have to rewrite the code at the end. But let first make it working.
Rewriting and refactoring is completely up to you. If API is untouched then this will be completely internal rework. It really "patched" now, because we really fix and improve existed base code. ;) Personally I have not enough time to investigate/rewrite this module. I just make some hotfixes to test my own infrastructure which provide this module to whole system and make it flexible.

But in other hand also we have a lot of specific cases in behaviour and some limitations due flexibility+avoid malloc. So I think this code never will be simple. ;)


Re: CHDK - typing / virtual keyboard / editor-style typing
« Reply #64 on: 06 / January / 2012, 14:50:06 »
Ok, I have implementation of insert while typing inside the string. It makes werid things, when string becomes longer than text field width, but I hope when we'll provide text scrolling we will fix that.

Note, that space is now not added inside of gui_tbox_kbd_process() but in tbox_keyboard_key. This require to call tbox_keyboard_key with 's' as curKey. I'm going to do simmilar thing with backspace.

PS.
Quote
I just make some hotfixes to test my own infrastructure which provide this module to whole system and make it flexible.

Without these 'hotfixes' we would need to work twice as now ;) So I very appreciate your work!
« Last Edit: 06 / January / 2012, 15:24:47 by outslider »
if (2*b || !2*b) {
    cout<<question
}

Compile error: poor Yorick

Re: CHDK - typing / virtual keyboard / editor-style typing
« Reply #65 on: 06 / January / 2012, 16:18:11 »
That's really good. I tried it also but with memcpy and it doesn't work.
If we remove "1+" from "draw_line(text_offset_x+(1+cursor)*FONT_WIDT..." and the other draw_line then the cursor is on the other side of the typed char.
Also we should replace
Code: [Select]
for (i=strlen(text); i>cursor; i--) {with
Code: [Select]
for (i=(strlen(text) < maxlen-1)?strlen(text):maxlen-1; i>cursor; i--) {then the ends of too long texts where removed.

Re: CHDK - typing / virtual keyboard / editor-style typing
« Reply #66 on: 06 / January / 2012, 16:43:37 »
If we remove "1+" from "draw_line(text_offset_x+(1+cursor)*FONT_WIDT..." and the other draw_line then the cursor is on the other side of the typed char.
But why? I have added this +1 to move the cursor to the right side of typed char and this is good side. All editors have cursor on the right side of the character (excluding writing in oposite direction - e.g in arabic, yiddish)...

Code: [Select]
for (i=(strlen(text) < maxlen-1)?strlen(text):maxlen-1; i>cursor; i--) {
I added this:)

Below is new source with backspace implemented in tbox_keyboard_key(). It also works inside the text now :)[/code]
« Last Edit: 06 / January / 2012, 17:34:01 by outslider »
if (2*b || !2*b) {
    cout<<question
}

Compile error: poor Yorick

Re: CHDK - typing / virtual keyboard / editor-style typing
« Reply #67 on: 07 / January / 2012, 02:56:14 »
Really good work!
There should be an "if (cursor > 0)" otherwise the cursor can go to -1 and lower.

But why? I have added this +1 to move the cursor to the right side of typed char and this is good side.
I think also that's good, but I thought that anybody has said it is the wrong side.

Edit: not "if (cursor > 0)" but "if (cursor >= 0)"
« Last Edit: 07 / January / 2012, 05:25:34 by TobiMarg »


Re: CHDK - typing / virtual keyboard / editor-style typing
« Reply #68 on: 07 / January / 2012, 06:25:51 »
I have made "tbox_keyboard_key" so:
Code: [Select]
    switch (curKey) {
        case 'b':
            if (cursor >= 0) {
                int i;
                for (i=cursor; i<strlen(text); i++) {
                    text[i]=text[i+1];
                }
                cursor--;
                lastKey = '\0';
            }
            break;
        case 's':
            text[cursor] = ' ';
            lastKey = '\0';
            break;
        case lastKey:
            curchar++;
            if (tbox_chars[line][curchar] == SUBGROUP_SEPARATOR || tbox_chars[line][curchar]==0) {
                curchar=subgroup_offs[subgroup];
            }
            text[cursor] = tbox_chars[line][curchar];
            break;
        default:
            curchar = subgroup_offs[subgroup];
            if (cursor < (maxlen-1)) {
                if (text[cursor+1] != '\0') { //check wheter cursor is at the end of the string
                    int i;
                    //This loop moves all characters on the right of the cursor one place right
                    for (i=(strlen(text) < maxlen-1)?strlen(text):maxlen-1; i>cursor; i--) {
                        text[i]=text[i-1];
                    }
                }
                cursor++;
            }
            lastKey = curKey;
            text[cursor] = tbox_chars[line][curchar];
            break;
    }
    gui_tbox_redraw = 1;
It needs a little bit more code but no return.

Actually there is an error:
Code: [Select]
../gui_tbox.c: In function 'tbox_keyboard_key':
../gui_tbox.c:329: error: case label does not reduce to an integer constant
and I have no idea to fix that.
« Last Edit: 07 / January / 2012, 06:37:41 by TobiMarg »

Re: CHDK - typing / virtual keyboard / editor-style typing
« Reply #69 on: 07 / January / 2012, 06:56:50 »
Edit: not "if (cursor > 0)" but "if (cursor >= 0)"

Changed ;) I missed this condition. Also changed of FUNC key work (just change keyLast - used to type letter from the same key).

I have enlarged a set of special symbols. Minor problem is that we can't have '|' at the moment. Should be a kind of escape for this. But that's not important symbol in most cases.

I have done a little GUI improvements (SPACING_BELOW_TEXT).

We should focus on making scrollable text. But I have no idea where to start. There should be a variable sucha as textScrollOffset and it should be added to many places. But I don't really understand the whole of code... Tobi, could you try to implement this? Even in buggy form at start.

Also what about multiline text? Are we going to have this? I don't think it is required now, since virtual keybord is designed to changing names, adding captions (as EXIF tags - would be cool!) or entering small amount of text. Not writting SMSes;)

I see that whole applet becomes stable :)

EDIT

Quote
Actually there is an error:
Code: [Select]
../gui_tbox.c: In function 'tbox_keyboard_key':
../gui_tbox.c:329: error: case label does not reduce to an integer constant
and I have no idea to fix that.

The problem is that after case you need a constant, not a variable. And it seems like it's not possible here. I don't know why C requires that, but after reading on Internet it looks so...

Also - I have tried to change this to if/else if/else but there are problems with spacebar now. So I didn't apply this in to below code...
« Last Edit: 07 / January / 2012, 07:55:35 by outslider »
if (2*b || !2*b) {
    cout<<question
}

Compile error: poor Yorick

 

Related Topics