Smart Show Demo

Smart Show Demo

This example demonstrates intelligent display mode selection based on environment.

Files

  • smart_show_demo.f90 - Source code

Running

make example ARGS="smart_show_demo"

Features Demonstrated

  • Environment detection: GUI vs terminal detection
  • Automatic fallback: ASCII when no GUI available
  • Smart defaults: Best output for context
  • User override: Force specific backend

Display Logic

  1. Check environment:
  2. DISPLAY variable (Linux/Unix)
  3. Terminal capabilities
  4. SSH session detection

  5. Select backend:

  6. GUI available → PNG viewer
  7. Terminal only → ASCII output
  8. File output → User specified

  9. Fallback chain:

  10. Try PNG viewer
  11. Fall back to ASCII
  12. Save to file if all else fails

Use Cases

  • Local development: Full GUI viewer
  • Remote SSH: ASCII visualization
  • CI/CD pipelines: File output only
  • Docker containers: Depends on configuration

Example Output

GUI Mode

Opens in image viewer with full graphics

Terminal Mode

Smart Plot Display
==================
     1.0 |    **
         |   *  *
     0.5 |  *    *
         | *      *
     0.0 |*        *
    -0.5 |          *
         |           *
    -1.0 |            **
         +---------------
         0              2π