def trySurroundSelection(editor, char, map_table):
	"""Try to do char-surrounding using a mapping table.

	Will not do any surrounding if a keyboard modifier key (e.g. Ctrl) is in pressed state.
	If the editor has multiple selections, each selection will be surrounded separately.

	:param editor: editor where to try to do surrounding
	:type editor: :any:`eye.widgets.editor.Editor`
	:param char: the character to do the surrounding
	:type char: str
	:param map_table: mapping table listing chars and their replacement
	:type map_table: dict[str, str]
	:returns: True if a char surrounding was performed, else False. The value can be used for
	          returning from an event filter function.
	:rtype: bool
	"""

	if char not in map_table:
		return False

	# when a surrounding is done, it will shift (invalidate) all line-indexes after it
	# doing in reverse order avoids having to compute shifting
	sels = reversed([editor.getSelectionN(n) for n in range(editor.selectionsCount())])
	with editor.undoGroup(True):
		for sel in sels:
			editor.setSelection(*sel)
			s = editor.selectedText()
			editor.replaceSelectedText(map_table[char] % s)

	return True