void sched_start(struct status_line *status) { const unsigned sleeptime = longest_sleep(status); debug("starting scheduler with sleep time %d", sleeptime); while (1) { update_status_line(status); json_print_status_line(status); /* Sleep or force check on interruption */ if (sleep(sleeptime)) { debug("woken up by signal %d", caughtsig); if (caughtsig == SIGIO) { debug("stdin readable"); handle_click(status); } } } }
/* if force then do update otherwise return 1 if update or 0 if not */ static int update_1(Line *top, int force) { int i; Window_Type *start_win; int did_eob, time_has_expired = 0; if (Batch || (!force && (Executing_Keyboard_Macro || (Repeat_Factor != NULL) || screen_input_pending (0) || (Read_This_Character != NULL))) || (CBuf != JWindow->buffer)) { return(0); } if (Suspend_Screen_Update != 0) { Suspend_Screen_Update = 0; touch_screen (); } JWindow->mark.line = CLine; JWindow->mark.point = Point; JWindow->mark.n = LineNum + CBuf->nup; CBuf->linenum = LineNum; CBuf->max_linenum = Max_LineNum; if (Wants_Attributes && CBuf->vis_marks) { JWindow->trashed = 1; } /* Do not bother setting this unless it is really needed */ if (Display_Time) { Status_This_Time = sys_time(); time_has_expired = (Status_This_Time > Status_Last_Time + 45); } /* if cursor moves just left right, do not update status line */ if (!force && !JWindow->trashed && ((JWindow == JWindow->next) || (User_Prefers_Line_Numbers && Cursor_Motion)) /* if % wanted, assume user is like me and gets annoyed with * screen updates */ && (User_Prefers_Line_Numbers || time_has_expired)) { update_status_line(0); return(1); } if (!JWindow->trashed && Cursor_Motion) { #if JED_HAS_LINE_ATTRIBUTES if (CLine->flags & JED_LINE_IS_READONLY) update_status_line (0); #endif return 1; } start_win = JWindow; do { int imax; unsigned int start_column; #if JED_HAS_LINE_ATTRIBUTES if (CBuf->min_unparsed_line_num) jed_syntax_parse_buffer (0); #endif if (Wants_Syntax_Highlight) init_syntax_highlight (); #if JED_HAS_LINE_ATTRIBUTES if (top != NULL) top = jed_find_non_hidden_line (top); #endif /* (void) SLsmg_utf8_enable (CBuf->local_vars.is_utf8); */ if (top == NULL) { top = find_top(); if (top == NULL) top = CLine; } JWindow->beg.line = top; #if JED_HAS_LINE_ATTRIBUTES if (top->flags & JED_LINE_HIDDEN) top = NULL; else #endif mark_window_attributes ((start_win == JWindow) || (start_win->buffer != CBuf)); did_eob = 0; i = JWindow->sy; imax = i + JWindow->rows; compute_line_display_size (); start_column = JWindow->sx; while (i < imax) { #if JED_HAS_LINE_ATTRIBUTES if ((top != NULL) && (top->flags & JED_LINE_HIDDEN)) { top = top->next; continue; } #endif /* the next line is really optional */ #if 0 if (!force && (Exit_From_MiniBuffer || screen_input_pending (0))) break; #endif if ((JScreen[i].line != top) || JScreen[i].is_modified || (Want_Eob && !did_eob && (i != Jed_Num_Screen_Rows - 1) && (top == NULL))) { if (((top == NULL) || (top->len == 0)) && (Want_Eob && !did_eob && !(CBuf->flags & READ_ONLY))) { display_line(&Eob_Line, i, start_column); /* JScreen[i].line = top; */ did_eob = 1; } else display_line(top, i, start_column); } if (top != NULL) top = top->next; i++; } HScroll_Line = NULL; Mode_Has_Syntax_Highlight = 0; if (!force && screen_input_pending (0)) { while (JWindow != start_win) other_window(); JWindow->trashed = 1; /* since cursor not pointed */ /* (void) SLsmg_utf8_enable (1); */ /* default state */ return(0); } else update_status_line (start_win != JWindow); #if JED_HAS_DISPLAY_LINE_NUMBERS if (CBuf->line_num_display_size) display_line_numbers (); #endif JWindow->trashed = 0; other_window(); top = NULL; /* if (!JWindow->trashed) top = JWindow->beg.line; else top = NULL; */ } while (JWindow != start_win); /* SLsmg_utf8_enable (1); */ /* default state */ return 1; }