Gitweb links:

...log 
http://git.netsurf-browser.org/netsurf.git/shortlog/0b0c6a4f6ae8d04546028f42440054508c6121d0
...commit 
http://git.netsurf-browser.org/netsurf.git/commit/0b0c6a4f6ae8d04546028f42440054508c6121d0
...tree 
http://git.netsurf-browser.org/netsurf.git/tree/0b0c6a4f6ae8d04546028f42440054508c6121d0

The branch, master has been updated
       via  0b0c6a4f6ae8d04546028f42440054508c6121d0 (commit)
      from  c4a412604106e06ca4a0e59c6f7279d1e4b182a4 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff 
http://git.netsurf-browser.org/netsurf.git/commitdiff/0b0c6a4f6ae8d04546028f42440054508c6121d0
commit 0b0c6a4f6ae8d04546028f42440054508c6121d0
Author: Chris Young <[email protected]>
Commit: Chris Young <[email protected]>

    Support pasting the UTF8 chunk of clipboard IFF FTXT when present, instead 
of CHRS

diff --git a/amiga/clipboard.c b/amiga/clipboard.c
index 6c91f95..66a4da2 100755
--- a/amiga/clipboard.c
+++ b/amiga/clipboard.c
@@ -108,6 +108,22 @@ void gui_clear_selection(struct gui_window *g)
        OffMenu(g->shared->win, AMI_MENU_COPY);
 }
 
+bool ami_clipboard_check_for_utf8(struct IFFHandle *iffh) {
+       struct ContextNode *cn;
+       ULONG error;
+       bool utf8_chunk = false;
+       
+       if(OpenIFF(iffh, IFFF_READ)) return false;
+       if(!StopChunk(iffh, ID_FTXT, ID_UTF8)) {
+               error = ParseIFF(iffh, IFFPARSE_SCAN);
+               if(error != IFFERR_EOF)
+                       utf8_chunk = true; /* or a real error, but that'll get 
caught later */
+       }
+       CloseIFF(iffh);
+
+       return utf8_chunk;
+}
+
 void gui_paste_from_clipboard(struct gui_window *g, int x, int y)
 {
        /* This and the other clipboard code is heavily based on the RKRM 
examples */
@@ -116,14 +132,23 @@ void gui_paste_from_clipboard(struct gui_window *g, int 
x, int y)
        struct CSet cset;
        LONG codeset = 0;
        char *clip;
+       bool utf8_chunks = false;
        STRPTR readbuf = AllocVec(1024,MEMF_PRIVATE | MEMF_CLEAR);
 
        cset.CodeSet = 0;
 
+       if(ami_clipboard_check_for_utf8(iffh))
+               utf8_chunks = true;
+       
        if(OpenIFF(iffh,IFFF_READ)) return;
-       if(StopChunk(iffh,ID_FTXT,ID_CHRS)) return;
-       if(StopChunk(iffh,ID_FTXT,ID_CSET)) return;
-
+       
+       if(utf8_chunks == false) {
+               if(StopChunk(iffh,ID_FTXT,ID_CHRS)) return;
+               if(StopChunk(iffh,ID_FTXT,ID_CSET)) return;
+       } else {
+               if(StopChunk(iffh,ID_FTXT,ID_UTF8)) return;
+       }
+       
        while(1)
        {
                error = ParseIFF(iffh,IFFPARSE_SCAN);
@@ -132,14 +157,14 @@ void gui_paste_from_clipboard(struct gui_window *g, int 
x, int y)
 
                cn = CurrentChunk(iffh);
 
-               if((cn)&&(cn->cn_Type == ID_FTXT)&&(cn->cn_ID == ID_CSET))
+               if((cn)&&(cn->cn_Type == ID_FTXT)&&(cn->cn_ID == 
ID_CSET)&&(utf8_chunks == false))
                {
                        rlen = ReadChunkBytes(iffh,&cset,32);
                        if(cset.CodeSet == 1) codeset = 106;
                                else codeset = cset.CodeSet;
                }
 
-               if((cn)&&(cn->cn_Type == ID_FTXT)&&(cn->cn_ID == ID_CHRS))
+               if((cn)&&(cn->cn_Type == ID_FTXT)&&(cn->cn_ID == 
ID_CHRS)&&(utf8_chunks == false))
                {
                        while((rlen = ReadChunkBytes(iffh,readbuf,1024)) > 0)
                        {
@@ -159,6 +184,15 @@ void gui_paste_from_clipboard(struct gui_window *g, int x, 
int y)
                        }
                        if(rlen < 0) error = rlen;
                }
+
+               if((cn)&&(cn->cn_Type == ID_FTXT)&&(cn->cn_ID == 
ID_UTF8)&&(utf8_chunks == true))
+               {
+                       while((rlen = ReadChunkBytes(iffh, readbuf, 1024)) > 0)
+                       {
+                               browser_window_paste_text(g->shared->bw, 
readbuf, rlen, true);
+                       }
+                       if(rlen < 0) error = rlen;
+               }
        }
        CloseIFF(iffh);
 }


