tweaks: reshuffle some declarations, and expand a few variable names
Этот коммит содержится в:
родитель
445cd2a6c5
Коммит
c64f506933
@ -457,7 +457,6 @@ void read_the_list(const char *path, DIR *dir)
|
||||
* if necessary, and display the list of files. */
|
||||
void browser_refresh(void)
|
||||
{
|
||||
size_t i;
|
||||
int row = 0, col = 0;
|
||||
/* The current row and column while the list is getting displayed. */
|
||||
int the_row = 0, the_column = 0;
|
||||
@ -470,11 +469,10 @@ void browser_refresh(void)
|
||||
|
||||
wmove(edit, 0, 0);
|
||||
|
||||
i = selected - selected % (editwinrows * width);
|
||||
|
||||
for (; i < filelist_len && row < editwinrows; i++) {
|
||||
for (size_t index = selected - selected % (editwinrows * width);
|
||||
index < filelist_len && row < editwinrows; index++) {
|
||||
struct stat st;
|
||||
const char *thename = tail(filelist[i]);
|
||||
const char *thename = tail(filelist[index]);
|
||||
/* The filename we display, minus the path. */
|
||||
size_t namelen = breadth(thename);
|
||||
/* The length of the filename in columns. */
|
||||
@ -493,7 +491,7 @@ void browser_refresh(void)
|
||||
|
||||
/* If this is the selected item, draw its highlighted bar upfront, and
|
||||
* remember its location to be able to place the cursor on it. */
|
||||
if (i == selected) {
|
||||
if (index == selected) {
|
||||
wattron(edit, interface_color_pair[SELECTED_TEXT]);
|
||||
mvwprintw(edit, row, col, "%*s", longest, " ");
|
||||
the_row = row;
|
||||
@ -512,8 +510,8 @@ void browser_refresh(void)
|
||||
/* Show information about the file: "--" for symlinks (except when
|
||||
* they point to a directory) and for files that have disappeared,
|
||||
* "(dir)" for directories, and the file size for normal files. */
|
||||
if (lstat(filelist[i], &st) == -1 || S_ISLNK(st.st_mode)) {
|
||||
if (stat(filelist[i], &st) == -1 || !S_ISDIR(st.st_mode))
|
||||
if (lstat(filelist[index], &st) == -1 || S_ISLNK(st.st_mode)) {
|
||||
if (stat(filelist[index], &st) == -1 || !S_ISDIR(st.st_mode))
|
||||
info = copy_of("--");
|
||||
else
|
||||
/* TRANSLATORS: Try to keep this at most 7 characters. */
|
||||
@ -564,7 +562,7 @@ void browser_refresh(void)
|
||||
mvwaddstr(edit, row, col - infolen, info);
|
||||
|
||||
/* If this is the selected item, finish its highlighting. */
|
||||
if (i == selected)
|
||||
if (index == selected)
|
||||
wattroff(edit, interface_color_pair[SELECTED_TEXT]);
|
||||
|
||||
free(info);
|
||||
|
30
src/color.c
30
src/color.c
@ -67,7 +67,6 @@ void set_colorpairs(void)
|
||||
{
|
||||
syntaxtype *sint;
|
||||
bool using_defaults = FALSE;
|
||||
size_t i;
|
||||
|
||||
/* Tell ncurses to enable colors. */
|
||||
start_color();
|
||||
@ -78,30 +77,31 @@ void set_colorpairs(void)
|
||||
#endif
|
||||
|
||||
/* Initialize the color pairs for nano's interface elements. */
|
||||
for (i = 0; i < NUMBER_OF_ELEMENTS; i++) {
|
||||
colortype *combo = color_combo[i];
|
||||
for (size_t index = 0; index < NUMBER_OF_ELEMENTS; index++) {
|
||||
colortype *combo = color_combo[index];
|
||||
|
||||
if (combo != NULL) {
|
||||
if (combo->fg == USE_THE_DEFAULT && !using_defaults)
|
||||
combo->fg = COLOR_WHITE;
|
||||
if (combo->bg == USE_THE_DEFAULT && !using_defaults)
|
||||
combo->bg = COLOR_BLACK;
|
||||
init_pair(i + 1, combo->fg, combo->bg);
|
||||
interface_color_pair[i] = COLOR_PAIR(i + 1) | A_BANDAID |
|
||||
combo->attributes;
|
||||
init_pair(index + 1, combo->fg, combo->bg);
|
||||
interface_color_pair[index] = COLOR_PAIR(index + 1) | A_BANDAID |
|
||||
combo->attributes;
|
||||
} else {
|
||||
if (i == FUNCTION_TAG)
|
||||
interface_color_pair[i] = A_NORMAL;
|
||||
else if (i == GUIDE_STRIPE)
|
||||
interface_color_pair[i] = A_REVERSE;
|
||||
else if (i == ERROR_MESSAGE) {
|
||||
init_pair(i + 1, COLOR_WHITE, COLOR_RED);
|
||||
interface_color_pair[i] = COLOR_PAIR(i + 1) | A_BOLD | A_BANDAID;
|
||||
if (index == FUNCTION_TAG)
|
||||
interface_color_pair[index] = A_NORMAL;
|
||||
else if (index == GUIDE_STRIPE)
|
||||
interface_color_pair[index] = A_REVERSE;
|
||||
else if (index == ERROR_MESSAGE) {
|
||||
init_pair(index + 1, COLOR_WHITE, COLOR_RED);
|
||||
interface_color_pair[index] = COLOR_PAIR(index + 1) |
|
||||
A_BOLD | A_BANDAID;
|
||||
} else
|
||||
interface_color_pair[i] = hilite_attribute;
|
||||
interface_color_pair[index] = hilite_attribute;
|
||||
}
|
||||
|
||||
free(color_combo[i]);
|
||||
free(color_combo[index]);
|
||||
}
|
||||
|
||||
/* For each loaded syntax, assign pair numbers to color combinations. */
|
||||
|
@ -103,8 +103,6 @@ void record_macro(void)
|
||||
* so they will be "executed" again. */
|
||||
void run_macro(void)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (recording) {
|
||||
statusbar(_("Cannot run macro while recording"));
|
||||
snip_last_keystroke();
|
||||
@ -119,7 +117,7 @@ void run_macro(void)
|
||||
key_buffer = (int *)nrealloc(key_buffer, macro_length * sizeof(int));
|
||||
key_buffer_len = macro_length;
|
||||
|
||||
for (i = 0; i < macro_length; i++)
|
||||
for (size_t i = 0; i < macro_length; i++)
|
||||
key_buffer[i] = macro_buffer[i];
|
||||
|
||||
mute_modifiers = TRUE;
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user