Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

68 řádky
1.8 KiB

  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # driver libcaca test drivers program
  5. # Copyright (c) 2010 Alex Foulon <alxf@lavabit.com>
  6. #
  7. # This file is a Python port of "examples/driver.c"
  8. # which is:
  9. # Copyright (c) 2006-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. lst = caca.get_display_driver_list()
  25. cur = 0
  26. try:
  27. cv = Canvas(0, 0)
  28. dp = Display(cv)
  29. except (CanvasError, DisplayError) as err:
  30. sys.stderr.write("%s\n" % err)
  31. sys.exit(127)
  32. cv.set_color_ansi(caca.COLOR_WHITE, caca.COLOR_BLACK)
  33. while True:
  34. cv.put_str(1, 0, "Available drivers:")
  35. cur_driver = dp.get_driver()
  36. n = 0
  37. for driver, desc in lst:
  38. if driver == cur_driver:
  39. cv.put_str(2, n + 2, "%s %s (%s)" % ('*', driver, desc))
  40. else:
  41. cv.put_str(2, n + 2, "%s %s (%s)" % (' ', driver, desc))
  42. n += 1
  43. cv.put_str(2, n + 3, "Switching driver in 5 seconds")
  44. dp.refresh()
  45. if dp.get_event(caca.EVENT_KEY_PRESS, Event(), 5000000):
  46. break
  47. cur += 1
  48. if cur < len(lst) and lst[cur][0] == "raw":
  49. cur += 1
  50. if cur >= len(lst):
  51. cur = 0
  52. dp.set_driver(lst[cur][0])
  53. if __name__ == "__main__":
  54. main()