@@ -1198,22 +1198,39 @@ def print_to(
1198
1198
end : str = "\n " ,
1199
1199
style : StyleType | None = None ,
1200
1200
soft_wrap : bool = True ,
1201
+ emoji : bool = False ,
1202
+ markup : bool = False ,
1203
+ highlight : bool = False ,
1201
1204
rich_print_kwargs : RichPrintKwargs | None = None ,
1202
1205
** kwargs : Any , # noqa: ARG002
1203
1206
) -> None :
1204
1207
"""Print objects to a given file stream.
1205
1208
1209
+ This method is configured for general-purpose printing. By default, it enables
1210
+ soft wrap and disables Rich's automatic detection for markup, emoji, and highlighting.
1211
+ These defaults can be overridden by passing explicit keyword arguments.
1212
+
1206
1213
:param file: file stream being written to
1207
1214
:param objects: objects to print
1208
1215
:param sep: string to write between printed text. Defaults to " ".
1209
1216
:param end: string to write at end of printed text. Defaults to a newline.
1210
1217
:param style: optional style to apply to output
1211
- :param soft_wrap: Enable soft wrap mode. If True, lines of text will not be word-wrapped or cropped to
1212
- fit the terminal width. Defaults to True.
1218
+ :param soft_wrap: Enable soft wrap mode. If True, lines of text will not be
1219
+ word-wrapped or cropped to fit the terminal width. Defaults to True.
1220
+ :param emoji: If True, Rich will replace emoji codes (e.g., :smiley:) with their
1221
+ corresponding Unicode characters. Defaults to False.
1222
+ :param markup: If True, Rich will interpret strings with tags (e.g., [bold]hello[/bold])
1223
+ as styled output. Defaults to False.
1224
+ :param highlight: If True, Rich will automatically apply highlighting to elements within
1225
+ strings, such as common Python data types like numbers, booleans, or None.
1226
+ This is particularly useful when pretty printing objects like lists and
1227
+ dictionaries to display them in color. Defaults to False.
1213
1228
:param rich_print_kwargs: optional additional keyword arguments to pass to Rich's Console.print().
1214
1229
:param kwargs: Arbitrary keyword arguments. This allows subclasses to extend the signature of this
1215
1230
method and still call `super()` without encountering unexpected keyword argument errors.
1216
1231
These arguments are not passed to Rich's Console.print().
1232
+
1233
+ See the Rich documentation for more details on emoji codes, markup tags, and highlighting.
1217
1234
"""
1218
1235
prepared_objects = ru .prepare_objects_for_rendering (* objects )
1219
1236
@@ -1224,6 +1241,9 @@ def print_to(
1224
1241
end = end ,
1225
1242
style = style ,
1226
1243
soft_wrap = soft_wrap ,
1244
+ emoji = emoji ,
1245
+ markup = markup ,
1246
+ highlight = highlight ,
1227
1247
** (rich_print_kwargs if rich_print_kwargs is not None else {}),
1228
1248
)
1229
1249
except BrokenPipeError :
@@ -1242,6 +1262,9 @@ def poutput(
1242
1262
end : str = "\n " ,
1243
1263
style : StyleType | None = None ,
1244
1264
soft_wrap : bool = True ,
1265
+ emoji : bool = False ,
1266
+ markup : bool = False ,
1267
+ highlight : bool = False ,
1245
1268
rich_print_kwargs : RichPrintKwargs | None = None ,
1246
1269
** kwargs : Any , # noqa: ARG002
1247
1270
) -> None :
@@ -1256,6 +1279,9 @@ def poutput(
1256
1279
end = end ,
1257
1280
style = style ,
1258
1281
soft_wrap = soft_wrap ,
1282
+ emoji = emoji ,
1283
+ markup = markup ,
1284
+ highlight = highlight ,
1259
1285
rich_print_kwargs = rich_print_kwargs ,
1260
1286
)
1261
1287
@@ -1266,6 +1292,9 @@ def perror(
1266
1292
end : str = "\n " ,
1267
1293
style : StyleType | None = Cmd2Style .ERROR ,
1268
1294
soft_wrap : bool = True ,
1295
+ emoji : bool = False ,
1296
+ markup : bool = False ,
1297
+ highlight : bool = False ,
1269
1298
rich_print_kwargs : RichPrintKwargs | None = None ,
1270
1299
** kwargs : Any , # noqa: ARG002
1271
1300
) -> None :
@@ -1282,6 +1311,9 @@ def perror(
1282
1311
end = end ,
1283
1312
style = style ,
1284
1313
soft_wrap = soft_wrap ,
1314
+ emoji = emoji ,
1315
+ markup = markup ,
1316
+ highlight = highlight ,
1285
1317
rich_print_kwargs = rich_print_kwargs ,
1286
1318
)
1287
1319
@@ -1291,6 +1323,9 @@ def psuccess(
1291
1323
sep : str = " " ,
1292
1324
end : str = "\n " ,
1293
1325
soft_wrap : bool = True ,
1326
+ emoji : bool = False ,
1327
+ markup : bool = False ,
1328
+ highlight : bool = False ,
1294
1329
rich_print_kwargs : RichPrintKwargs | None = None ,
1295
1330
** kwargs : Any , # noqa: ARG002
1296
1331
) -> None :
@@ -1304,6 +1339,9 @@ def psuccess(
1304
1339
end = end ,
1305
1340
style = Cmd2Style .SUCCESS ,
1306
1341
soft_wrap = soft_wrap ,
1342
+ emoji = emoji ,
1343
+ markup = markup ,
1344
+ highlight = highlight ,
1307
1345
rich_print_kwargs = rich_print_kwargs ,
1308
1346
)
1309
1347
@@ -1313,6 +1351,9 @@ def pwarning(
1313
1351
sep : str = " " ,
1314
1352
end : str = "\n " ,
1315
1353
soft_wrap : bool = True ,
1354
+ emoji : bool = False ,
1355
+ markup : bool = False ,
1356
+ highlight : bool = False ,
1316
1357
rich_print_kwargs : RichPrintKwargs | None = None ,
1317
1358
** kwargs : Any , # noqa: ARG002
1318
1359
) -> None :
@@ -1326,6 +1367,9 @@ def pwarning(
1326
1367
end = end ,
1327
1368
style = Cmd2Style .WARNING ,
1328
1369
soft_wrap = soft_wrap ,
1370
+ emoji = emoji ,
1371
+ markup = markup ,
1372
+ highlight = highlight ,
1329
1373
rich_print_kwargs = rich_print_kwargs ,
1330
1374
)
1331
1375
@@ -1390,6 +1434,9 @@ def pfeedback(
1390
1434
end : str = "\n " ,
1391
1435
style : StyleType | None = None ,
1392
1436
soft_wrap : bool = True ,
1437
+ emoji : bool = False ,
1438
+ markup : bool = False ,
1439
+ highlight : bool = False ,
1393
1440
rich_print_kwargs : RichPrintKwargs | None = None ,
1394
1441
** kwargs : Any , # noqa: ARG002
1395
1442
) -> None :
@@ -1408,6 +1455,9 @@ def pfeedback(
1408
1455
end = end ,
1409
1456
style = style ,
1410
1457
soft_wrap = soft_wrap ,
1458
+ emoji = emoji ,
1459
+ markup = markup ,
1460
+ highlight = highlight ,
1411
1461
rich_print_kwargs = rich_print_kwargs ,
1412
1462
)
1413
1463
else :
@@ -1417,6 +1467,9 @@ def pfeedback(
1417
1467
end = end ,
1418
1468
style = style ,
1419
1469
soft_wrap = soft_wrap ,
1470
+ emoji = emoji ,
1471
+ markup = markup ,
1472
+ highlight = highlight ,
1420
1473
rich_print_kwargs = rich_print_kwargs ,
1421
1474
)
1422
1475
@@ -1428,6 +1481,9 @@ def ppaged(
1428
1481
style : StyleType | None = None ,
1429
1482
chop : bool = False ,
1430
1483
soft_wrap : bool = True ,
1484
+ emoji : bool = False ,
1485
+ markup : bool = False ,
1486
+ highlight : bool = False ,
1431
1487
rich_print_kwargs : RichPrintKwargs | None = None ,
1432
1488
** kwargs : Any , # noqa: ARG002
1433
1489
) -> None :
@@ -1479,6 +1535,9 @@ def ppaged(
1479
1535
end = end ,
1480
1536
style = style ,
1481
1537
soft_wrap = soft_wrap ,
1538
+ emoji = emoji ,
1539
+ markup = markup ,
1540
+ highlight = highlight ,
1482
1541
** (rich_print_kwargs if rich_print_kwargs is not None else {}),
1483
1542
)
1484
1543
output_bytes = capture .get ().encode ('utf-8' , 'replace' )
@@ -1503,6 +1562,9 @@ def ppaged(
1503
1562
end = end ,
1504
1563
style = style ,
1505
1564
soft_wrap = soft_wrap ,
1565
+ emoji = emoji ,
1566
+ markup = markup ,
1567
+ highlight = highlight ,
1506
1568
rich_print_kwargs = rich_print_kwargs ,
1507
1569
)
1508
1570
0 commit comments