⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 select_o.pro

📁 basic median filter simulation
💻 PRO
字号:
PRO SELECT_O, selections, iselected, comments, command_line, only_one, $              COUNT = n_select;+; NAME:;	SELECT_O; PURPOSE:;	Dumb-terminal routine to let a user interactively select from a list; EXPLANATION: ;	This is the non-widget version of SCREEN_SELECT;; CALLING SEQUENCE:;	select_o, selections, iselected, comments, command_line, only_one, $;                            [ COUNT = ];; INPUTS:;	selections - string array giving list of items that can be;		selected.;; OPTIONAL INPUTS:;	comments - comments which can be requested for each item in;		array selections.  It can be:;			string array - same length as array selections.;			null string - no comments available;			scalar string - name of a procedure which will;				return comments.  It will take selections;				as its first argument and return comments;				as its second argument.;	command_line - optional command line to be placed at the bottom;		of the screen.  It is usually used to specify what the;		user is selecting.;	only_one - integer flag. If set to 1 then the user can only select;		one item.  The routine returns immediately after the first;		selection is made.; OUTPUTS:;	iselected - list of indices in selections giving the selected;		items.; OPTIONAL OUTPUT KEYWORD:;       COUNT - Integer scalar giving the number of selections; SIDE EFFECTS:;	The obsolete system variable !err is set to the number of selections; HISTORY:;	version 1, D. Lindler  April 88.;	changed name from screen_select_o         W. Landsman January 1993;       Added COUNT keyword, deprecate !ERR   W. Landsman   March 2000;       Remove VMS code  W. Landsman September 2006;-;--------------------------------------------------------------------------;			set defaults;IF n_params(0) LT 3 THEN comments=''IF n_params(0) LT 4 THEN command_line=''IF n_params(0) LT 5 THEN only_one=0;; 			initilization;n_select=0			;number of selections maden=n_elements(selections)nchar=max(strlen(selections))help_avail=0			;help available flagncom=0				;Length of commentsIF n_elements(comments) EQ n THEN BEGIN	ncom=max(strlen(comments))	help_avail=1ENDIFIF n_elements(comments) EQ 1 THEN BEGIN				;scalar string	IF strlen(strtrim(comments)) GT 0 THEN help_avail=1	;function nameENDIFquestion=0			;user asked for help;; 			determine screen format;inpos = 0spos = 0totchr = (nchar+ncom*question+3) < 79 		;total characters requirednx = 79 / totchr				;number in x directionny = (n+nx-1)/nx				;total number in y directionscreen=strarr(nx,ny)				;fill display string array.selected = replicate(0B,nx,ny)			;vector of selected valuesk = 0FOR j = 0, ny-1 DO BEGIN	FOR i = 0, nx-1 DO BEGIN		IF (k LT n) THEN BEGIN			st=selections[k]			IF (ncom GT 0) AND (question EQ 1) THEN $				st=' '+st+' '+comments[k]			screen[i,j]=st		ENDIF ELSE screen[i,j] = "  "		k = k + 1      	ENDFORENDFORnlines = 22 < ny			;number of screen lines to displaynscr = (ny + nlines - 1) / nlines	;number of screens to display.xpos = indgen(nx) * totchr + 1ypos = indgen(nlines) + 1;; 			screen format init.;cr = 10B	;keystrokesup = 128Bdown = 130Bleft = 129Bright = 131Bix=0				;current position on screeniy=0iscr = 0scr_curpos, 0, 0			;get scr_curpos compiled.key = read_key(0)			;get read_key compiled.refresh:scr_attrib, 0       			;clear attributesscr_other, '[?25l'			;disable visible cursorscr_erase, 5         			;clear screen;; 			print initial contents of the screen;FOR j = 0, nlines-1 DO BEGIN	k = j + spos	FOR i = 0, nx-1 DO BEGIN 		IF k LT ny THEN BEGIN 		   	IF selected[i,k] THEN scr_attrib, 0, 1			scr_curpos, ypos[j], xpos[i]			print, screen[i,k]			scr_attrib, 0		ENDIF	ENDFORENDFOR;; 			print help lines in the text window.;message='Use arrow keys to move.  'IF only_one THEN message=message+'<cr> or <space bar> to select' $	    ELSE message=message+'<space bar> to select.  <cr> when done'IF help_avail THEN message=message+'  ? for info.'scr_attrib, 0, 1scr_curpos, 22, 1print, messageprint, command_linescr_attrib, 0;; 			loop until <cr>;key= 0BWHILE key NE cr DO BEGIN;; 			high light current location;	scr_attrib, 0, 4	scr_curpos, ypos[iy], xpos[ix]	print, screen[ix,iy+spos]	scr_attrib, 0;; 			process next key;	key = read_key(1);; 			arrow key processing;	IF (key EQ up) OR (key EQ down) OR (key EQ right) OR (key EQ left) $	    THEN BEGIN	    scroll=0				;scroll flag;;				unhighlight the previous selection.;	    scr_curpos, ypos[iy], xpos[ix]	;remove cursor attrib.	    IF selected[inpos] THEN BEGIN	;if selected, change attrib.		scr_attrib, 0, 1            ENDIF	    print, screen[ix,iy+spos]	    scr_attrib, 0;;				decode arrow key.;	    CASE key OF		up: BEGIN			IF iy GT 0 THEN BEGIN				iy = iy - 1				inpos = inpos - nx		    	ENDIF ELSE BEGIN				IF iscr GT 0 THEN BEGIN				    iscr = iscr - 1				    scroll = 1				ENDIF			ENDELSE		    END		down: BEGIN			IF (iy LT (nlines-1)) AND ((iy+spos) LT (ny-1)) $			THEN BEGIN				inpos=inpos+nx				iy=iy+1			ENDIF ELSE BEGIN				IF iscr LT (nscr - 1) THEN BEGIN				    iscr = iscr + 1				    scroll = 1				ENDIF			ENDELSE		     END		right: BEGIN 			 IF ix LT (nx-1) THEN BEGIN				ix=ix+1				inpos=inpos+1			 ENDIF		       END		left : BEGIN			 IF ix GT 0 THEN BEGIN				ix=ix-1				inpos=inpos-1			 ENDIF		       END	    ENDCASE	    WHILE inpos GE n DO BEGIN		;prevent passing end-of-list		inpos=inpos-1		ix=ix-1	    ENDWHILE;; 			do we need to scroll ?;		IF scroll THEN BEGIN			iy = 0			spos = iscr * nlines			inpos = (nx * spos) + ix			goto, refresh		ENDIF	ENDIF;; 			process other keys;	IF (only_one EQ 1) AND (key EQ cr) THEN key=' '	;select with cr also	   if string(key) EQ ' ' THEN BEGIN		    IF (NOT selected[inpos]) THEN BEGIN			selected[inpos]=1B			n_select=n_select+1                        IF n_select EQ 1 THEN iselected = lonarr(1) + inpos $                                         ELSE iselected = [iselected,inpos]			IF only_one THEN BEGIN		;got our one selection?                                iselected = iselected[0]				goto,done			ENDIF		    ENDIF		  ENDIF	CASE strupcase(key) OF	    cr  : goto,done	    'R' : BEGIN			selected[inpos]=0B			n_select = (n_select - 1) > 0		  END	    '?' : BEGIN		   IF (help_avail) THEN BEGIN			IF (ncom EQ 0) THEN BEGIN  ;go get help text			    scr_erase, 5			    print, 'PLEASE WAIT....'			    istat=execute(comments+',selections,comments')			    ncom=strlen(comments[0])			    print, 'FINISHED WITH HELP'			ENDIF			question=1			goto,refresh		   ENDIF	          END	    ELSE :	ENDCASEENDWHILE;;			Finished.  Set !err to the number of items selected.;done:scr_other, '[?25h'			;enable visible cursor!err = n_selectscr_erase, 5;RETURNEND

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -