From 4becc885d157a50caeb71704f5950a464f547ae3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D9=85=D8=AD=D9=85=D8=AF=20=D8=A7=D9=84=D8=AF=D8=B3=D9=88?= =?UTF-8?q?=D9=82=D9=8A?= <39778149+mohamed-180@users.noreply.github.com> Date: Sat, 23 May 2020 18:56:15 +0200 Subject: [PATCH 1/2] Update config.py add auto close for brackets and parentheses --- examples/ptpython_config/config.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/examples/ptpython_config/config.py b/examples/ptpython_config/config.py index a834112c..04e375ea 100644 --- a/examples/ptpython_config/config.py +++ b/examples/ptpython_config/config.py @@ -144,6 +144,32 @@ def _(event): " Map 'jj' to Escape. " event.cli.key_processor.feed(KeyPress(Keys.Escape)) """ + + @repl.add_key_binding('(') + def _(event): + event.cli.current_buffer.insert_text("(") + event.cli.current_buffer.insert_text(")" , move_cursor=False) + + @repl.add_key_binding('[') + def _(event): + event.cli.current_buffer.insert_text("[") + event.cli.current_buffer.insert_text("]" , move_cursor=False) + + @repl.add_key_binding('{') + def _(event): + event.cli.current_buffer.insert_text("{") + event.cli.current_buffer.insert_text("}" , move_cursor=False) + + @repl.add_key_binding("'") + def _(event): + event.cli.current_buffer.insert_text("'") + event.cli.current_buffer.insert_text("'" , move_cursor=False) + + @repl.add_key_binding('"') + def _(event): + event.cli.current_buffer.insert_text('"') + event.cli.current_buffer.insert_text('"' , move_cursor=False) + # Custom key binding for some simple autocorrection while typing. """ From a0a44f6b1f254e7f690bf3d609b6ce57a9358948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D9=85=D8=AD=D9=85=D8=AF=20=D8=A7=D9=84=D8=AF=D8=B3=D9=88?= =?UTF-8?q?=D9=82=D9=8A?= <39778149+mohamed-180@users.noreply.github.com> Date: Sat, 23 May 2020 19:00:53 +0200 Subject: [PATCH 2/2] Update config.py add auto close brackets and parentheses --- examples/ptpython_config/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/ptpython_config/config.py b/examples/ptpython_config/config.py index 04e375ea..e5e1d16f 100644 --- a/examples/ptpython_config/config.py +++ b/examples/ptpython_config/config.py @@ -145,7 +145,7 @@ def _(event): event.cli.key_processor.feed(KeyPress(Keys.Escape)) """ - @repl.add_key_binding('(') + @repl.add_key_binding('(') def _(event): event.cli.current_buffer.insert_text("(") event.cli.current_buffer.insert_text(")" , move_cursor=False)