[solved]BMax & Ubuntu 12.04 French GetChar problem

BlitzMax Forums/BlitzMax Programming/[solved]BMax & Ubuntu 12.04 French GetChar problem

Vignoli(Posted 2015) [#1]
Hello

I encounter a problem for an app i've made when i compile it under Ubuntu 12.04.5 LTS, with language set in French :
GetChar() returns me 0 when i type an accentued char. (ex: é è à, etc.)

Is there a way to get the GetChar function to works under Ubuntu with not English keyboards ?


Vignoli(Posted 2015) [#2]
Can't i use a code like this :

?Linux
 // C or C++ international Getch function for linux
?


I suppose my app uses Gtk because it is a windowed screen of 800x600.

Source, executable and medias are here :
http://www.retro-bruno.com/freewares/blitz/Jadis_Ubuntu.zip


markcw(Posted 2015) [#3]
Try Gnome character map: apt-get install gucharmap


Vignoli(Posted 2015) [#4]
It is already installed. French accentued chars are working in Ubuntu, but not in BMax apps.


Derron(Posted 2015) [#5]
You will have to write your own "keymapping".

My gui-class contains this function:
	'returns true if the conversion was successful
	Function ConvertKeystrokesToText:Int(value:String Var, skipEnterKey:int = False)
		'remove with backspace
		If KEYWRAPPER.pressedKey(KEY_BACKSPACE)
			value = value[..value.length -1]
			return TRUE
		Endif
		'abort with ESCAPE
		If KEYWRAPPER.pressedKey(KEY_ESCAPE) then Return False

		'read special keys (shift + altgr) to enable special key handling
		Local shiftPressed:Int = KEYMANAGER.IsDown(160) Or KEYMANAGER.IsDown(161)
		?not Linux
		'windows and mac
		Local altGrPressed:int = KEYMANAGER.IsDown(164) Or KEYMANAGER.IsDown(165)
		?Linux
		'linux
		Local altGrPressed:int = KEYMANAGER.IsDown(3)
		?

		'charCode is "0" if no key is recognized
		local charCode:int = int(GetChar())

		'loop through all chars of the getchar-queue
		While charCode <>0
			'charCode is < 0 for me when umlauts are pressed
			if charCode < 0
				?Win32
				If KEYWRAPPER.pressedKey(186) Then If shiftPressed Then value:+ "Ü" Else value :+ "ü"
				If KEYWRAPPER.pressedKey(192) Then If shiftPressed Then value:+ "Ö" Else value :+ "ö"
				If KEYWRAPPER.pressedKey(222) Then If shiftPressed Then value:+ "Ä" Else value :+ "ä"
				?Mac
				If KEYWRAPPER.pressedKey(186) Then If shiftPressed Then value:+ "Ü" Else value :+ "ü"
				If KEYWRAPPER.pressedKey(192) Then If shiftPressed Then value:+ "Ö" Else value :+ "ö"
				If KEYWRAPPER.pressedKey(222) Then If shiftPressed Then value:+ "Ä" Else value :+ "ä"
				?Linux
				If KEYWRAPPER.pressedKey(252) Then If shiftPressed Then value:+ "Ü" Else value :+ "ü"
				If KEYWRAPPER.pressedKey(246) Then If shiftPressed Then value:+ "Ö" Else value :+ "ö"
				If KEYWRAPPER.pressedKey(163) Then If shiftPressed Then value:+ "Ä" Else value :+ "ä"
				?
			'handle normal "keys" (excluding umlauts)
			elseif charCode > 0
				local addChar:int = True
				'skip "backspace"
				if chr(KEY_BACKSPACE) = chr(charCode) then addChar = False
				'skip enter if whished so
				if skipEnterKey and chr(KEY_ENTER) = chr(charCode) then addChar = False

				if addChar then value :+ chr(charCode)
			endif
			charCode = int(GetChar())
		Wend

		'special chars - recognized on Mac, but not Linux
		'euro sign
		?Linux
		If KEYWRAPPER.pressedKey(69) And altGrPressed Then value :+ chr(8364)
		?
		Return True
	End Function


Of course "KeyWrapper" won't exist in your case - but "KeyHit" or "KeyDown" should do similar (albeit not "cached" then).


bye
Ron


Vignoli(Posted 2015) [#6]
... and i'll have to test for the Control/Shift/Maj keys to.
Thanks.