Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

print.c 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #include <curses.h>
  2. #include <stdio.h>
  3. #include <stddef.h>
  4. #include <gpxe/vsprintf.h>
  5. #include "mucurses.h"
  6. /** @file
  7. *
  8. * MuCurses printing functions
  9. *
  10. */
  11. /**
  12. * Add a single-byte character and rendition to a window and advance
  13. * the cursor
  14. *
  15. * @v *win window to be rendered in
  16. * @v ch character to be added at cursor
  17. * @ret rc return status code
  18. */
  19. int waddch ( WINDOW *win, const chtype ch ) {
  20. _wputch( win, ch, WRAP );
  21. return OK;
  22. }
  23. /**
  24. * Add string of single-byte characters to a window
  25. *
  26. * @v *win window to be rendered in
  27. * @v *str standard c-style string
  28. * @v n max number of chars from string to render
  29. * @ret rc return status code
  30. */
  31. int waddnstr ( WINDOW *win, const char *str, int n ) {
  32. _wputstr( win, str, WRAP, n );
  33. return OK;
  34. }
  35. struct printw_context {
  36. struct printf_context ctx;
  37. WINDOW *win;
  38. };
  39. static void _printw_handler ( struct printf_context *ctx, unsigned int c ) {
  40. struct printw_context *wctx =
  41. container_of ( ctx, struct printw_context, ctx );
  42. _wputch( wctx->win, c | wctx->win->attrs, WRAP );
  43. }
  44. /**
  45. * Print formatted output in a window
  46. *
  47. * @v *win subject window
  48. * @v *fmt formatted string
  49. * @v varglist argument list
  50. * @ret rc return status code
  51. */
  52. int vw_printw ( WINDOW *win, const char *fmt, va_list varglist ) {
  53. struct printw_context wctx;
  54. wctx.win = win;
  55. wctx.ctx.handler = _printw_handler;
  56. vcprintf ( &(wctx.ctx), fmt, varglist );
  57. return OK;
  58. }
  59. /**
  60. * Print formatted output to a window
  61. *
  62. * @v *win subject window
  63. * @v *fmt formatted string
  64. * @v ... string arguments
  65. * @ret rc return status code
  66. */
  67. int wprintw ( WINDOW *win, const char *fmt, ... ) {
  68. va_list args;
  69. int i;
  70. va_start ( args, fmt );
  71. i = vw_printw ( win, fmt, args );
  72. va_end ( args );
  73. return i;
  74. }