Author Topic: QE Version l Update  (Read 1171 times)

sinsi

  • Member
  • *****
  • Posts: 1187
Re: QE Version l Update
« Reply #15 on: July 27, 2019, 03:12:03 PM »
Almost, now it only picks up the preceding crlf.
I can walk on water but stagger on beer bourbon.

jj2007

  • Member
  • *****
  • Posts: 9794
  • Assembler is fun ;-)
    • MasmBasic
Re: QE Version l Update
« Reply #16 on: July 27, 2019, 06:32:31 PM »
Actually, it's worse now. With the tproc.txt attached earlier, it selects now CrLf plus two chars in the line above. But it works correctly with intro.txt (both on Win10). And sometimes everything works, sometimes not. Weird :sad:

AW

  • Member
  • *****
  • Posts: 2435
  • Let's Make ASM Great Again!
Re: QE Version l Update
« Reply #17 on: July 27, 2019, 08:58:57 PM »
I think that you should be able to set that by sending an EM_SETOPTIONS message with ECO_AUTOWORDSELECTION, as mentioned above. If you are already doing that, I apologize.  :eusa_hand:
This should work from Windows 95 onwards, although online help says it requires Windows Vista and above  :skrewy:.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 6756
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: QE Version l Update
« Reply #18 on: July 28, 2019, 12:53:03 AM »
Thanks for that, I will give it a blast.

Just added the code,

      ; **********************************************************************
        invoke SendMessage,hEdit,EM_SETOPTIONS,ECOOP_OR,ECO_AUTOWORDSELECTION
      ; **********************************************************************

On the files that showed the incorrect select with a word at the left margin, it seems to work correctly. I removed the 100 ms lag as it did not do the job consistently.

I tried the ECOOP_XOR option but it made it worse.
« Last Edit: July 30, 2019, 03:58:08 AM by hutch-- »
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 6756
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: QE Version l Update
« Reply #19 on: July 28, 2019, 02:07:51 AM »
Mutter, this is a flop as well. Weird effect, I can copy the contents of a file that shows the defect to another editor instance and it does not do it.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

AW

  • Member
  • *****
  • Posts: 2435
  • Let's Make ASM Great Again!
Re: QE Version l Update
« Reply #20 on: July 28, 2019, 02:27:15 AM »
Mutter, this is a flop as well. Weird effect, I can copy the contents of a file that shows the defect to another editor instance and it does not do it.

I made a quick test in C and it appears that you don't need to do anything at all because the default behavior is exactly to select a word when you double-click inside it. I forced plain text by sending EM_SETTEXTMODE with TM_PLAINTEXT to make sure there are no different behaviors between rich text and plain text.
Incidentally a very old QEDIT from 2000 I have here from an ancient distribution, which uses riched32.dll, works fine.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 6756
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: QE Version l Update
« Reply #21 on: July 28, 2019, 03:04:59 AM »
I am getting very unusual results, just opening file after file, some show the selection error, others do not. I have EM_SETTEXTMODE and TM_PLAINTEXT set. I need a different method than the default as I use a table that specifies what characters are allowed, mainly ".", "_" and "$" which I lose with the default. It has only happened in win 10 64 bit and selection is different and slower.

Shrug, I will see if I can find a work around, the internal code works directly off the 256 characters table and I know the problem is not there as the ASCII 13 that riched uses as a line feed is set to zero in the table.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

AW

  • Member
  • *****
  • Posts: 2435
  • Let's Make ASM Great Again!
Re: QE Version l Update
« Reply #22 on: July 28, 2019, 05:11:55 AM »
I understand what you are looking for. a problem similar to this:
https://stackoverflow.com/questions/51438312/rules-for-selecting-a-word-in-a-windows-richedit20w-control

Looking at Qedit with a Windows Message viewer it does not appear, or it escaped me, that you are using EM_SETWORDBREAKPROC (and then EditWordBreakProc) as mentioned in the notes by  Alessandro Jacopson, may be you want to try that route.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 6756
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: QE Version l Update
« Reply #23 on: July 28, 2019, 07:49:42 AM »
After exhausting anything like reference material, this is the most successful so far.

  ; ........
    sub ecx, 1
    sub mn, ecx
    mov eax, mn
    mov cr.cpMin, eax
    mov cr.cpMax, eax
    add cr.cpMax, edx

  ; |||||||||||||||||||||||||||||||||||||||||||
  ; zero the selection to the end cpMax value
  ; |||||||||||||||||||||||||||||||||||||||||||

    add eax, edx
    mov cn.cpMin, eax
    mov cn.cpMax, eax

    invoke SendMessage,edit,EM_EXSETSEL,0,ADDR cn

  ; |||||||||||||||||||||||||||||||||||||||||||


    invoke SendMessage,edit,EM_HIDESELECTION,0,0
    invoke SendMessage,edit,EM_EXSETSEL,0,ADDR cr               ; set to correct selection

  ; ........
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 6756
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: QE Version l Update
« Reply #24 on: July 28, 2019, 03:42:41 PM »
I think I have this problem knackered, I just need a few days of using it to test if it beats the Microsoft over-ride.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

