Ticket #3651: 3651-Enh1.patch

File 3651-Enh1.patch, 2.7 KB (added by dsizzle, 5 years ago)

Patch for Enhancement 1

  • src/apps/charactermap/CharacterView.cpp

    From 63e6d158d5b940e7727d656bf9e78d8e4dda25af Mon Sep 17 00:00:00 2001
    From: dsizzle <dcieslak@yahoo.com>
    Date: Sun, 23 Nov 2014 19:47:32 +0000
    Subject: [PATCH] 3651: Enhancement 1 - select the correct Unicode block for a
     selected character
    
    ---
     src/apps/charactermap/CharacterView.cpp    |  6 ++++++
     src/apps/charactermap/CharacterWindow.cpp  |  2 ++
     src/apps/charactermap/UnicodeBlockView.cpp | 19 +++++++++++++++++++
     src/apps/charactermap/UnicodeBlockView.h   |  1 +
     4 files changed, 28 insertions(+)
    
    diff --git a/src/apps/charactermap/CharacterView.cpp b/src/apps/charactermap/CharacterView.cpp
    index 9a25108..529e2a9 100644
    a b CharacterView::IsShowingBlock(int32 blockIndex) const  
    108108void
    109109CharacterView::ScrollToBlock(int32 blockIndex)
    110110{
     111    // don't scroll if the selected character is already in view.
     112    // this prevents distracting jumps when crossing a block
     113    // boundary in the character view.
     114    if (IsCharacterVisible(fCurrentCharacter))
     115        return;
     116       
    111117    if (blockIndex < 0)
    112118        blockIndex = 0;
    113119    else if (blockIndex >= (int32)kNumUnicodeBlocks)
  • src/apps/charactermap/CharacterWindow.cpp

    diff --git a/src/apps/charactermap/CharacterWindow.cpp b/src/apps/charactermap/CharacterWindow.cpp
    index 8b1ec80..cab1c9e 100644
    a b CharacterWindow::MessageReceived(BMessage* message)  
    337337
    338338            fGlyphView->SetText(glyph);
    339339            fCodeView->SetText(text);
     340           
     341            fUnicodeBlockView->SelectBlockForCharacter(character);
    340342            break;
    341343        }
    342344
  • src/apps/charactermap/UnicodeBlockView.cpp

    diff --git a/src/apps/charactermap/UnicodeBlockView.cpp b/src/apps/charactermap/UnicodeBlockView.cpp
    index fd192af..a643875 100644
    a b UnicodeBlockView::_CreateBlocks()  
    118118    _UpdateBlocks();
    119119}
    120120
     121
     122void
     123UnicodeBlockView::SelectBlockForCharacter(uint32 character)
     124{
     125    // find block containing the character
     126
     127    // TODO: could use binary search here
     128    for (uint32 i = 0; i < kNumUnicodeBlocks; i++) {
     129        if (kUnicodeBlocks[i].end < character)
     130            continue;
     131        if (kUnicodeBlocks[i].start > character) {
     132            // Character is not mapped
     133            break;
     134        }
     135
     136        Select(i);
     137        ScrollToSelection();
     138    }
     139}
  • src/apps/charactermap/UnicodeBlockView.h

    diff --git a/src/apps/charactermap/UnicodeBlockView.h b/src/apps/charactermap/UnicodeBlockView.h
    index 6bfedbc..03c3d32 100644
    a b public:  
    4040                                { return fShowContainedBlocksOnly; }
    4141
    4242            bool            IsShowingBlock(int32 blockIndex) const;
     43            void            SelectBlockForCharacter(uint32 character);
    4344
    4445private:
    4546            void            _UpdateBlocks();