25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 
 

77 satır
2.1 KiB

  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # colors display all possible libcaca colour pairs
  5. # Copyright (c) 2010 Alex Foulon <alxf@lavabit.com>
  6. #
  7. # This file is a Python port of "examples/colors.c"
  8. # which is:
  9. # Copyright (c) 2003-2010 Sam Hocevar <sam@hocevar.net>
  10. # All Rights Reserverd
  11. #
  12. # This library is free software. It comes without any warranty, to
  13. # the extent permitted by applicable law. You can redistribute it
  14. # and/or modify it under the terms of the Do What the Fuck You Want
  15. # to Public License, Version 2, as published by Sam Hocevar. See
  16. # http://www.wtfpl.net/ for more details.
  17. #
  18. import sys
  19. import caca
  20. from caca.canvas import Canvas, CanvasError
  21. from caca.display import Display, DisplayError, Event
  22. def main():
  23. """ Main function. """
  24. try:
  25. cv = Canvas(80, 24)
  26. dp = Display(cv)
  27. except (CanvasError, DisplayError) as err:
  28. sys.stderr.write("%s\n" % err)
  29. sys.exit(127)
  30. cv.set_color_ansi(caca.COLOR_LIGHTGRAY, caca.COLOR_BLACK)
  31. cv.clear()
  32. for i in range(0, 16):
  33. if i >= 8:
  34. y = i + 3
  35. else:
  36. y = i + 2
  37. cv.set_color_ansi(caca.COLOR_LIGHTGRAY, caca.COLOR_BLACK)
  38. cv.printf(3, y, "ANSI %i", i)
  39. for j in range(0, 16):
  40. if j >= 8:
  41. x = 13 + (j * 4)
  42. else:
  43. x = 12 + (j * 4)
  44. if i >= 8:
  45. y = i + 3
  46. else:
  47. y = i + 2
  48. cv.set_color_ansi(i, j)
  49. cv.put_str(x, y, "Aaホ")
  50. cv.set_color_ansi(caca.COLOR_LIGHTGRAY, caca.COLOR_BLACK)
  51. cv.put_str(3, 20, "This is bold This is blink This is italics This is underline")
  52. cv.set_attr(caca.STYLE_BOLD)
  53. cv.put_str(3 + 8, 20, "bold")
  54. cv.set_attr(caca.STYLE_BLINK)
  55. cv.put_str(3 + 24, 20, "blink")
  56. cv.set_attr(caca.STYLE_ITALICS)
  57. cv.put_str(3 + 41, 20, "italics")
  58. cv.set_attr(caca.STYLE_UNDERLINE)
  59. cv.put_str(3 + 60, 20, "underline")
  60. dp.refresh()
  61. dp.get_event(caca.EVENT_KEY_PRESS, Event(), -1)
  62. if __name__ == "__main__":
  63. main()