Nux

Merge lp:~unity-team/nux/nux.fix-746761 into lp:nux

Proposed by Mirco Müller
Status: Rejected
Rejected by: Neil J. Patel
Proposed branch: lp:~unity-team/nux/nux.fix-746761
Merge into: lp:nux
Diff against target: 187 lines (+122/-3)
3 files modified
Nux/TextEntry.cpp (+110/-1)
Nux/TextEntry.h (+10/-0)
examples/pangotextedit.cpp (+2/-2)
To merge this branch: bzr merge lp:~unity-team/nux/nux.fix-746761
Reviewer Review Type Date Requested Status
David Barth (community) Needs Information
Review via email: mp+58139@code.launchpad.net

Description of the change

Internal modification of class nux::TextEntry to allow most common dead-keys. Also check https://launchpadlibrarian.net/69808424/working-dead-keys.ogv Fixes LP: #746761

To post a comment you must log in.
lp:~unity-team/nux/nux.fix-746761 updated
333. By Mirco Müller

Always be a good boy and clean up afterwards

Revision history for this message
David Barth (dbarth) wrote :

I don't feel like the code can make the difference between a /dead/ key and a normal apostrophe for example. Could you confirm that it will not impact users which don't use dead keys at all, and force them into having to type apostrophe + space to actually get the apostrophe?

review: Needs Information
Revision history for this message
David Barth (dbarth) wrote :

Could you also check if either pango, cairo or an accepted nux dependency can provide you with a trasnlation table or a dtection mechanism for the question i was asking above?

Revision history for this message
Mirco Müller (macslow) wrote :

This patch does allow entering e.g. "á" and "'a", thus mimicking real input-methods. But it does that despite what ever is set system-wide.

It is a quick fix after all and not using input-methods. That would have taken longer to figure out and implement. This was an urgent fix. But by now this will probably not be accepted anymore as we want proper input-method support and we are in a new dev-cycle anyway and have more time.

Unmerged revisions

333. By Mirco Müller

Always be a good boy and clean up afterwards

332. By Mirco Müller

Rudimentary support for dead-keys. Not perfect, but works for most common cases. Fixes LP: #746761

331. By Mirco Müller

