File tree Expand file tree Collapse file tree 1 file changed +43
-1
lines changed Expand file tree Collapse file tree 1 file changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -804,7 +804,49 @@ def menuconfig(kconf):
804
804
805
805
# Enter curses mode. _menuconfig() returns a string to print on exit, after
806
806
# curses has been de-initialized.
807
- print (curses .wrapper (_menuconfig ))
807
+ print (_wrapper (_menuconfig ))
808
+
809
+
810
+ def _wrapper (func ):
811
+ # Workaround for windows-curses bug on Python 3.12+
812
+ # See: https://github.com/zephyrproject-rtos/windows-curses/issues/50
813
+ if os .name == "nt" and sys .version_info >= (3 , 12 ):
814
+ stdscr = None
815
+ try :
816
+ import _curses
817
+ except ImportError :
818
+ # _curses not available, fall back to standard wrapper
819
+ return curses .wrapper (func )
820
+
821
+ try :
822
+ # setupterm() crashes on Python 3.12 with windows-curses
823
+ stdscr = _curses .initscr ()
824
+
825
+ # Copy ACS_* and LINES/COLS to curses module
826
+ for key , value in _curses .__dict__ .items ():
827
+ if key .startswith ("ACS_" ) or key in ("LINES" , "COLS" ):
828
+ setattr (curses , key , value )
829
+
830
+ curses .noecho ()
831
+ curses .cbreak ()
832
+
833
+ try :
834
+ curses .start_color ()
835
+ except curses .error :
836
+ # Color support not available
837
+ pass
838
+
839
+ if stdscr is not None :
840
+ stdscr .keypad (True )
841
+ return func (stdscr )
842
+ finally :
843
+ if stdscr is not None :
844
+ stdscr .keypad (False )
845
+ curses .echo ()
846
+ curses .nocbreak ()
847
+ curses .endwin ()
848
+ else :
849
+ return curses .wrapper (func )
808
850
809
851
810
852
def _load_config ():
You can’t perform that action at this time.
0 commit comments