-----------------------------------------------------------------------

Summary of changes:
 amiga/clipboard.c |   44 +++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 39 insertions(+), 5 deletions(-)

diff --git a/amiga/clipboard.c b/amiga/clipboard.c
index 6c91f95..66a4da2 100755
--- a/amiga/clipboard.c
+++ b/amiga/clipboard.c
@@ -108,6 +108,22 @@ void gui_clear_selection(struct gui_window *g)
        OffMenu(g->shared->win, AMI_MENU_COPY);
 }
 
+bool ami_clipboard_check_for_utf8(struct IFFHandle *iffh) {
+       struct ContextNode *cn;
+       ULONG error;
+       bool utf8_chunk = false;
+       
+       if(OpenIFF(iffh, IFFF_READ)) return false;
+       if(!StopChunk(iffh, ID_FTXT, ID_UTF8)) {
+               error = ParseIFF(iffh, IFFPARSE_SCAN);
+               if(error != IFFERR_EOF)
+                       utf8_chunk = true; /* or a real error, but that'll get 
caught later */
+       }
+       CloseIFF(iffh);
+
+       return utf8_chunk;
+}
+
 void gui_paste_from_clipboard(struct gui_window *g, int x, int y)
 {
        /* This and the other clipboard code is heavily based on the RKRM 
examples */
@@ -116,14 +132,23 @@ void gui_paste_from_clipboard(struct gui_window *g, int 
x, int y)
        struct CSet cset;
        LONG codeset = 0;
        char *clip;
+       bool utf8_chunks = false;
        STRPTR readbuf = AllocVec(1024,MEMF_PRIVATE | MEMF_CLEAR);
 
        cset.CodeSet = 0;
 
+       if(ami_clipboard_check_for_utf8(iffh))
+               utf8_chunks = true;
+       
        if(OpenIFF(iffh,IFFF_READ)) return;
-       if(StopChunk(iffh,ID_FTXT,ID_CHRS)) return;
-       if(StopChunk(iffh,ID_FTXT,ID_CSET)) return;
-
+       
+       if(utf8_chunks == false) {
+               if(StopChunk(iffh,ID_FTXT,ID_CHRS)) return;
+               if(StopChunk(iffh,ID_FTXT,ID_CSET)) return;
+       } else {
+               if(StopChunk(iffh,ID_FTXT,ID_UTF8)) return;
+       }
+       
        while(1)
        {
                error = ParseIFF(iffh,IFFPARSE_SCAN);
@@ -132,14 +157,14 @@ void gui_paste_from_clipboard(struct gui_window *g, int 
x, int y)
 
                cn = CurrentChunk(iffh);
 
-               if((cn)&&(cn->cn_Type == ID_FTXT)&&(cn->cn_ID == ID_CSET))
+               if((cn)&&(cn->cn_Type == ID_FTXT)&&(cn->cn_ID == 
ID_CSET)&&(utf8_chunks == false))
                {
                        rlen = ReadChunkBytes(iffh,&cset,32);
                        if(cset.CodeSet == 1) codeset = 106;
                                else codeset = cset.CodeSet;
                }
 
-               if((cn)&&(cn->cn_Type == ID_FTXT)&&(cn->cn_ID == ID_CHRS))
+               if((cn)&&(cn->cn_Type == ID_FTXT)&&(cn->cn_ID == 
ID_CHRS)&&(utf8_chunks == false))
                {
                        while((rlen = ReadChunkBytes(iffh,readbuf,1024)) > 0)
                        {
@@ -159,6 +184,15 @@ void gui_paste_from_clipboard(struct gui_window *g, int x, 
int y)
                        }
                        if(rlen < 0) error = rlen;
                }
+
+               if((cn)&&(cn->cn_Type == ID_FTXT)&&(cn->cn_ID == 
ID_UTF8)&&(utf8_chunks == true))
+               {
+                       while((rlen = ReadChunkBytes(iffh, readbuf, 1024)) > 0)
+                       {
+                               browser_window_paste_text(g->shared->bw, 
readbuf, rlen, true);
+                       }
+                       if(rlen < 0) error = rlen;
+               }
        }
        CloseIFF(iffh);
 }


-- 
NetSurf Browser

_______________________________________________
netsurf-commits mailing list
[email protected]
http://vlists.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org

Reply via email to