t_ll *find_cols(t_ll *files) { t_ll *cols; int term_cols; term_cols = get_window_columns(); if (term_cols == -1) { if (g_opts->multicolumn) term_cols = DEFAULT_OUTPUT_WIDTH; else return (NULL); } if (one_liner(files, term_cols, &cols)) return (cols); cols = find_cols_rec(files, 2, term_cols); return (cols); }
options() { /** change options... **/ /* return: * > 0 if restort was done - to indicate we might need to * change the page of our headers as a consequence * of the new sort order * < 0 if user entered 'x' to quit elm immediately * 0 otherwise */ int ch, resort = 0; char *strcpy(), temp[SLEN]; /* needed when an option is run through * expand_env(), because that function * is destructive of the original */ display_options(); clearerr(stdin); while(1) { ClearLine(LINES-4); Centerline(LINES-4, "Select first letter of option line, '>' to save, or 'i' to return to index."); PutLine0(LINES-2, 0, "Command: "); ch = ReadCh(); ch = tolower(ch); clear_error(); /* remove possible "sorting" message etc... */ one_liner(one_liner_for(ch)); switch (ch) { case 'c' : optionally_enter(raw_calendar_file, 2, 23, FALSE, FALSE); strcpy(temp, raw_calendar_file); expand_env(calendar_file, temp); break; case 'd' : optionally_enter(raw_pager, 3, 23, FALSE, FALSE); strcpy(temp, raw_pager); expand_env(pager, temp); clear_pages = (equal(pager, "builtin+") || equal(pager, "internal+")); break; case 'e' : optionally_enter(raw_editor, 4, 23, FALSE, FALSE); strcpy(temp, raw_editor); expand_env(editor, temp); break; case 'f' : optionally_enter(raw_folders, 5, 23, FALSE, FALSE); strcpy(temp, raw_folders); expand_env(folders, temp); break; case 's' : if(change_sort(6,23)) resort++; break; case 'o' : optionally_enter(raw_sentmail, 7, 23, FALSE, FALSE); strcpy(temp, raw_sentmail); expand_env(sent_mail, temp); break; case 'p' : optionally_enter(raw_printout, 8, 23, FALSE, FALSE); strcpy(temp, raw_printout); expand_env(printout, temp); break; case 'y' : optionally_enter(full_username, 9, 23, FALSE, FALSE); break; case 'a' : on_or_off(&arrow_cursor, 12, 23); break; case 'm' : on_or_off(&mini_menu, 13, 23); headers_per_page = LINES - (mini_menu ? 13 : 8); break; case 'u' : switch_user_level(&user_level,15, 23); break; case 'n' : on_or_off(&names_only, 16, 23); break; case '?' : options_help(); PutLine0(LINES-2,0,"Command: "); break; case '>' : printf("Save options in .elm/elmrc..."); fflush(stdout); save_options(); break; case 'x' : return(-1); /* exit elm */ case 'q' : /* pop back up to previous level, in this case == 'i' */ case 'i' : /* return to index screen */ return(resort ? 1 : 0); case ctrl('L'): display_options(); break; default: error("Command unknown!"); } } }