MOUSEEVENT * getmouseevent(void) { static MOUSEEVENT m; if (mouse == EMACSTERM) { switch (mygetch()) { case ctrl('_'): /* click */ if ((m.button = mygetch()) == '0') { /* if scroll bar */ m.percent = getpercent(); } else { m.x1 = getcoordinate(); m.y1 = getcoordinate(); m.x2 = m.y2 = -1; } break; case ctrl(']'): /* sweep */ m.button = mygetch(); m.x1 = getcoordinate(); m.y1 = getcoordinate(); m.x2 = getcoordinate(); m.y2 = getcoordinate(); break; default: return (NULL); } return (&m); } return (NULL); }
MOUSE * getmouseaction(char leading_char) { static MOUSE m; #if UNIXPC if(unixpcmouse == YES && leading_char == ESC) { /* Called if cscope received an ESC character. See if it is * a mouse report and if so, decipher it. A mouse report * looks like: "<ESC>[?xx;yy;b;rM" */ int x = 0, y = 0, button = 0, reason = 0; int i; /* Get a mouse report. The form is: XX;YY;B;RM where * XX is 1,2, or 3 decimal digits with the X pixel position. * Similarly for YY. B is a single decimal digit with the * button number (4 for one, 2 for two, and 1 for three). * R is the reason for the mouse report. * * In general, the input is read until the mouse report has * been completely read in or we have discovered that this * escape sequence is NOT a mouse report. In the latter case * return the last character read to the input stream with * myungetch(). */ /* Check for "[?" being next 2 chars */ if(((i = mygetch()) != '[') || ((i = mygetch()) != '?')) { myungetch(i); return(NULL); } /* Grab the X position (in pixels) */ while(isdigit(i = mygetch())) { x = (x*10) + (i - '0'); } if(i != ';') { myungetch(i); return(NULL); /* not a mouse report after all */ } /* Grab the Y position (in pixels) */ while(isdigit(i = mygetch())) { y = (y*10) + (i - '0'); } if(i != ';') { myungetch(i); return(NULL); } /* Get which button */ if((button = mygetch()) > '4') { myungetch(button); return(NULL); } if((i = mygetch()) != ';') { myungetch(i); return(NULL); } /* Get the reason for this mouse report */ if((reason = mygetch()) > '8') { myungetch(reason); return(NULL); } /* sequence should terminate with an 'M' */ if((i = mygetch()) != 'M') { myungetch(i); return(NULL); } /* OK. We get a mouse report whenever a button is depressed * or released. Let's ignore the report whenever the button * is depressed until when I am ready to implement sweeping. */ if(reason != '2') { return(NULL); /* '2' means button is released */ } /************************************************************ * Always indicate button 1 irregardless of which button was * really pushed. ************************************************************/ m.button = 1; /************************************************************ * Convert pixel coordinates to line and column coords. * The height and width are obtained using an ioctl() call * in mouseinit(). This assumes that variable width chars * are not being used ('though it would probably work anyway). ************************************************************/ m.x1 = x/uw_hs; /* pixel/horizontal_spacing */ m.y1 = y/uw_vs; /* pixel/vertical_spacing */ /* "null" out the other fields */ m.percent = m.x2 = m.y2 = -1; } else #endif /* not UNIXPC */ if (mouse == YES && leading_char == ctrl('X')) { switch (mygetch()) { case ctrl('_'): /* click */ if ((m.button = mygetch()) == '0') { /* if scrollbar */ m.percent = getpercent(); } else { m.x1 = getcoordinate(); m.y1 = getcoordinate(); m.x2 = m.y2 = -1; } break; case ctrl(']'): /* sweep */ m.button = mygetch(); m.x1 = getcoordinate(); m.y1 = getcoordinate(); m.x2 = getcoordinate(); m.y2 = getcoordinate(); break; default: return(NULL); } } else return(NULL); return(&m); }
/* **************************************************************** * Imprime o diretório corrente * **************************************************************** */ void do_df (int argc, const char *argv[]) { const UNI *up = &uni; int livres, total, usados, ruins, index; int end_index; short clusno; int opt; /* * Analisa as opções */ while ((opt = cmd_getopt (argv, "H")) >= 0) { switch (opt) { case 'H': /* Help */ do_df_help (); return; default: /* Erro */ fprintf (stderr, "\n"); do_df_help (); return; } } /* * Pequena consistência */ argc -= cmd_optind; argv += cmd_optind; if (argc != 0) { do_df_help (); return; } /* * Verifica quantos "clusters" estão livres */ get_whole_fat (); for ( livres = 0, ruins = 0, index = 2, end_index = 2 + up->u_n_clusters; index < end_index; index++ ) { if (C_ISFREE (clusno = get_fat_value (index))) livres++; elif (C_ISBAD (clusno)) ruins++; } total = up->u_n_clusters; usados = total - livres - ruins; total = BLTOKB (up->u_sectors_per_cluster * total); usados = BLTOKB (up->u_sectors_per_cluster * usados); livres = BLTOKB (up->u_sectors_per_cluster * livres); ruins = BLTOKB (up->u_sectors_per_cluster * ruins); /* * Imprime o cabeçalho */ printf ( "RW DISPOSITIVO SISTEMA " " TOTAL ALOCADOS LIVRES RUINS (KB) %%\n" ); /* * Imprime o resultado */ printf ("%s ", fs_status == FS_MOUNT_RO ? "RO" : " "); printf ("%-20.20s", dev_nm); printf ("%-8.8s ", sb.s_id); printf ("%7d %7d %7d %6d ", total, usados, livres, ruins); printf ( "%s %%\n", total == 0 ? "?" : editpercent (getpercent (usados, total - ruins)) ); } /* end do_df */