Text-Entry widget did not have default focus, thus typing wasn't possible... fixed now

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Nux/TextEntry.cpp'
2--- Nux/TextEntry.cpp 2011-04-07 15:54:21 +0000
3+++ Nux/TextEntry.cpp 2011-04-18 15:28:17 +0000
4@@ -165,6 +165,8 @@
5
6 update_canvas_ = true;
7
8+ _dead_key = NULL;
9+
10 OnMouseDown.connect (sigc::mem_fun (this, &TextEntry::RecvMouseDown) );
11 OnMouseDrag.connect (sigc::mem_fun (this, &TextEntry::RecvMouseDrag) );
12 OnMouseUp.connect (sigc::mem_fun (this, &TextEntry::RecvMouseUp) );
13@@ -187,6 +189,8 @@
14 cairo_font_options_destroy (font_options_);
15 if (_texture2D)
16 _texture2D->UnReference ();
17+
18+ ClearDeadKey ();
19 }
20
21 void TextEntry::PreLayoutManagement ()
22@@ -346,6 +350,98 @@
23 //return EVENT_RESULT_HANDLED;
24 }
25
26+ bool TextEntry::IsDeadKeyEmpty ()
27+ {
28+ return (_dead_key == NULL);
29+ }
30+
31+ bool TextEntry::IsDeadKey (const TCHAR* character)
32+ {
33+ return (!strcmp (character, "~") ||
34+ !strcmp (character, "^") ||
35+ !strcmp (character, "`") ||
36+ !strcmp (character, "'"));
37+ }
38+
39+ void TextEntry::StoreDeadKey (const char* character)
40+ {
41+ ClearDeadKey ();
42+ _dead_key = strdup (character);
43+ }
44+
45+ bool TextEntry::IsSpace (const TCHAR* character)
46+ {
47+ return !strcmp (character, " ");
48+ }
49+
50+ void TextEntry::ClearDeadKey ()
51+ {
52+ if (_dead_key)
53+ {
54+ free (_dead_key);
55+ _dead_key = NULL;
56+ }
57+ }
58+
59+ void TextEntry::EnterDeadKey ()
60+ {
61+ if (_dead_key)
62+ {
63+ EnterText (_dead_key);
64+ ClearDeadKey ();
65+ }
66+ }
67+
68+ void TextEntry::EnterComposedCharacter (const TCHAR* character)
69+ {
70+ if (!strcmp (_dead_key, "^") && !strcmp (character, "a")) EnterText ("â");
71+ if (!strcmp (_dead_key, "~") && !strcmp (character, "a")) EnterText ("ã");
72+ if (!strcmp (_dead_key, "'") && !strcmp (character, "a")) EnterText ("á");
73+ if (!strcmp (_dead_key, "`") && !strcmp (character, "a")) EnterText ("à");
74+ if (!strcmp (_dead_key, "^") && !strcmp (character, "A")) EnterText ("Â");
75+ if (!strcmp (_dead_key, "~") && !strcmp (character, "A")) EnterText ("Ã");
76+ if (!strcmp (_dead_key, "'") && !strcmp (character, "A")) EnterText ("Á");
77+ if (!strcmp (_dead_key, "`") && !strcmp (character, "A")) EnterText ("À");
78+
79+ if (!strcmp (_dead_key, "^") && !strcmp (character, "e")) EnterText ("ê");
80+ if (!strcmp (_dead_key, "~") && !strcmp (character, "e")) EnterText ("ẽ");
81+ if (!strcmp (_dead_key, "'") && !strcmp (character, "e")) EnterText ("é");
82+ if (!strcmp (_dead_key, "`") && !strcmp (character, "e")) EnterText ("è");
83+ if (!strcmp (_dead_key, "^") && !strcmp (character, "E")) EnterText ("Ê");
84+ if (!strcmp (_dead_key, "~") && !strcmp (character, "E")) EnterText ("Ẽ");
85+ if (!strcmp (_dead_key, "'") && !strcmp (character, "E")) EnterText ("É");
86+ if (!strcmp (_dead_key, "`") && !strcmp (character, "E")) EnterText ("È");
87+
88+ if (!strcmp (_dead_key, "^") && !strcmp (character, "i")) EnterText ("î");
89+ if (!strcmp (_dead_key, "~") && !strcmp (character, "i")) EnterText ("ĩ");
90+ if (!strcmp (_dead_key, "'") && !strcmp (character, "i")) EnterText ("í");
91+ if (!strcmp (_dead_key, "`") && !strcmp (character, "i")) EnterText ("ì");
92+ if (!strcmp (_dead_key, "^") && !strcmp (character, "I")) EnterText ("Î");
93+ if (!strcmp (_dead_key, "~") && !strcmp (character, "I")) EnterText ("Ĩ");
94+ if (!strcmp (_dead_key, "'") && !strcmp (character, "I")) EnterText ("Í");
95+ if (!strcmp (_dead_key, "`") && !strcmp (character, "I")) EnterText ("Ì");
96+
97+ if (!strcmp (_dead_key, "^") && !strcmp (character, "o")) EnterText ("ô");
98+ if (!strcmp (_dead_key, "~") && !strcmp (character, "o")) EnterText ("õ");
99+ if (!strcmp (_dead_key, "'") && !strcmp (character, "o")) EnterText ("ó");
100+ if (!strcmp (_dead_key, "`") && !strcmp (character, "o")) EnterText ("ò");
101+ if (!strcmp (_dead_key, "^") && !strcmp (character, "O")) EnterText ("Ô");
102+ if (!strcmp (_dead_key, "~") && !strcmp (character, "O")) EnterText ("Õ");
103+ if (!strcmp (_dead_key, "'") && !strcmp (character, "O")) EnterText ("Ó");
104+ if (!strcmp (_dead_key, "`") && !strcmp (character, "O")) EnterText ("Ò");
105+
106+ if (!strcmp (_dead_key, "^") && !strcmp (character, "u")) EnterText ("û");
107+ if (!strcmp (_dead_key, "~") && !strcmp (character, "u")) EnterText ("ũ");
108+ if (!strcmp (_dead_key, "'") && !strcmp (character, "u")) EnterText ("ú");
109+ if (!strcmp (_dead_key, "`") && !strcmp (character, "u")) EnterText ("ù");
110+ if (!strcmp (_dead_key, "^") && !strcmp (character, "U")) EnterText ("Û");
111+ if (!strcmp (_dead_key, "~") && !strcmp (character, "U")) EnterText ("Ũ");
112+ if (!strcmp (_dead_key, "'") && !strcmp (character, "U")) EnterText ("Ú");
113+ if (!strcmp (_dead_key, "`") && !strcmp (character, "U")) EnterText ("Ù");
114+
115+ ClearDeadKey ();
116+ }
117+
118 void TextEntry::ProcessKeyEvent (
119 unsigned long event_type , /*event type*/
120 unsigned long keysym , /*event keysym*/
121@@ -499,7 +595,20 @@
122
123 if (character != 0 && (strlen (character) != 0))
124 {
125- EnterText(character);
126+ if (IsDeadKeyEmpty ())
127+ {
128+ if (IsDeadKey (character))
129+ StoreDeadKey (character);
130+ else
131+ EnterText (character);
132+ }
133+ else
134+ {
135+ if (IsSpace (character))
136+ EnterDeadKey ();
137+ else
138+ EnterComposedCharacter (character);
139+ }
140 }
141
142 QueueRefresh(false, true);
143
144=== modified file 'Nux/TextEntry.h'
145--- Nux/TextEntry.h 2011-03-24 18:42:55 +0000
146+++ Nux/TextEntry.h 2011-04-18 15:28:17 +0000
147@@ -317,6 +317,14 @@
148 void GetCursorLocationInLayout(int *strong_x, int *strong_y, int *strong_height,
149 int *weak_x, int *weak_y, int *weak_height);
150
151+ bool IsDeadKeyEmpty ();
152+ bool IsDeadKey (const TCHAR* character);
153+ void StoreDeadKey (const TCHAR* character);
154+ void ClearDeadKey ();
155+ bool IsSpace (const TCHAR* character);
156+ void EnterDeadKey ();
157+ void EnterComposedCharacter (const TCHAR* character);
158+
159 // /**
160 // * Updates the cursor location of input method context.
161 // */
162@@ -464,6 +472,8 @@
163
164 int full_height_;
165
166+ TCHAR* _dead_key;
167+
168 // /** The background texture of the edit control */
169 // Texture *background_;
170
171
172=== modified file 'examples/pangotextedit.cpp'
173--- examples/pangotextedit.cpp 2011-03-08 01:47:17 +0000
174+++ examples/pangotextedit.cpp 2011-04-18 15:28:17 +0000
175@@ -33,10 +33,10 @@
176 text_entry->SetMaximumWidth(300);
177 text_entry->SetMinimumHeight (20);
178
179-
180 MainVLayout->AddView(text_entry, 0, nux::eCenter, nux::eFull);
181 MainVLayout->SetContentDistribution(nux::eStackCenter);
182-
183+ MainVLayout->SetFocused (true);
184+
185 nux::GetWindowThread ()->SetLayout(MainVLayout);
186 nux::ColorLayer background(nux::Color(0xFF4D4D4D));
187 static_cast<nux::WindowThread*>(thread)->SetWindowBackgroundPaintLayer(&background);

Subscribers

People subscribed via source and target branches