TimoVJL

  • Member
  • ***
  • Posts: 476
Re: QE Version l Update
« Reply #25 on: July 28, 2019, 07:54:10 PM »
I understand what you are looking for. a problem similar to this:
https://stackoverflow.com/questions/51438312/rules-for-selecting-a-word-in-a-windows-richedit20w-control

Looking at Qedit with a Windows Message viewer it does not appear, or it escaped me, that you are using EM_SETWORDBREAKPROC (and then EditWordBreakProc) as mentioned in the notes by  Alessandro Jacopson, may be you want to try that route.
Thanks for that link.
a simplified C version for testing:
Code: [Select]
int CharClasses[256] = {
 0, 0, 0, 0, 0, 0, 0, 0, 0,19,20,20,20,20, 0, 0,        //   0- 15
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,        //  16- 31
50, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,65, 1, 1,        //  32- 47
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1,        //  48- 63
 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,        //  64- 79
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0,        //  80- 95
 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,        //  96-111
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0,        // 112-127
 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0,        // 128-143
 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0,        // 144-159
18, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,        // 160-175
 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,        // 176-191
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,        // 192-207
 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,        // 208-223
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,        // 224-239
 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0         // 240-255
};

int MoveWordLeft(LPWSTR lpch, int ichCurrent, int cch)
{
while (ichCurrent > 0 && !CharClasses[*(lpch + ichCurrent - 1)])
ichCurrent--;
return ichCurrent;
}

int MoveWordRight(LPWSTR lpch, int ichCurrent, int cch)
{
while (ichCurrent < cch  && !CharClasses[*(lpch + ichCurrent)])
ichCurrent++;
return ichCurrent;
}

int EditWordBreakProc(LPWSTR lpch, int ichCurrent, int cch, int code)
{
switch ( code ) {
case WB_LEFT:
case WB_MOVEWORDLEFT:
case WB_LEFTBREAK:
return MoveWordLeft(lpch, ichCurrent, cch);
case WB_RIGHT:
case WB_MOVEWORDRIGHT:
case WB_RIGHTBREAK:
return MoveWordRight(lpch, ichCurrent, cch);
}
return 0;
}
floats still needs a special handling :undecided:
EDIT: a simple version:
Code: [Select]
int EditWordBreakProc(LPWSTR lpch, int ichCurrent, int cch, int code)
{
switch ( code ) {
case WB_LEFT:
case WB_MOVEWORDLEFT:
case WB_LEFTBREAK:
for (;ichCurrent > 0 && !CharClasses[*(lpch + ichCurrent - 1)]; ichCurrent--);
return ichCurrent;
case WB_RIGHT:
case WB_MOVEWORDRIGHT:
case WB_RIGHTBREAK:
for (;ichCurrent < cch  && !CharClasses[*(lpch + ichCurrent)]; ichCurrent++);
return ichCurrent;
}
return 0;
}

for asm
Code: [Select]
CharClasses dw  0, 0, 0, 0, 0, 0, 0, 0, 0,19,20,20,20,20, 0, 0  ;   0- 15
            dw  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0  ;  16- 31
            dw 50, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,65, 1, 1  ;  32- 47
            dw  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1  ;  48- 63
            dw  1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0  ;  64- 79
            dw  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0  ;  80- 95
            dw  1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0  ;  96-111
            dw  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0  ; 112-127
            dw  0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0  ; 128-143
            dw  0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0  ; 144-159
            dw 18, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1  ; 160-175
            dw  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1  ; 176-191
            dw  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0  ; 192-207
            dw  0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0  ; 208-223
            dw  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0  ; 224-239
            dw  0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0  ; 240-255
« Last Edit: July 29, 2019, 05:46:36 PM by TimoVJL »
May the source be with you