@@ -365,6 +365,7 @@ def new(
365365 sdl_window_flags : Optional [int ] = None ,
366366 title : Optional [str ] = None ,
367367 argv : Optional [Iterable [str ]] = None ,
368+ console : Optional [tcod .Console ] = None ,
368369) -> Context :
369370 """Create a new context with the desired pixel size.
370371
@@ -376,6 +377,9 @@ def new(
376377 `columns` and `rows` is the desired size of the console. Can be left as
377378 `None` when you're setting a context by a window size instead of a console.
378379
380+ `console` automatically fills in the `columns` and `rows` parameters from an existing :any:`tcod.console.Console`
381+ instance.
382+
379383 Providing no size information at all is also acceptable.
380384
381385 `renderer` is the desired libtcod renderer to use.
@@ -409,13 +413,19 @@ def new(
409413 the console which should be used.
410414
411415 .. versionadded:: 11.16
416+
417+ .. versionchanged:: 13.2
418+ Added the `console` parameter.
412419 """
413420 if renderer is None :
414421 renderer = RENDERER_OPENGL2
415422 if sdl_window_flags is None :
416423 sdl_window_flags = SDL_WINDOW_RESIZABLE
417424 if argv is None :
418425 argv = sys .argv
426+ if console is not None :
427+ columns = columns or console .width
428+ rows = rows or console .height
419429 argv_encoded = [ffi .new ("char[]" , arg .encode ("utf-8" )) for arg in argv ] # Needs to be kept alive for argv_c.
420430 argv_c = ffi .new ("char*[]" , argv_encoded )
421431
0 commit comments