home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l460 / 2.ddi / GRAPHICS.DI$ / TERMINAL.M < prev    next >
Encoding:
Text File  |  1993-03-07  |  8.3 KB  |  322 lines

  1. function terminal(ttype)
  2. %TERMINAL Set graphics terminal type.
  3. %
  4. %    TERMINAL puts up a menu of graphics terminal types and prompts for
  5. %    a choice.  It then configures MATLAB. You can also specify the
  6. %    terminal type as the first parameter.
  7. %    You can add any terminal settings you may need for your specific
  8. %    emulators/terminals to this file.
  9. %
  10. %    The graphics terminals that are currently supported are:
  11. %
  12. %    tek401x - Tektronix 4010/4014
  13. %    tek4100 - Tektronix 4100
  14. %    tek4105 - Tektronix 4105
  15. %    retro - retrographics card
  16. %    sg100 - Selanar graphics 100
  17. %    sg200 - Selanar graphics 200
  18. %    vt240tek - VT240 & VT340 Tek mode
  19. %    ergo - ergo terminal
  20. %    graphon - graphon terminal
  21. %    citoh - C.Itoh terminal
  22. %    xtermtek - xterm, Tektronix graphics
  23. %    wyse - Wyse WY-99GT
  24. %    kermit - MS-DOS Kermit 2.23
  25. %    hp2647 - Hewlett-Packard 2647
  26. %    versa - Macintosh with VersaTerm (Tektronics 4010/4014)
  27. %    versa4100 - Macintosh with VersaTerm (Tektronics 4100)
  28. %    versa4105 - Color/Grayscale Macintosh with VersaTerm (Tektronics 4105)
  29. %    hds - Human Designed Systems
  30.  
  31. %       Copyright (c) 1984-93 by The MathWorks, Inc.
  32.  
  33. if nargin == 0,
  34.     s0 = 'Graphics Terminal Types';
  35.     s1 = 'C.Itoh';
  36.     s2 = 'Ergo';
  37.     s3 = 'Graphon';
  38.     s4 = 'HP 2647';
  39.     s5 = 'Human Designed Systems';
  40.     s6 = 'Kermit';
  41.     s7 = 'Macintosh with VersaTerm (Tektronix 4010/4014)';
  42.     s8 = 'Macintosh with VersaTerm (Tektronix 4100)';
  43.     s9 = 'Macintosh (Color/Grayscale) with VersaTerm (Tektronix 4105)';
  44.     s10 = 'Tektronix 4010/4014';
  45.     s11 = 'Tektronix 4100';
  46.     s12 = 'Tektronix 4105';
  47.     s13 = 'More selections - - - ';
  48.     clc
  49.     i=menu(s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13);
  50.     if i == 13
  51.         s1 = 'VT100 with Retrographics';
  52.         s2 = 'VT100 with Selanar 100';
  53.         s3 = 'VT100 with Selanar 200';
  54.         s4 = 'VT-240 & VT340 Tek mode';
  55.         s5 = 'Wyse WY-99GT';
  56.         s6 = 'xterm (Tektronics emulation)';
  57.         s7 = 'Cancel';
  58.         clc
  59.         i = i + menu(s0,s1,s2,s3,s4,s5,s6,s7) - 1;
  60.     end
  61.     if i >= 19 | i <= 0
  62.         return
  63.     end
  64.     ttype = i;
  65. else
  66.     termtab = [
  67.         'citoh    '
  68.         'ergo     '
  69.         'graphon  '
  70.         'hp2647   '
  71.         'hds      '
  72.         'kermit   '
  73.         'versa    '
  74.         'versa4100'
  75.         'versa4105'
  76.         'tek401x  '
  77.         'tek4100  '
  78.         'tek4105  '
  79.         'retro    '
  80.         'sg100    '
  81.         'sg200    '
  82.         'vt240tek '
  83.         'wyse     '
  84.         'xtermtek '
  85.     ];
  86.     t = 0;
  87.     for tt=1:18,
  88.         l = min(length(ttype),length(termtab(tt,:)));
  89.         if (strcmp(ttype,termtab(tt,1:l))),
  90.             t = tt;
  91.             break;
  92.         end
  93.     end
  94.     if t == 0,
  95.         if ~exist(ttype),
  96.             error(['Invalid terminal type ' ttype]);
  97.         else
  98.             eval(ttype);
  99.             return;
  100.         end
  101.     end
  102.     ttype = t;
  103. end
  104.  
  105.  
  106. % Some control characters
  107. esc = 27;
  108. nl = 10;
  109. ret = 13;
  110. ff = 12;
  111. alphamode = 31;
  112. graphmode = 29;
  113. can = 24;
  114. ctrlc = 3;
  115. nul = 0;
  116.  
  117. % This gets disp'ed at the end after the settings are done
  118. % to initialize certain terminal characteristics right away.
  119. % See Tektronix 4105 below for an example of why you'd want to use this.
  120. init_str = [];
  121.  
  122.  
  123. if (ttype == 1),
  124. % C. Itoh
  125.     showgraph = [esc '[H' esc '[2J' esc '1' esc '*'];
  126.     hidegraph = [esc ff esc '8' esc '2' esc '[A'];
  127.     screendepth = 1;
  128.     onewindow = 'yes';
  129.     tp = 'tek401x';
  130.  
  131. elseif (ttype == 2),
  132. % Ergo
  133.     showgraph = [esc '[H' esc '[2J' esc '1' esc '*'];
  134.     hidegraph = [esc ff esc '8' esc '0' esc '2'];
  135.     screendepth = 1;
  136.     onewindow = 'yes';
  137.     tp = 'tek401x';
  138.  
  139. elseif (ttype == 3),
  140. % Graphon
  141.     showgraph = [esc '[H' esc '[2J' esc '1'];
  142.     hidegraph = [esc ff esc '8' esc '2'];
  143.     screendepth = 1;
  144.     onewindow = 'yes';
  145.     tp = 'tek401x';
  146.  
  147. elseif (ttype == 4),
  148. % HP2647
  149.     showgraph = [esc '[H' esc '[2J' esc '&s1p0Q' nul];
  150.     hidegraph = [esc ff esc '8' esc '&s0p0Q' nul esc '*dT'];
  151.     screendepth = 1;
  152.     onewindow = 'yes';
  153.     tp = 'tek401x';
  154.  
  155. elseif (ttype == 5),
  156. % HDS
  157.     showgraph = setstr(graphmode);
  158.     hidegraph = [can esc '[A'];
  159.     screendepth = 1;
  160.     onewindow = 'yes';
  161.     tp = 'tek401x';
  162.  
  163. elseif (ttype == 6),
  164. % Kermit
  165.     showgraph = [esc '[?38h'];
  166.     hidegraph = [esc '[?38l'];
  167.     screendepth = 1;
  168.     onewindow = 'yes';
  169.     tp = 'tek401x';
  170.  
  171. elseif (ttype == 7),
  172. % Versaterm (Tektronix 4010/4014)
  173.     showgraph = [esc '%!8' esc ff graphmode];
  174.     hidegraph = [esc '2'];
  175.     screendepth = 1;
  176.     onewindow = 'no';
  177.     tp = 'tek401x';
  178.  
  179. elseif (ttype == 8),
  180. % Versaterm (Tektronix 4100)
  181.     showgraph = [esc '%!0' graphmode];
  182.     hidegraph = [esc '%!2'];
  183.     init_str = [esc '%!0' esc 'TF43000' esc 'LI133' esc 'KA0' esc 'LV0'];
  184.     init_str = [init_str esc 'RW `` @8co?_' nl esc 'RA!  ' esc 'MC'];
  185.     screendepth = 1;
  186.     onewindow = 'no';
  187.     tp = 'tek410x';
  188.  
  189. elseif (ttype == 9),
  190. % Versaterm (Tektronix 4105 color)
  191.     showgraph = [esc '%!0' graphmode];
  192.     hidegraph = [esc '%!2'];
  193.     init_str = [esc '%!0' esc 'TF43000' esc 'LI133' esc 'KA0' esc 'LV0'];
  194.     init_str = [init_str esc 'RW `` @8co?_' nl esc 'RA!  ' esc 'MC'];
  195.     screendepth = 3;
  196.     onewindow = 'no';
  197.     tp = 'tek410x';
  198.  
  199. elseif (ttype == 10),
  200. % Tektronix 4010/4014
  201.     showgraph = setstr([esc ff]);
  202.     hidegraph = [esc ff esc '8' nl];
  203.     screendepth = 1;
  204.     onewindow = 'yes';
  205.     tp = 'tek401x';
  206.  
  207. elseif (ttype == 11),
  208. % Tektronix 4100
  209.     showgraph = [esc '%!0' esc 'KA0' esc 'LV0'];
  210.     hidegraph = [alphamode esc 'LV1' esc 'KA1' esc '%!1'];
  211.     init_str = [esc '%!0' esc 'TF43000' esc 'LI133'];
  212.     init_str = [init_str esc 'RW `` @@' nl];
  213.     init_str = [init_str esc 'RA1' esc 'MC' esc 'MN' esc 'MR'];
  214.     init_str = [init_str esc 'LLA>' esc 'LM0' esc 'LBA>' esc '%!1'];
  215.     screendepth = 1;
  216.     onewindow = 'yes';
  217.     tp = 'tek410x';
  218.  
  219.  
  220. elseif (ttype == 12),
  221. % Tektronix 4105
  222.  
  223. % showgraph selects TEK mode, disables the dialog area and makes it invisible
  224.     showgraph = [esc '%!0' esc 'KA0' esc 'LV0'];
  225.  
  226. % hidegraph selects ALPHA mode, enables the dialog area and makes it visible
  227. % then selects ANSI mode
  228.     hidegraph = [alphamode esc 'LV1' esc 'KA1' esc '%!1'];
  229.  
  230. % init_str is used to set the following defaults:
  231. %   dialog area colormap's index 3 to (0,0,0) (HSV)
  232. %   window size to the factory default
  233. %   view attributes (background color) for the screen to 0 (factory default)
  234. %   graphtext size to the factory default
  235. %   graphtext character path to the factory default
  236. %   graphtext rotation to the factory default
  237. %   dialog area number of lines to 30
  238. %   dialog area writing mode to REPLACE mode
  239. %   dialog area buffer size to 30 lines
  240.     init_str = [esc '%!0' esc 'TF43000' esc 'LI133'];
  241.     init_str = [init_str esc 'RW `` @@' nl];
  242.     init_str = [init_str esc 'RA1' esc 'MC' esc 'MN' esc 'MR'];
  243.     init_str = [init_str esc 'LBA>' esc 'LLA>' esc 'LM0' esc '%!1'];
  244.  
  245. % there are 8 colors (tek4105 is a 3-bit machine)
  246.     screendepth = 3;
  247.  
  248. % tek4105 only has one window
  249.     onewindow = 'yes';
  250.     tp = 'tek410x';
  251.  
  252. elseif (ttype == 13),
  253. % Retrographics
  254.     showgraph = [esc '[H' esc '[2J' esc ff graphmode];
  255.     hidegraph = [esc ff esc '8' can esc '[A' nl];
  256.     screendepth = 1;
  257.     onewindow = 'yes';
  258.     tp = 'tek401x';
  259.  
  260. elseif (ttype == 14),
  261. % Selanar 100
  262.     showgraph = [esc '[H' esc '[2J' esc '1' esc '*'];
  263.     hidegraph = [esc ff esc '8' esc '2' esc '[A'];
  264.     screendepth = 1;
  265.     onewindow = 'yes';
  266.     tp = 'tek401x';
  267.  
  268. elseif (ttype == 15),
  269. % Selanar 200
  270.     showgraph = [esc '[H' esc '[2J' esc '1' esc '~6T'];
  271.     hidegraph = [esc ff esc '8' esc '~1T' esc '[A'];
  272.     screendepth = 1;
  273.     onewindow = 'yes';
  274.     tp = 'tek401x';
  275.  
  276. elseif (ttype == 16),
  277. % VT240 Tektronix mode
  278.     showgraph = [esc '[H' esc '[2J' esc '[?38h' esc ff graphmode];
  279.     hidegraph = [esc ff esc '8' ret esc '[?38l' nl];
  280.     screendepth = 1;
  281.     onewindow = 'yes';
  282.     tp = 'tek401x';
  283.  
  284. elseif (ttype == 17),
  285. % WYSE
  286.     showgraph = [esc '[?38h'];
  287.     hidegraph = [esc '[?38l' esc '[61"p' esc '[A' esc '[41' esc '[?7h'];
  288.     screendepth = 1;
  289.     onewindow = 'yes';
  290.     tp = 'tek401x';
  291.  
  292. elseif (ttype == 18),
  293. % Xterm Tektronix mode
  294.     showgraph = [esc '[?38h' esc ff];
  295.     hidegraph = setstr([esc ctrlc]);
  296.     screendepth = 1;
  297.     onewindow = 'no';
  298.     tp = 'tek401x';
  299.  
  300. else
  301.     error ('Invalid terminal type');
  302. end
  303.  
  304.  
  305. % Check to see if the terminal protocol is already set.
  306. % If it is already set and what it's currently set to is not what we want
  307. % the user will have to exit MATLAB to change it.
  308. currtp = get(0,'TerminalProtocol');
  309. if ~strcmp(currtp,'none') & ~strcmp(currtp,tp),
  310.     error(['Terminal protocol is already set to ' currtp '.' nl 'In order to switch you must exit MATLAB.']);
  311. end
  312.  
  313. % Set the other root terminal properties now
  314. set(0,'TerminalShowGraphCommand',showgraph);
  315. set(0,'TerminalHideGraphCommand',hidegraph);
  316. set(0,'ScreenDepth',screendepth);
  317. set(0,'TerminalOneWindow',onewindow);
  318. if ~strcmp(currtp,tp),
  319.     set(0,'TerminalProtocol',tp);
  320. end
  321. disp(init_str);
  322.