Mercurial > projects > dwt2
comparison org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/widgets/Text.d @ 51:c01d033c633a
[swt lin]
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Fri, 27 Mar 2009 19:58:06 +0100 |
parents | ddbfe84d86df |
children | fb3aa8075988 |
comparison
equal
deleted
inserted
replaced
50:d5075f5226e5 | 51:c01d033c633a |
---|---|
965 GtkTextIter end; | 965 GtkTextIter end; |
966 OS.gtk_text_buffer_get_bounds (bufferHandle, &start, &end); | 966 OS.gtk_text_buffer_get_bounds (bufferHandle, &start, &end); |
967 address = OS.gtk_text_buffer_get_text (bufferHandle, &start, &end, true); | 967 address = OS.gtk_text_buffer_get_text (bufferHandle, &start, &end, true); |
968 } | 968 } |
969 if (address is null) return ""; | 969 if (address is null) return ""; |
970 String res = fromStringz( address ).dup; | 970 String res = fromStringz( address )._idup(); |
971 if ((style & SWT.MULTI) !is 0) OS.g_free (address); | 971 if ((style & SWT.MULTI) !is 0) OS.g_free (address); |
972 return res; | 972 return res; |
973 } | 973 } |
974 | 974 |
975 /** | 975 /** |
1005 OS.gtk_text_buffer_get_iter_at_offset (bufferHandle, &startIter, start); | 1005 OS.gtk_text_buffer_get_iter_at_offset (bufferHandle, &startIter, start); |
1006 OS.gtk_text_buffer_get_iter_at_offset (bufferHandle, &endIter, end + 1); | 1006 OS.gtk_text_buffer_get_iter_at_offset (bufferHandle, &endIter, end + 1); |
1007 address = OS.gtk_text_buffer_get_text (bufferHandle, &startIter, &endIter, true); | 1007 address = OS.gtk_text_buffer_get_text (bufferHandle, &startIter, &endIter, true); |
1008 } | 1008 } |
1009 if (address is null) error (SWT.ERROR_CANNOT_GET_TEXT); | 1009 if (address is null) error (SWT.ERROR_CANNOT_GET_TEXT); |
1010 String res = fromStringz( address ).dup; | 1010 String res = fromStringz( address )._idup(); |
1011 OS.g_free (address); | 1011 OS.g_free (address); |
1012 return res; | 1012 return res; |
1013 } | 1013 } |
1014 | 1014 |
1015 /** | 1015 /** |
1281 } | 1281 } |
1282 | 1282 |
1283 override int /*long*/ gtk_insert_text (GtkEditable* widget, char* new_text, int new_text_length, int position) { | 1283 override int /*long*/ gtk_insert_text (GtkEditable* widget, char* new_text, int new_text_length, int position) { |
1284 if (!hooks (SWT.Verify) && !filters (SWT.Verify)) return 0; | 1284 if (!hooks (SWT.Verify) && !filters (SWT.Verify)) return 0; |
1285 if (new_text is null || new_text_length is 0) return 0; | 1285 if (new_text is null || new_text_length is 0) return 0; |
1286 String oldText = (cast(char*)new_text)[ 0 .. new_text_length ].dup; | 1286 String oldText = (cast(char*)new_text)[ 0 .. new_text_length ]._idup(); |
1287 int pos; | 1287 int pos; |
1288 pos = *cast(int*)position; | 1288 pos = *cast(int*)position; |
1289 if (pos is -1) { | 1289 if (pos is -1) { |
1290 auto ptr = OS.gtk_entry_get_text (cast(GtkEntry*)handle); | 1290 auto ptr = OS.gtk_entry_get_text (cast(GtkEntry*)handle); |
1291 pos = cast(int)/*64*/OS.g_utf8_strlen (ptr, -1); | 1291 pos = cast(int)/*64*/OS.g_utf8_strlen (ptr, -1); |
1349 if (fixStart !is -1 && fixEnd !is -1) { | 1349 if (fixStart !is -1 && fixEnd !is -1) { |
1350 start = fixStart; | 1350 start = fixStart; |
1351 end = fixEnd; | 1351 end = fixEnd; |
1352 fixStart = fixEnd = -1; | 1352 fixStart = fixEnd = -1; |
1353 } | 1353 } |
1354 String oldText = text[ 0 .. len ]; | 1354 String oldText = cast(String)text[ 0 .. len ]; |
1355 String newText = verifyText (oldText, start, end); | 1355 String newText = verifyText (oldText, start, end); |
1356 if (newText is null) { | 1356 if (newText is null) { |
1357 OS.g_signal_stop_emission_by_name (bufferHandle, OS.insert_text.ptr); | 1357 OS.g_signal_stop_emission_by_name (bufferHandle, OS.insert_text.ptr); |
1358 } else { | 1358 } else { |
1359 if (newText !is oldText) { | 1359 if (newText !is oldText) { |
2003 auto imContext = imContext (); | 2003 auto imContext = imContext (); |
2004 if (imContext !is null) { | 2004 if (imContext !is null) { |
2005 char* preeditString; | 2005 char* preeditString; |
2006 OS.gtk_im_context_get_preedit_string (imContext, &preeditString, null, null); | 2006 OS.gtk_im_context_get_preedit_string (imContext, &preeditString, null, null); |
2007 if (preeditString !is null) { | 2007 if (preeditString !is null) { |
2008 int length = tango.stdc.string.strlen (preeditString); | 2008 int length = OS.strlen (preeditString); |
2009 OS.g_free (preeditString); | 2009 OS.g_free (preeditString); |
2010 if (length !is 0) return false; | 2010 if (length !is 0) return false; |
2011 } | 2011 } |
2012 } | 2012 } |
2013 default: | 2013 default: |