1 /******************************************************************************* 2 * Copyright (c) 2018 Red Hat and others. All rights reserved. 3 * The contents of this file are made available under the terms 4 * of the GNU Lesser General Public License (LGPL) Version 2.1 that 5 * accompanies this distribution (lgpl-v21.txt). The LGPL is also 6 * available at http://www.gnu.org/licenses/lgpl.html. If the version 7 * of the LGPL at http://www.gnu.org is different to the version of 8 * the LGPL accompanying this distribution and there is any conflict 9 * between the two license versions, the terms of the LGPL accompanying 10 * this distribution shall govern. 11 * 12 * Contributors: 13 * Red Hat - initial API and implementation 14 *******************************************************************************/ 15 package org.eclipse.swt.tests.gtk.snippets; 16 17 import org.eclipse.swt.SWT; 18 import org.eclipse.swt.custom.StyledText; 19 import org.eclipse.swt.layout.FillLayout; 20 import org.eclipse.swt.widgets.Display; 21 import org.eclipse.swt.widgets.Shell; 22 23 /* 24 * Title: Bug 528691 - [GTK] StyledText ignores text after \u0000 character 25 * How to run: launch snippet and observe StyledText widget 26 * Bug description: Only "hello" is displayed 27 * Expected results: "helloworld" should be displayed 28 * GTK Version(s): GTK2, GTK3 29 */ 30 public class Bug528691_StyledTextNull { 31 main(String[] args)32 public static void main(String[] args) { 33 final Display display = new Display(); 34 35 final Shell shell = new Shell(display); 36 shell.setLayout(new FillLayout()); 37 38 final StyledText styledText = new StyledText(shell, SWT.BORDER); 39 styledText.setText("hello\u0000world"); 40 41 shell.setSize(500, 400); 42 shell.open(); 43 44 while (!shell.isDisposed()) { 45 if (!display.readAndDispatch()) { 46 display.sleep(); 47 } 48 } 49 50 display.dispose(); 51 } 52 } 53