From d5ac1b340aaaeb512eec5cd67034e9096c791775 Mon Sep 17 00:00:00 2001 From: Archie Hilton Date: Sat, 29 Jun 2024 00:10:30 +0100 Subject: [PATCH] Get whole thing working based on display buffer --- .ccls | 2 + grep | 1 + profile.log | 1711 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/main.cc | 74 ++- src/main.hh | 11 + 5 files changed, 1774 insertions(+), 25 deletions(-) create mode 100644 .ccls create mode 100644 grep create mode 100644 profile.log diff --git a/.ccls b/.ccls new file mode 100644 index 0000000..117fa70 --- /dev/null +++ b/.ccls @@ -0,0 +1,2 @@ +%compile_commands.json +--sysroot=/usr/arm-none-eabi/ diff --git a/grep b/grep new file mode 100644 index 0000000..8990538 --- /dev/null +++ b/grep @@ -0,0 +1 @@ +ccls: Unknown command line argument 'main.cc'. Try: 'ccls --help' diff --git a/profile.log b/profile.log new file mode 100644 index 0000000..4928ee4 --- /dev/null +++ b/profile.log @@ -0,0 +1,1711 @@ +FUNCTION 54_get_separator() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/builder.vim:155 +Called 18 times +Total time: 0.042920 + Self time: 0.000482 + +count total (s) self (s) + 18 0.014457 0.000175 if airline#builder#should_change_group(a:prev_group, a:group) + 18 0.028357 0.000200 return s:get_transitioned_separator(a:self, a:prev_group, a:group, a:side) + else + return a:side ? a:self._context.left_alt_sep : a:self._context.right_alt_sep + endif + +FUNCTION airline#util#winwidth() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/util.vim:19 +Called 54 times +Total time: 0.001597 + Self time: 0.001597 + +count total (s) self (s) + 54 0.000256 let nr = get(a:000, 0, 0) + " When statusline is on top, or using global statusline for Neovim + " always return the number of columns + 54 0.000257 if get(g:, 'airline_statusline_ontop', 0) || &laststatus > 2 + return &columns + 54 0.000113 else + 54 0.000251 return winwidth(nr) + endif + +FUNCTION 5() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/builder.vim:8 +Called 6 times +Total time: 0.000050 + Self time: 0.000050 + +count total (s) self (s) + 6 0.000029 call add(self._sections, ['|', a:0 ? a:1 : '%=']) + +FUNCTION 54_section_is_empty() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/builder.vim:182 +Called 36 times +Total time: 0.001368 + Self time: 0.001368 + +count total (s) self (s) + 36 0.000131 let start=1 + + " do not check for inactive windows or the tabline + 36 0.000146 if a:self._context.active == 0 + 15 0.000040 return 0 + 21 0.000087 elseif get(a:self._context, 'tabline', 0) + return 0 + 21 0.000036 endif + + " only check, if airline#skip_empty_sections == 1 + 21 0.000099 if get(g:, 'airline_skip_empty_sections', 0) == 0 + 21 0.000044 return 0 + endif + + " only check, if airline#skip_empty_sections == 1 + if get(w:, 'airline_skip_empty_sections', -1) == 0 + return 0 + endif + + " special case: When the content is %=, that is the + " separation marker, which switches between left- and + " right-aligned content. + " Consider that to be empty, so that the previous previous + " group is correctly remembered in the builder() function + if empty(a:content) || a:content is# '%=' + return 1 + endif + + let stripped = substitute(a:content, '\(%{.*}\|%#__accent_[^#]*#\|%#__restore__#\|%( \| %)\)', '', 'g') + + if !empty(stripped) + return 0 " There is content in the statusline + endif + + let exprlist = [] + call substitute(a:content, '%{\([^}]*\)}', '\=add(exprlist, submatch(1))', 'g') + + for expr in exprlist + try + " catch all exceptions, just in case + if !empty(eval(expr)) + return 0 + endif + catch + return 0 + endtry + endfor + return 1 + +FUNCTION airline#util#doautocmd() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/util.vim:178 +Called 12 times +Total time: 0.001149 + Self time: 0.000485 + +count total (s) self (s) + 12 0.000056 if !exists('#airline') && a:event !=? 'AirlineToggledOff' + " airline disabled + return + 12 0.000022 endif + 12 0.000022 try + 12 0.000794 0.000130 exe printf("silent doautocmd %s User %s", s:nomodeline, a:event) + catch /^Vim\%((\a\+)\)\=:E48:/ + " Catch: Sandbox mode + " no-op + 12 0.000026 endtry + +FUNCTION airline#util#exec_funcrefs() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/util.vim:95 +Called 6 times +Total time: 0.012736 + Self time: 0.001585 + +count total (s) self (s) + 39 0.000151 for Fn in a:list + 39 0.011689 0.000538 let code = call(Fn, a:000) + 39 0.000137 if code != 0 + 6 0.000013 return code + 33 0.000131 endif + 33 0.000114 endfor + return 0 + +FUNCTION airline#parts#mode() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/parts.vim:55 +Called 9 times +Total time: 0.001000 + Self time: 0.000250 + +count total (s) self (s) + 9 0.000139 0.000066 let part = airline#parts#get('mode') + 9 0.000040 let minwidth = get(part, 'minwidth', 79) + 9 0.000759 0.000081 return airline#util#shorten(get(w:, 'airline_current_mode', ''), minwidth, 1) + +FUNCTION 13_dopopd() + Defined: /usr/share/nvim/runtime/plugin/fzf.vim:639 +Called 3 times +Total time: 0.000036 + Self time: 0.000036 + +count total (s) self (s) + 3 0.000014 if !exists('w:fzf_pushd') + 3 0.000006 return + endif + + " FIXME: We temporarily change the working directory to 'dir' entry + " of options dictionary (set to the current working directory if not given) + " before running fzf. + " + " e.g. call fzf#run({'dir': '/tmp', 'source': 'ls', 'sink': 'e'}) + " + " After processing the sink function, we have to restore the current working + " directory. But doing so may not be desirable if the function changed the + " working directory on purpose. + " + " So how can we tell if we should do it or not? A simple heuristic we use + " here is that we change directory only if the current working directory + " matches 'dir' entry. However, it is possible that the sink function did + " change the directory to 'dir'. In that case, the user will have an + " unexpected result. + if s:fzf_getcwd() ==# w:fzf_pushd.dir && (!&autochdir || w:fzf_pushd.bufname ==# bufname('')) + execute w:fzf_pushd.command s:escape(w:fzf_pushd.origin) + endif + unlet! w:fzf_pushd + +FUNCTION 51_get_syn() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/highlighter.vim:44 +Called 4008 times +Total time: 0.238689 + Self time: 0.238689 + +count total (s) self (s) + 4008 0.011028 let color = '' + 4008 0.018098 if hlexists(a:group) + 3892 0.020517 let color = synIDattr(synIDtrans(hlID(a:group)), a:what, a:mode) + 4008 0.007971 endif + 4008 0.019174 if empty(color) || color == -1 + " should always exist + 282 0.001444 let color = synIDattr(synIDtrans(hlID('Normal')), a:what, a:mode) + " however, just in case + 282 0.001330 if empty(color) || color == -1 + 282 0.000754 let color = 'NONE' + 282 0.000579 endif + 4008 0.013027 endif + 4008 0.013482 return color + +FUNCTION airline#extensions#quickfix#inactive_qf_window() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/extensions/quickfix.vim:28 +Called 3 times +Total time: 0.000075 + Self time: 0.000075 + +count total (s) self (s) + 3 0.000032 if getbufvar(a:2.bufnr, '&filetype') is# 'qf' && !empty(airline#util#getwinvar(a:2.winnr, 'quickfix_title', '')) + call setwinvar(a:2.winnr, 'airline_section_c', '[%{get(w:, "quickfix_title", "")}] %f %m') + 3 0.000008 endif + +FUNCTION 54_get_transitioned_separator() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/builder.vim:140 +Called 24 times +Total time: 0.037922 + Self time: 0.001719 + +count total (s) self (s) + 24 0.000079 let line = '' + 24 0.000126 if get(a:self._context, 'tabline', 0) && get(g:, 'airline#extensions#tabline#alt_sep', 0) && a:group ==# 'airline_tabsel' && a:side + call airline#highlighter#add_separator(a:prev_group, a:group, 0) + let line .= '%#'.a:prev_group.'_to_'.a:group.'#' + let line .= a:self._context.right_sep.'%#'.a:group.'#' + 24 0.000068 else + 24 0.036476 0.000274 call airline#highlighter#add_separator(a:prev_group, a:group, a:side) + 24 0.000121 let line .= '%#'.a:prev_group.'_to_'.a:group.'#' + 24 0.000112 let line .= a:side ? a:self._context.left_sep : a:self._context.right_sep + 24 0.000114 let line .= '%#'.a:group.'#' + 24 0.000046 endif + 24 0.000058 return line + +FUNCTION airline#extensions#quickfix#apply() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/extensions/quickfix.vim:14 +Called 3 times +Total time: 0.000071 + Self time: 0.000071 + +count total (s) self (s) + 3 0.000014 if &buftype == 'quickfix' + let w:airline_section_a = airline#extensions#quickfix#get_type() + let w:airline_section_b = '%{get(w:, "quickfix_title", "")}' + let w:airline_section_c = '' + let w:airline_section_x = '' + 3 0.000006 endif + +FUNCTION airline#util#ignore_buf() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/util.vim:138 +Called 18 times +Total time: 0.000469 + Self time: 0.000469 + +count total (s) self (s) + 18 0.000128 let pat = '\c\v'. get(g:, 'airline#ignore_bufadd_pat', ''). get(g:, 'airline#extensions#tabline#ignore_bufadd_pat', '!|defx|gundo|nerd_tree|startify|tagbar|term://|undotree|vimfiler') + 18 0.000257 return match(a:name, pat) > -1 + +FUNCTION 6_on_window_changed() + Defined: ~/.local/share/nvim/lazy/vim-airline/plugin/airline.vim:51 +Called 3 times +Total time: 0.084138 + Self time: 0.000489 + +count total (s) self (s) + " don't trigger for Vim popup windows + 3 0.000030 if &buftype is# 'popup' + return + 3 0.000009 endif + + 3 0.000023 if pumvisible() && (!&previewwindow || g:airline_exclude_preview) + " do not trigger for previewwindows + return + 3 0.000010 endif + 3 0.000025 let s:active_winnr = winnr() + " Handle each window only once, since we might come here several times for + " different autocommands. + 3 0.000085 let l:key = [bufnr('%'), s:active_winnr, winnr('$'), tabpagenr(), &ft] + 3 0.000029 if get(g:, 'airline_last_window_changed', []) == l:key && &stl is# '%!airline#statusline('.s:active_winnr.')' && &ft !~? 'gitcommit' + " fugitive is special, it changes names and filetypes several times, + " make sure the caching does not get into its way + return + 3 0.000010 endif + 3 0.000019 let g:airline_last_window_changed = l:key + 3 0.000086 0.000040 call s:init() + 3 0.083646 0.000043 call airline#update_statusline() + +FUNCTION 19_Highlight_Matching_Pair() + Defined: /usr/share/nvim/runtime/plugin/matchparen.vim:39 +Called 6 times +Total time: 0.000997 + Self time: 0.000889 + +count total (s) self (s) + " Remove any previous match. + 6 0.000148 0.000040 call s:Remove_Matches() + + " Avoid that we remove the popup menu. + " Return when there are no colors (looks like the cursor jumps). + 6 0.000029 if pumvisible() || (&t_Co < 8 && !has("gui_running")) + return + 6 0.000012 endif + + " Get the character under the cursor and check if it's in 'matchpairs'. + 6 0.000028 let c_lnum = line('.') + 6 0.000029 let c_col = col('.') + 6 0.000015 let before = 0 + + 6 0.000028 let text = getline(c_lnum) + 6 0.000069 let matches = matchlist(text, '\(.\)\=\%'.c_col.'c\(.\=\)') + 6 0.000025 if empty(matches) + let [c_before, c] = ['', ''] + 6 0.000018 else + 6 0.000029 let [c_before, c] = matches[1:2] + 6 0.000010 endif + 6 0.000052 let plist = split(&matchpairs, '.\zs[:,]') + 6 0.000028 let i = index(plist, c) + 6 0.000014 if i < 0 + " not found, in Insert mode try character before the cursor + 6 0.000028 if c_col > 1 && (mode() == 'i' || mode() == 'R') + let before = strlen(c_before) + let c = c_before + let i = index(plist, c) + 6 0.000020 endif + 6 0.000019 if i < 0 + " not found, nothing to do + 6 0.000013 return + endif + endif + + " Figure out the arguments for searchpairpos(). + if i % 2 == 0 + let s_flags = 'nW' + let c2 = plist[i + 1] + else + let s_flags = 'nbW' + let c2 = c + let c = plist[i - 1] + endif + if c == '[' + let c = '\[' + let c2 = '\]' + endif + + " Find the match. When it was just before the cursor move it there for a + " moment. + if before > 0 + let has_getcurpos = exists("*getcurpos") + if has_getcurpos + " getcurpos() is more efficient but doesn't exist before 7.4.313. + let save_cursor = getcurpos() + else + let save_cursor = winsaveview() + endif + call cursor(c_lnum, c_col - before) + endif + + if !has("syntax") || !exists("g:syntax_on") + let s_skip = "0" + else + " Build an expression that detects whether the current cursor position is + " in certain syntax types (string, comment, etc.), for use as + " searchpairpos()'s skip argument. + " We match "escape" for special items, such as lispEscapeSpecial, and + " match "symbol" for lispBarSymbol. + let s_skip = 'synstack(".", col("."))' . '->indexof({_, id -> synIDattr(id, "name") =~? ' . '"string\\|character\\|singlequote\\|escape\\|symbol\\|comment"}) >= 0' + " If executing the expression determines that the cursor is currently in + " one of the syntax types, then we want searchpairpos() to find the pair + " within those syntax types (i.e., not skip). Otherwise, the cursor is + " outside of the syntax types and s_skip should keep its value so we skip + " any matching pair inside the syntax types. + " Catch if this throws E363: pattern uses more memory than 'maxmempattern'. + try + execute 'if ' . s_skip . ' | let s_skip = "0" | endif' + catch /^Vim\%((\a\+)\)\=:E363/ + " We won't find anything, so skip searching, should keep Vim responsive. + return + endtry + endif + + " Limit the search to lines visible in the window. + let stoplinebottom = line('w$') + let stoplinetop = line('w0') + if i % 2 == 0 + let stopline = stoplinebottom + else + let stopline = stoplinetop + endif + + " Limit the search time to 300 msec to avoid a hang on very long lines. + " This fails when a timeout is not supported. + if mode() == 'i' || mode() == 'R' + let timeout = exists("b:matchparen_insert_timeout") ? b:matchparen_insert_timeout : g:matchparen_insert_timeout + else + let timeout = exists("b:matchparen_timeout") ? b:matchparen_timeout : g:matchparen_timeout + endif + try + let [m_lnum, m_col] = searchpairpos(c, '', c2, s_flags, s_skip, stopline, timeout) + catch /E118/ + " Can't use the timeout, restrict the stopline a bit more to avoid taking + " a long time on closed folds and long lines. + " The "viewable" variables give a range in which we can scroll while + " keeping the cursor at the same position. + " adjustedScrolloff accounts for very large numbers of scrolloff. + let adjustedScrolloff = min([&scrolloff, (line('w$') - line('w0')) / 2]) + let bottom_viewable = min([line('$'), c_lnum + &lines - adjustedScrolloff - 2]) + let top_viewable = max([1, c_lnum-&lines+adjustedScrolloff + 2]) + " one of these stoplines will be adjusted below, but the current values are + " minimal boundaries within the current window + if i % 2 == 0 + if has("byte_offset") && has("syntax_items") && &smc > 0 + let stopbyte = min([line2byte("$"), line2byte(".") + col(".") + &smc * 2]) + let stopline = min([bottom_viewable, byte2line(stopbyte)]) + else + let stopline = min([bottom_viewable, c_lnum + 100]) + endif + let stoplinebottom = stopline + else + if has("byte_offset") && has("syntax_items") && &smc > 0 + let stopbyte = max([1, line2byte(".") + col(".") - &smc * 2]) + let stopline = max([top_viewable, byte2line(stopbyte)]) + else + let stopline = max([top_viewable, c_lnum - 100]) + endif + let stoplinetop = stopline + endif + let [m_lnum, m_col] = searchpairpos(c, '', c2, s_flags, s_skip, stopline) + endtry + + if before > 0 + if has_getcurpos + call setpos('.', save_cursor) + else + call winrestview(save_cursor) + endif + endif + + " If a match is found setup match highlighting. + if m_lnum > 0 && m_lnum >= stoplinetop && m_lnum <= stoplinebottom + if exists('*matchaddpos') + call matchaddpos('MatchParen', [[c_lnum, c_col - before], [m_lnum, m_col]], 10, 3) + else + exe '3match MatchParen /\(\%' . c_lnum . 'l\%' . (c_col - before) . 'c\)\|\(\%' . m_lnum . 'l\%' . m_col . 'c\)/' + endif + let w:paren_hl_on = 1 + endif + +FUNCTION 6_init() + Defined: ~/.local/share/nvim/lazy/vim-airline/plugin/airline.vim:15 +Called 3 times +Total time: 0.000046 + Self time: 0.000046 + +count total (s) self (s) + 3 0.000013 if s:airline_initialized + 3 0.000014 return + endif + let s:airline_initialized = 1 + + call airline#extensions#load() + call airline#init#sections() + + let s:theme_in_vimrc = exists('g:airline_theme') + if s:theme_in_vimrc + try + if g:airline_theme is# 'random' + let g:airline_theme=s:random_theme() + endif + let palette = g:airline#themes#{g:airline_theme}#palette + catch + call airline#util#warning(printf('Could not resolve airline theme "%s". Themes have been migrated to github.com/vim-airline/vim-airline-themes.', g:airline_theme)) + let g:airline_theme = 'dark' + endtry + try + silent call airline#switch_theme(g:airline_theme) + catch + call airline#util#warning(printf('Could not find airline theme "%s".', g:airline_theme)) + let g:airline_theme = 'dark' + silent call airline#switch_theme(g:airline_theme) + endtry + else + let g:airline_theme = 'dark' + silent call s:on_colorscheme_changed() + endif + + call airline#util#doautocmd('AirlineAfterInit') + +FUNCTION airline#parts#get() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/parts.vim:49 +Called 9 times +Total time: 0.000073 + Self time: 0.000073 + +count total (s) self (s) + 9 0.000044 return get(s:parts, a:key, {}) + +FUNCTION airline#statusline() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline.vim:218 +Called 18 times +Total time: 0.000452 + Self time: 0.000452 + +count total (s) self (s) + 18 0.000155 if has_key(s:contexts, a:winnr) + 18 0.000181 return '%{airline#check_mode('.a:winnr.')}'.s:contexts[a:winnr].line + endif + " in rare circumstances this happens...see #276 + return '' + +FUNCTION airline#extensions#keymap#status() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/extensions/keymap.vim:10 +Called 9 times +Total time: 0.000634 + Self time: 0.000634 + +count total (s) self (s) + 9 0.000047 if (get(g:, 'airline#extensions#keymap#enabled', 1) && has('keymap')) + 9 0.000042 let short_codes = get(g:, 'airline#extensions#keymap#short_codes', {}) + 9 0.000043 let label = get(g:, 'airline#extensions#keymap#label', g:airline_symbols.keymap) + 9 0.000043 let default = get(g:, 'airline#extensions#keymap#default', '') + 9 0.000022 if (label !=# '') + 9 0.000035 let label .= ' ' + 9 0.000026 endif + 9 0.000032 let keymap = &keymap + 9 0.000037 if has_key(short_codes, keymap) + let keymap = short_codes[keymap] + 9 0.000017 endif + 9 0.000051 return printf('%s', (!empty(keymap) && &iminsert ? (label . keymap) : (!empty(default) ? label . default : default))) + else + return '' + endif + +FUNCTION airline#parts#paste() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/parts.vim:65 +Called 9 times +Total time: 0.000070 + Self time: 0.000070 + +count total (s) self (s) + 9 0.000042 return g:airline_detect_paste && &paste ? g:airline_symbols.paste : '' + +FUNCTION 51_GetHiCmd() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/highlighter.vim:140 +Called 108 times +Total time: 0.039887 + Self time: 0.039887 + +count total (s) self (s) + " a:list needs to have 5 items! + 108 0.000304 let res = '' + 108 0.000310 let i = -1 + 648 0.001638 while i < 4 + 540 0.001504 let i += 1 + 540 0.002610 let item = get(a:list, i, '') + 540 0.001390 if item is '' + 114 0.000248 continue + 426 0.000983 endif + 426 0.001070 if i == 0 + 108 0.000510 let res .= ' guifg='.item + 318 0.000801 elseif i == 1 + 94 0.000468 let res .= ' guibg='.item + 224 0.000538 elseif i == 2 + 108 0.000521 let res .= ' ctermfg='.item + 116 0.000274 elseif i == 3 + 94 0.000456 let res .= ' ctermbg='.item + 22 0.000057 elseif i == 4 + 22 0.000124 let res .= printf(' gui=%s cterm=%s term=%s', item, item, item) + 426 0.000881 endif + 534 0.001207 endwhile + 108 0.000312 return res + +FUNCTION airline#extensions#wordcount#apply() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/extensions/wordcount.vim:98 +Called 3 times +Total time: 0.000247 + Self time: 0.000247 + +count total (s) self (s) + 3 0.000023 let filetypes = get(g:, 'airline#extensions#wordcount#filetypes', ['asciidoc', 'help', 'mail', 'markdown', 'rmd', 'nroff', 'org', 'rst', 'plaintex', 'tex', 'text']) + " export current filetypes settings to global namespace + 3 0.000014 let g:airline#extensions#wordcount#filetypes = filetypes + + " Check if filetype needs testing + 3 0.000014 if did_filetype() + " correctly test for compound filetypes (e.g. markdown.pandoc) + let ft = substitute(&filetype, '\.', '\\|', 'g') + + " Select test based on type of "filetypes": new=list, old=string + if type(filetypes) == get(v:, 't_list', type([])) ? match(filetypes, '\<'. ft. '\>') > -1 || index(filetypes, 'all') > -1 : match(&filetype, filetypes) > -1 + let b:airline_changedtick = -1 + call s:update_wordcount(1) " force update: ensures initial worcount exists + elseif exists('b:airline_wordcount') " cleanup when filetype is removed + unlet b:airline_wordcount + endif + 3 0.000009 endif + + 3 0.000014 if exists('b:airline_wordcount') + call airline#extensions#prepend_to_section( 'z', '%{airline#extensions#wordcount#get()}') + 3 0.000005 endif + +FUNCTION 12() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/builder.vim:62 +Called 6 times +Total time: 0.068256 + Self time: 0.009603 + +count total (s) self (s) + 6 0.000021 let side = 1 + 6 0.000021 let line = '' + 6 0.000023 let i = 0 + 6 0.000027 let length = len(self._sections) + 6 0.000033 let split = 0 + 6 0.000021 let is_empty = 0 + 6 0.000021 let prev_group = '' + + 42 0.000152 while i < length + 36 0.000156 let section = self._sections[i] + 36 0.000148 let group = section[0] + 36 0.000171 let contents = section[1] + 36 0.000131 let pgroup = prev_group + 36 0.001810 0.000406 let prev_group = airline#builder#get_prev_group(self._sections, i) + 36 0.000157 if group ==# 'airline_c' && &buftype ==# 'terminal' && self._context.active + let group = 'airline_term' + 36 0.000173 elseif group ==# 'airline_c' && !self._context.active && has_key(self._context, 'bufnr') + let group = 'airline_c'. self._context.bufnr + 36 0.000172 elseif prev_group ==# 'airline_c' && !self._context.active && has_key(self._context, 'bufnr') + let prev_group = 'airline_c'. self._context.bufnr + 36 0.000069 endif + 36 0.000080 if is_empty + let prev_group = pgroup + 36 0.000075 endif + 36 0.001747 0.000378 let is_empty = s:section_is_empty(self, contents) + + 36 0.000104 if is_empty + " need to fix highlighting groups, since we + " have skipped a section, we actually need + " the previous previous group and so the + " separator goes from the previous previous group + " to the current group + let pgroup = group + 36 0.000077 endif + + 36 0.000105 if group == '' + let line .= contents + 36 0.000104 elseif group == '|' + 6 0.000019 let side = 0 + 6 0.000028 let line .= contents + 6 0.000014 let split = 1 + 30 0.000069 else + 30 0.000087 if prev_group == '' + 6 0.000029 let line .= '%#'.group.'#' + 24 0.000061 elseif split + 6 0.000016 if !is_empty + 6 0.009845 0.000081 let line .= s:get_transitioned_separator(self, prev_group, group, side) + 6 0.000013 endif + 6 0.000018 let split = 0 + 18 0.000033 else + 18 0.000041 if !is_empty + 18 0.043147 0.000227 let line .= s:get_separator(self, prev_group, group, side) + 18 0.000034 endif + 30 0.000053 endif + 30 0.003609 0.000413 let line .= is_empty ? '' : s:get_accented_line(self, group, contents) + 36 0.000068 endif + + 36 0.000123 let i = i + 1 + 42 0.000172 endwhile + + 6 0.000019 if !self._context.active + "let line = substitute(line, '%#airline_c#', '%#airline_c'.self._context.bufnr.'#', '') + 3 0.000116 let line = substitute(line, '%#.\{-}\ze#', '\0_inactive', 'g') + 6 0.000016 endif + 6 0.000020 return line + +FUNCTION airline#update_statusline() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline.vim:144 +Called 3 times +Total time: 0.083603 + Self time: 0.000445 + +count total (s) self (s) + 3 0.000379 0.000073 if airline#util#stl_disabled(winnr()) || airline#util#is_popup_window(winnr()) + return + 3 0.000010 endif + " TODO: need to ignore popup windows here as well? + 3 0.000048 let range = filter(range(1, winnr('$')), 'v:val != winnr()') + " create inactive statusline + 3 0.034500 0.000054 call airline#update_statusline_inactive(range) + + 3 0.000014 unlet! w:airline_render_left w:airline_render_right + 3 0.000034 exe 'unlet! ' 'w:airline_section_'. join(s:sections, ' w:airline_section_') + + " Now create the active statusline + 3 0.000014 let w:airline_active = 1 + 3 0.000019 let context = { 'winnr': winnr(), 'active': 1, 'bufnr': winbufnr(winnr()) } + 3 0.000006 try + 3 0.048447 0.000042 call s:invoke_funcrefs(context, g:airline_statusline_funcrefs) + catch /^Vim\%((\a\+)\)\=:E48:/ + " Catch: Sandbox mode + " no-op + 3 0.000006 endtry + +FUNCTION airline#util#append() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/util.vim:51 +Called 63 times +Total time: 0.001614 + Self time: 0.001614 + +count total (s) self (s) + 63 0.000309 if a:minwidth > 0 && airline#util#winwidth() < a:minwidth + return '' + 63 0.000122 endif + 63 0.000296 let prefix = s:spc == "\ua0" ? s:spc : s:spc.s:spc + 63 0.000295 return empty(a:text) ? '' : prefix.g:airline_left_alt_sep.s:spc.a:text + +FUNCTION 7() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/builder.vim:17 +Called 30 times +Total time: 0.000250 + Self time: 0.000250 + +count total (s) self (s) + 30 0.000149 call add(self._sections, [a:group, a:contents]) + +FUNCTION airline#parts#readonly() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/parts.vim:179 +Called 18 times +Total time: 0.001227 + Self time: 0.000758 + +count total (s) self (s) + " only consider regular buffers (e.g. ones that represent actual files, + " but not special ones like e.g. NERDTree) + 18 0.000683 0.000214 if !empty(&buftype) || airline#util#ignore_buf(bufname('%')) + return '' + 18 0.000033 endif + 18 0.000086 if &readonly && !filereadable(bufname('%')) + return '[noperm]' + 18 0.000032 else + 18 0.000074 return &readonly ? g:airline_symbols.readonly : '' + endif + +FUNCTION 19_Remove_Matches() + Defined: /usr/share/nvim/runtime/plugin/matchparen.vim:197 +Called 12 times +Total time: 0.000327 + Self time: 0.000327 + +count total (s) self (s) + 12 0.000106 if exists('w:paren_hl_on') && w:paren_hl_on + silent! call matchdelete(3) + let w:paren_hl_on = 0 + 12 0.000035 endif + +FUNCTION 41_invoke_funcrefs() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline.vim:205 +Called 6 times +Total time: 0.081832 + Self time: 0.000516 + +count total (s) self (s) + 6 0.000391 0.000067 let builder = airline#builder#new(a:context) + 6 0.012871 0.000135 let err = airline#util#exec_funcrefs(a:funcrefs + s:core_funcrefs, builder, a:context) + 6 0.000019 if err == 1 + 6 0.068321 0.000065 let a:context.line = builder.build() + 6 0.000033 let s:contexts[a:context.winnr] = a:context + 6 0.000029 let option = get(g:, 'airline_statusline_ontop', 0) ? '&tabline' : '&statusline' + 6 0.000064 call setwinvar(a:context.winnr, option, '%!airline#statusline('.a:context.winnr.')') + 6 0.000011 endif + +FUNCTION airline#extensions#default#apply() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/extensions/default.vim:79 +Called 6 times +Total time: 0.008190 + Self time: 0.000756 + +count total (s) self (s) + 6 0.000028 let winnr = a:context.winnr + 6 0.000024 let active = a:context.active + + 6 0.000115 0.000065 if airline#util#getwinvar(winnr, 'airline_render_left', active || (!active && !g:airline_inactive_collapse)) + 3 0.001658 0.000030 call s:build_sections(a:builder, a:context, s:layout[0]) + 3 0.000007 else + 3 0.000636 0.000064 let text = !empty(s:get_section(winnr, 'c')) ? s:get_section(winnr, 'c') : ' %f%m ' + 3 0.000061 0.000032 call a:builder.add_section('airline_c'.(a:context.bufnr), text) + 6 0.000011 endif + + 6 0.000579 0.000088 call a:builder.split(s:get_section(winnr, 'gutter', '', '')) + + 6 0.000098 0.000051 if airline#util#getwinvar(winnr, 'airline_render_right', 1) + 6 0.004680 0.000063 call s:build_sections(a:builder, a:context, s:layout[1]) + 6 0.000015 endif + + 6 0.000017 return 1 + +FUNCTION airline#highlighter#exec() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/highlighter.vim:219 +Called 594 times +Total time: 0.407801 + Self time: 0.108453 + +count total (s) self (s) + 594 0.001676 if pumvisible() + return + 594 0.001806 endif + 594 0.002122 let colors = a:colors + 594 0.002281 if len(colors) == 4 + 189 0.000761 call add(colors, '') + 594 0.001729 endif + " colors should always be string values + 594 0.010300 let colors = map(copy(colors), 'type(v:val) != type("") ? string(v:val) : v:val') + 594 0.001548 if s:is_win32term + let colors[2] = s:gui2cui(get(colors, 0, ''), get(colors, 2, '')) + let colors[3] = s:gui2cui(get(colors, 1, ''), get(colors, 3, '')) + 594 0.001187 endif + 594 0.228965 0.006326 let old_hi = airline#highlighter#get_highlight(a:group) + 594 0.004440 let new_hi = [colors[0], colors[1], printf('%s', colors[2]), printf('%s', colors[3]), colors[4]] + 594 0.029235 0.005218 let colors = s:CheckDefined(colors) + 594 0.017832 0.005028 if old_hi != new_hi || !s:hl_group_exists(a:group) + 108 0.041157 0.001269 let cmd = printf('hi %s%s', a:group, s:GetHiCmd(colors)) + 108 0.000243 try + 108 0.000707 exe cmd + catch /^Vim\%((\a\+)\)\=:E421:/ " color definition not found + let group=matchstr(v:exception, '\w\+\ze=') + let color=matchstr(v:exception, '=\zs\w\+') + let cmd=substitute(cmd, color, 'grey', 'g') + exe cmd + call airline#util#warning('color definition for group ' . a:group . ' not found, using grey as fallback') + catch + call airline#util#warning('Error when running command: '. cmd) + 108 0.000368 endtry + 108 0.000466 if has_key(s:hl_groups, a:group) + 108 0.000529 let s:hl_groups[a:group] = colors + 108 0.000227 endif + 594 0.001906 endif + +FUNCTION airline#util#stl_disabled() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/util.vim:196 +Called 9 times +Total time: 0.000702 + Self time: 0.000449 + +count total (s) self (s) + " setting the statusline is disabled, + " either globally, per window, or per buffer + " w:airline_disabled is deprecated! + 9 0.000583 0.000330 return get(g:, 'airline_disable_statusline', 0) || airline#util#getwinvar(a:winnr, 'airline_disable_statusline', 0) || airline#util#getwinvar(a:winnr, 'airline_disabled', 0) || airline#util#getbufvar(winbufnr(a:winnr), 'airline_disable_statusline', 0) + +FUNCTION 51_hl_group_exists() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/highlighter.vim:99 +Called 486 times +Total time: 0.012804 + Self time: 0.012804 + +count total (s) self (s) + 486 0.002305 if !hlexists(a:group) + return 0 + 486 0.002524 elseif empty(synIDattr(synIDtrans(hlID(a:group)), 'fg')) + return 0 + 486 0.000973 endif + 486 0.001073 return 1 + +FUNCTION airline#extensions#apply() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/extensions.vim:72 +Called 6 times +Total time: 0.001771 + Self time: 0.000954 + +count total (s) self (s) + 6 0.000032 let filetype_overrides = get(s:, 'filetype_overrides', {}) + 6 0.000045 call extend(filetype_overrides, get(g:, 'airline_filetype_overrides', {}), 'force') + + 6 0.000881 0.000063 if s:is_excluded_window() + return -1 + 6 0.000017 endif + + 6 0.000026 if &buftype == 'terminal' + let w:airline_section_x = '' + let w:airline_section_y = '' + 6 0.000017 endif + + 6 0.000030 if &previewwindow && empty(get(w:, 'airline_section_a', '')) + let w:airline_section_a = 'Preview' + let w:airline_section_b = '' + let w:airline_section_c = bufname(winbufnr(winnr())) + 6 0.000012 endif + + 6 0.000045 if has_key(filetype_overrides, &ft) && ((&filetype == 'help' && &buftype == 'help') || &filetype !~ 'help') + " for help files only override it, if the buftype is also of type 'help', + " else it would trigger when editing Vim help files + let args = filetype_overrides[&ft] + call airline#extensions#apply_left_override(args[0], args[1]) + 6 0.000012 endif + + 6 0.000024 if &buftype == 'help' + let w:airline_section_x = '' + let w:airline_section_y = '' + let w:airline_render_right = 1 + 6 0.000020 endif + + 6 0.000031 for item in items(s:filetype_regex_overrides) + if match(&ft, item[0]) >= 0 + call airline#extensions#apply_left_override(item[1][0], item[1][1]) + endif + 6 0.000012 endfor + +FUNCTION airline#builder#should_change_group() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/builder.vim:130 +Called 18 times +Total time: 0.014281 + Self time: 0.000860 + +count total (s) self (s) + 18 0.000082 if a:group1 == a:group2 + return 0 + 18 0.000040 endif + 18 0.006907 0.000211 let color1 = airline#highlighter#get_highlight(a:group1) + 18 0.006925 0.000200 let color2 = airline#highlighter#get_highlight(a:group2) + 18 0.000092 return color1[1] != color2[1] || color1[0] != color2[0] || color1[2] != color2[2] || color1[3] != color2[3] + +FUNCTION airline#themes#get_highlight() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/themes.vim:35 +Called 372 times +Total time: 0.142274 + Self time: 0.005828 + +count total (s) self (s) + 372 0.140548 0.004102 return call('airline#highlighter#get_highlight', [a:group] + a:000) + +FUNCTION airline#highlighter#get_highlight() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/highlighter.vim:68 +Called 1002 times +Total time: 0.372507 + Self time: 0.124818 + +count total (s) self (s) + " only check for the cterm reverse attribute + " TODO: do we need to check all modes (gui, term, as well)? + 1002 0.005445 let reverse = synIDattr(synIDtrans(hlID(a:group)), 'reverse', 'cterm') + 1002 0.005011 if get(g:, 'airline_highlighting_cache', 0) && has_key(s:hl_groups, a:group) + let res = s:hl_groups[a:group] + return reverse ? [ res[1], res[0], res[3], res[2], res[4] ] : res + 1002 0.002024 else + 1002 0.069696 0.008962 let ctermfg = s:get_syn(a:group, 'fg', 'cterm') + 1002 0.069205 0.009580 let ctermbg = s:get_syn(a:group, 'bg', 'cterm') + 1002 0.068462 0.009139 let guifg = s:get_syn(a:group, 'fg', 'gui') + 1002 0.068051 0.009044 let guibg = s:get_syn(a:group, 'bg', 'gui') + 1002 0.005193 let bold = synIDattr(synIDtrans(hlID(a:group)), 'bold') + 1002 0.002351 if reverse + let res = s:get_array(guibg, guifg, ctermbg, ctermfg, bold ? ['bold'] : a:000) + 1002 0.002021 else + 1002 0.019074 0.010074 let res = s:get_array(guifg, guibg, ctermfg, ctermbg, bold ? ['bold'] : a:000) + 1002 0.002230 endif + 1002 0.002172 endif + 1002 0.004928 let s:hl_groups[a:group] = res + 1002 0.002362 return res + +FUNCTION airline#util#shorten() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/util.vim:30 +Called 9 times +Total time: 0.000677 + Self time: 0.000416 + +count total (s) self (s) + 9 0.000418 0.000156 if airline#util#winwidth() < a:winwidth && len(split(a:text, '\zs')) > a:minwidth + 9 0.000042 if get(a:000, 0, 0) + " shorten from tail + return '…'.matchstr(a:text, '.\{'.a:minwidth.'}$') + 9 0.000017 else + " shorten from beginning of string + 9 0.000062 return matchstr(a:text, '^.\{'.a:minwidth.'}').'…' + endif + else + return a:text + endif + +FUNCTION airline#extensions#append_to_section() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/extensions.vim:54 +Called 3 times +Total time: 0.000108 + Self time: 0.000055 + +count total (s) self (s) + 3 0.000079 0.000027 call check_defined_section(a:name) + 3 0.000014 let w:airline_section_{a:name} .= a:value + +FUNCTION 55_get_section() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/extensions/default.vim:20 +Called 45 times +Total time: 0.003597 + Self time: 0.002537 + +count total (s) self (s) + 45 0.000213 if has_key(s:section_truncate_width, a:key) + 27 0.001086 0.000276 if airline#util#winwidth(a:winnr) < s:section_truncate_width[a:key] + 15 0.000032 return '' + 12 0.000024 endif + 30 0.000059 endif + 30 0.000135 let spc = g:airline_symbols.space + 30 0.000155 if !exists('g:airline_section_{a:key}') + return '' + 30 0.000056 endif + 30 0.000610 0.000361 let text = airline#util#getwinvar(a:winnr, 'airline_section_'.a:key, g:airline_section_{a:key}) + 30 0.000229 let [prefix, suffix] = [get(a:000, 0, '%('.spc), get(a:000, 1, spc.'%)')] + 30 0.000145 return empty(text) ? '' : prefix.text.suffix + +FUNCTION airline#extensions#searchcount#apply() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/extensions/searchcount.vim:15 +Called 3 times +Total time: 0.000147 + Self time: 0.000039 + +count total (s) self (s) + 3 0.000137 0.000029 call airline#extensions#append_to_section('y', '%{v:hlsearch ? airline#extensions#searchcount#status() : ""}') + +FUNCTION airline#util#wrap() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/util.vim:44 +Called 45 times +Total time: 0.000753 + Self time: 0.000753 + +count total (s) self (s) + 45 0.000212 if a:minwidth > 0 && airline#util#winwidth() < a:minwidth + return '' + 45 0.000080 endif + 45 0.000101 return a:text + +FUNCTION airline#extensions#fzf#inactive_apply() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/extensions/fzf.vim:37 +Called 3 times +Total time: 0.000102 + Self time: 0.000102 + +count total (s) self (s) + 3 0.000020 if getbufvar(a:2.bufnr, '&filetype') ==# 'fzf' + let spc = g:airline_symbols.space + call a:1.add_section('airline_a', spc.'FZF'.spc) + call a:1.add_section('airline_c', '') + return 1 + 3 0.000009 endif + +FUNCTION airline#highlighter#highlight_modified_inactive() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/highlighter.vim:205 +Called 12 times +Total time: 0.010674 + Self time: 0.000706 + +count total (s) self (s) + 12 0.000070 if getbufvar(a:bufnr, '&modified') + 8 0.000080 let colors = exists('g:airline#themes#{g:airline_theme}#palette.inactive_modified.airline_c') ? g:airline#themes#{g:airline_theme}#palette.inactive_modified.airline_c : [] + 4 0.000008 else + 4 0.000032 let colors = exists('g:airline#themes#{g:airline_theme}#palette.inactive.airline_c') ? g:airline#themes#{g:airline_theme}#palette.inactive.airline_c : [] + 12 0.000024 endif + + 12 0.000047 if !empty(colors) + 12 0.010139 0.000172 call airline#highlighter#exec('airline_c'.(a:bufnr).'_inactive', colors) + 12 0.000024 endif + +FUNCTION airline#util#is_popup_window() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/util.vim:214 +Called 3 times +Total time: 0.000059 + Self time: 0.000059 + +count total (s) self (s) + " Keep the statusline active if it's a popup window + 3 0.000018 if exists('*win_gettype') + 3 0.000019 return win_gettype(a:winnr) ==# 'popup' || win_gettype(a:winnr) ==# 'autocmd' + else + return airline#util#getwinvar(a:winnr, '&buftype', '') ==# 'popup' + endif + +FUNCTION airline#check_mode() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline.vim:227 +Called 18 times +Total time: 0.642331 + Self time: 0.005906 + +count total (s) self (s) + 18 0.000093 if !has_key(s:contexts, a:winnr) + return '' + 18 0.000048 endif + 18 0.000101 let context = s:contexts[a:winnr] + + 18 0.000093 if get(w:, 'airline_active', 1) + 9 0.000044 let m = mode(1) + " Refer :help mode() to see the list of modes + " NB: 'let mode' here refers to the display colour _groups_, + " not the literal mode's code (i.e., m). E.g., Select modes + " v, S and ^V use 'visual' since they are of similar ilk. + " Some modes do not get recognised for status line purposes: + " no, nov, noV, no^V, !, cv, and ce. + " Mode name displayed is handled in init.vim (g:airline_mode_map). + " + 9 0.000043 if m[0] ==# "i" + let mode = ['insert'] " Insert modes + submodes (i, ic, ix) + 9 0.000034 elseif m[0] == "R" + let mode = ['replace'] " Replace modes + submodes (R, Rc, Rv, Rx) (NB: case sensitive as 'r' is a mode) + 9 0.000091 elseif m[0] =~ '\v(v|V||s|S|)' + let mode = ['visual'] " Visual and Select modes (v, V, ^V, s, S, ^S)) + 9 0.000031 elseif m ==# "t" + let mode = ['terminal'] " Terminal mode (only has one mode (t)) + 9 0.000053 elseif m[0] =~ '\v(c|r|!)' + 3 0.000014 let mode = ['commandline'] " c, cv, ce, r, rm, r? (NB: cv and ce stay showing as mode entered from) + 6 0.000012 else + 6 0.000029 let mode = ['normal'] " Normal mode + submodes (n, niI, niR, niV; plus operator pendings no, nov, noV, no^V) + 9 0.000021 endif + 9 0.000056 if exists("*VMInfos") && !empty(VMInfos()) + " Vim plugin Multiple Cursors https://github.com/mg979/vim-visual-multi + let m = 'multi' + 9 0.000021 endif + " Adjust to handle additional modes, which don't display correctly otherwise + 9 0.000081 if index(['niI', 'niR', 'niV', 'ic', 'ix', 'Rc', 'Rv', 'Rx', 'multi'], m) == -1 + 9 0.000041 let m = m[0] + 9 0.000017 endif + 9 0.000047 let w:airline_current_mode = get(g:airline_mode_map, m, m) + 9 0.000019 else + 9 0.000046 let mode = ['inactive'] + 9 0.000048 let w:airline_current_mode = get(g:airline_mode_map, '__') + 18 0.000037 endif + + 18 0.000100 if g:airline_detect_modified && &modified + 9 0.000048 call add(mode, 'modified') + 18 0.000038 endif + + 18 0.000062 if g:airline_detect_paste && &paste + call add(mode, 'paste') + 18 0.000053 endif + + 18 0.000183 if g:airline_detect_crypt && exists("+key") && !empty(&key) + call add(mode, 'crypt') + 18 0.000054 endif + + 18 0.000075 if g:airline_detect_spell && &spell + call add(mode, 'spell') + 18 0.000054 endif + + 18 0.000070 if &readonly || ! &modifiable + call add(mode, 'readonly') + 18 0.000056 endif + + 18 0.000099 let mode_string = join(mode) + 18 0.000089 if get(w:, 'airline_lastmode', '') != mode_string + 12 0.010826 0.000153 call airline#highlighter#highlight_modified_inactive(context.bufnr) + 12 0.624811 0.000209 call airline#highlighter#highlight(mode, string(context.bufnr)) + 12 0.001294 0.000145 call airline#util#doautocmd('AirlineModeChanged') + 12 0.000056 let w:airline_lastmode = mode_string + 18 0.000043 endif + + 18 0.000046 return '' + +FUNCTION airline#extensions#term#inactive_apply() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/extensions/term.vim:39 +Called 3 times +Total time: 0.000256 + Self time: 0.000256 + +count total (s) self (s) + 3 0.000020 if getbufvar(a:2.bufnr, '&buftype') ==? 'terminal' + let sections = s:GetAirlineSection() + let spc = g:airline_symbols.space + call a:1.add_section_spaced('airline_a', sections[0]) + call a:1.add_section_spaced('airline_b', s:neoterm_id(a:2.bufnr)) + call a:1.add_section('airline_term', spc.s:termname(a:2.bufnr)) + call a:1.split() + call a:1.add_section('airline_y', '') + call a:1.add_section_spaced('airline_z', sections[1]) + return 1 + 3 0.000009 endif + +FUNCTION airline#parts#filetype() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/parts.vim:192 +Called 18 times +Total time: 0.000777 + Self time: 0.000252 + +count total (s) self (s) + 18 0.000720 0.000194 return (airline#util#winwidth() < 90 && strlen(&filetype) > 3) ? matchstr(&filetype, '...'). (&encoding is? 'utf-8' ? '…' : '>') : &filetype + +FUNCTION airline#parts#iminsert() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/parts.vim:172 +Called 9 times +Total time: 0.000217 + Self time: 0.000217 + +count total (s) self (s) + 9 0.000042 if g:airline_detect_iminsert && &iminsert && exists('b:keymap_name') + return toupper(b:keymap_name) + 9 0.000033 endif + 9 0.000031 return '' + +FUNCTION airline#update_tabline() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline.vim:301 +Called 21 times +Total time: 0.000484 + Self time: 0.000484 + +count total (s) self (s) + 21 0.000186 if get(g:, 'airline_statusline_ontop', 0) + call airline#extensions#tabline#redraw() + 21 0.000055 endif + +FUNCTION airline#builder#get_prev_group() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/builder.vim:37 +Called 36 times +Total time: 0.001404 + Self time: 0.001404 + +count total (s) self (s) + 36 0.000167 let x = a:i - 1 + 42 0.000132 while x >= 0 + 36 0.000162 let group = a:sections[x][0] + 36 0.000179 if group != '' && group != '|' + 30 0.000087 return group + 6 0.000015 endif + 6 0.000019 let x = x - 1 + 12 0.000046 endwhile + 6 0.000019 return '' + +FUNCTION airline#extensions#term#apply() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/extensions/term.vim:25 +Called 3 times +Total time: 0.000147 + Self time: 0.000147 + +count total (s) self (s) + 3 0.000016 if &buftype ==? 'terminal' || bufname(a:2.bufnr)[0] ==? '!' + let sections = s:GetAirlineSection() + let spc = g:airline_symbols.space + call a:1.add_section_spaced('airline_a', sections[0]) + call a:1.add_section_spaced('airline_b', s:neoterm_id(a:2.bufnr)) + call a:1.add_section('airline_term', spc.s:termname(a:2.bufnr)) + call a:1.split() + call a:1.add_section('airline_y', '') + call a:1.add_section_spaced('airline_z', sections[1]) + return 1 + 3 0.000009 endif + +FUNCTION 55_add_section() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/extensions/default.vim:47 +Called 33 times +Total time: 0.004790 + Self time: 0.001985 + +count total (s) self (s) + 33 0.000167 let condition = (a:key is# "warning" || a:key is# "error") && (v:version == 704 && !has("patch1511")) + " i have no idea why the warning section needs special treatment, but it's + " needed to prevent separators from showing up + 33 0.000492 0.000188 if ((a:key == 'error' || a:key == 'warning') && empty(s:get_section(a:context.winnr, a:key))) + 6 0.000017 return + 27 0.000050 endif + 27 0.000058 if condition + call a:builder.add_raw('%(') + 27 0.000083 endif + 27 0.002913 0.000412 call a:builder.add_section('airline_'.a:key, s:get_section(a:context.winnr, a:key)) + 27 0.000070 if condition + call a:builder.add_raw('%)') + 27 0.000083 endif + +FUNCTION airline#util#getwinvar() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/util.vim:84 +Called 60 times +Total time: 0.000520 + Self time: 0.000520 + +count total (s) self (s) + 60 0.000320 return getwinvar(a:winnr, a:key, a:def) + +FUNCTION 39_check_defined_section() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/extensions.vim:48 +Called 3 times +Total time: 0.000053 + Self time: 0.000053 + +count total (s) self (s) + 3 0.000014 if !exists('w:airline_section_{a:name}') + 3 0.000015 let w:airline_section_{a:name} = g:airline_section_{a:name} + 3 0.000006 endif + +FUNCTION 55_build_sections() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/extensions/default.vim:35 +Called 9 times +Total time: 0.006245 + Self time: 0.001455 + +count total (s) self (s) + 48 0.000145 for key in a:keys + 39 0.000178 if (key == 'warning' || key == 'error') && !a:context.active + 6 0.000012 continue + 33 0.000062 endif + 33 0.005100 0.000310 call s:add_section(a:builder, a:context, key) + 42 0.000115 endfor + +FUNCTION airline#extensions#po#apply() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/extensions/po.vim:64 +Called 3 times +Total time: 0.000070 + Self time: 0.000070 + +count total (s) self (s) + 3 0.000019 if &ft ==# 'po' + call airline#extensions#prepend_to_section('z', '%{airline#extensions#po#stats()}') + " Also reset the cache variable, if a window has been split, e.g. the winwidth changed + autocmd airline BufWritePost * call s:autocmd_handler() + autocmd airline WinEnter * call airline#extensions#po#on_winenter() + 3 0.000006 endif + +FUNCTION 39_is_excluded_window() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/extensions.vim:112 +Called 6 times +Total time: 0.000817 + Self time: 0.000817 + +count total (s) self (s) + 6 0.000029 for matchft in g:airline_exclude_filetypes + if matchft ==# &ft + return 1 + endif + 6 0.000016 endfor + + 24 0.000072 for matchw in g:airline_exclude_filenames + 18 0.000144 if matchstr(expand('%'), matchw) ==# matchw + return 1 + 18 0.000038 endif + 24 0.000047 endfor + + 6 0.000023 if g:airline_exclude_preview && &previewwindow + return 1 + 6 0.000017 endif + + 6 0.000018 return 0 + +FUNCTION airline#extensions#fzf#apply() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/extensions/fzf.vim:28 +Called 3 times +Total time: 0.000076 + Self time: 0.000076 + +count total (s) self (s) + 3 0.000014 if &filetype ==# 'fzf' + let spc = g:airline_symbols.space + call a:1.add_section('airline_a', spc.'FZF'.spc) + call a:1.add_section('airline_c', '') + return 1 + 3 0.000006 endif + +FUNCTION airline#parts#spell() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/parts.vim:147 +Called 9 times +Total time: 0.000825 + Self time: 0.000825 + +count total (s) self (s) + 9 0.000080 let spelllang = g:airline_detect_spelllang ? printf(" [%s]", toupper(substitute(&spelllang, ',', '/', 'g'))) : '' + 9 0.000046 if g:airline_detect_spell && (&spell || (exists('g:airline_spell_check_command') && eval(g:airline_spell_check_command))) + + if g:airline_detect_spelllang !=? '0' && g:airline_detect_spelllang ==? 'flag' + let spelllang = tolower(&spelllang) + if has_key(s:flags, spelllang) + return s:flags[spelllang] + elseif has_key(s:flags_noregion, spelllang) + return s:flags_noregion[spelllang] + endif + endif + + let winwidth = airline#util#winwidth() + if winwidth >= 90 + return g:airline_symbols.spell . spelllang + elseif winwidth >= 70 + return g:airline_symbols.spell + elseif !empty(g:airline_symbols.spell) + return split(g:airline_symbols.spell, '\zs')[0] + endif + 9 0.000029 endif + 9 0.000030 return '' + +FUNCTION airline#highlighter#highlight() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/highlighter.vim:255 +Called 12 times +Total time: 0.624602 + Self time: 0.090678 + +count total (s) self (s) + 12 0.000056 let bufnr = a:0 ? a:1 : '' + 12 0.000057 let p = g:airline#themes#{g:airline_theme}#palette + + " draw the base mode, followed by any overrides + 12 0.000105 let mapped = map(a:modes, 'v:val == a:modes[0] ? v:val : a:modes[0]."_".v:val') + 12 0.000058 let suffix = a:modes[0] == 'inactive' ? '_inactive' : '' + 12 0.000046 let airline_grouplist = [] + 12 0.000086 let buffers_in_tabpage = sort(tabpagebuflist()) + 12 0.000054 if exists("*uniq") + 12 0.000059 let buffers_in_tabpage = uniq(buffers_in_tabpage) + 12 0.000024 endif + " mapped might be something like ['normal', 'normal_modified'] + " if a group is in both modes available, only define the second + " that is how this was done previously overwrite the previous definition + 32 0.000106 for mode in reverse(mapped) + 20 0.000121 if exists('g:airline#themes#{g:airline_theme}#palette[mode]') + 18 0.000100 let dict = g:airline#themes#{g:airline_theme}#palette[mode] + 303 0.000922 for kvp in items(dict) + 285 0.001152 let mode_colors = kvp[1] + 285 0.000944 let name = kvp[0] + 285 0.001249 if name is# 'airline_c' && !empty(bufnr) && suffix is# '_inactive' + 5 0.000024 let name = 'airline_c'.bufnr + 285 0.000595 endif + " do not re-create highlighting for buffers that are no longer visible + " in the current tabpage + 285 0.001781 if name =~# 'airline_c\d\+' + 39 0.000266 let bnr = matchstr(name, 'airline_c\zs\d\+') + 0 + 39 0.000189 if bnr > 0 && index(buffers_in_tabpage, bnr) == -1 + continue + 39 0.000073 endif + 246 0.001363 elseif (name =~# '_to_') || (name[0:10] is# 'airline_tab' && !empty(suffix)) + " group will be redefined below at exec_separator + " or is not needed for tabline with '_inactive' suffix + " since active flag is 1 for builder) + 119 0.000274 continue + 166 0.000331 endif + 166 0.005601 0.001642 if s:group_not_done(airline_grouplist, name.suffix) + 132 0.092417 0.001492 call airline#highlighter#exec(name.suffix, mode_colors) + 166 0.000448 endif + + 166 0.000772 if !has_key(p, 'accents') + " work around a broken installation + " shouldn't actually happen, p should always contain accents + continue + 166 0.000337 endif + + 498 0.001751 for accent in keys(s:accents) + 332 0.001605 if !has_key(p.accents, accent) + continue + 332 0.000661 endif + 332 0.001675 let colors = copy(mode_colors) + 332 0.001603 if p.accents[accent][0] != '' + 166 0.000809 let colors[0] = p.accents[accent][0] + 332 0.000854 endif + 332 0.001477 if p.accents[accent][2] != '' + 166 0.000819 let colors[2] = p.accents[accent][2] + 332 0.000818 endif + 332 0.001366 if len(colors) >= 5 + 332 0.001646 let colors[4] = get(p.accents[accent], 4, '') + else + call add(colors, get(p.accents[accent], 4, '')) + 332 0.000679 endif + 332 0.011793 0.003760 if s:group_not_done(airline_grouplist, name.suffix.'_'.accent) + 264 0.185452 0.003171 call airline#highlighter#exec(name.suffix.'_'.accent, colors) + 332 0.000911 endif + 498 0.001294 endfor + 184 0.000377 endfor + + 18 0.000083 if empty(s:separators) + " nothing to be done + continue + 18 0.000036 endif + " TODO: optimize this + 180 0.000580 for sep in items(s:separators) + " we cannot check, that the group already exists, else the separators + " might not be correctly defined. But perhaps we can skip above groups + " that match the '_to_' name, because they would be redefined here... + 162 0.250763 0.002036 call exec_separator(dict, sep[1][0], sep[1][1], sep[1][2], suffix) + 180 0.000573 endfor + 20 0.000038 endif + 32 0.000086 endfor + +FUNCTION 51_exec_separator() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/highlighter.vim:189 +Called 186 times +Total time: 0.284366 + Self time: 0.017465 + +count total (s) self (s) + 186 0.000583 if pumvisible() + return + 186 0.000584 endif + 186 0.000909 let group = a:from.'_to_'.a:to.a:suffix + 186 0.073184 0.001851 let l:from = airline#themes#get_highlight(a:from.a:suffix) + 186 0.072986 0.002044 let l:to = airline#themes#get_highlight(a:to.a:suffix) + 186 0.000594 if a:inverse + 42 0.000226 let colors = [ l:from[1], l:to[1], l:from[3], l:to[3] ] + 144 0.000329 else + 144 0.000724 let colors = [ l:to[1], l:from[1], l:to[3], l:from[3] ] + 186 0.000362 endif + 186 0.000894 let a:dict[group] = colors + 186 0.126638 0.002011 call airline#highlighter#exec(group, colors) + +FUNCTION 51_group_not_done() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/highlighter.vim:32 +Called 498 times +Total time: 0.011991 + Self time: 0.011991 + +count total (s) self (s) + 498 0.002496 if index(a:list, a:name) == -1 + 396 0.001923 call add(a:list, a:name) + 396 0.000927 return 1 + 102 0.000351 else + 102 0.000386 if &vbs + echomsg printf("airline: group: %s already done, skipping", a:name) + 102 0.000364 endif + 102 0.000352 return 0 + endif + +FUNCTION airline#util#prepend() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/util.vim:65 +Called 108 times +Total time: 0.002083 + Self time: 0.002083 + +count total (s) self (s) + 108 0.000509 if a:minwidth > 0 && airline#util#winwidth() < a:minwidth + return '' + 108 0.000194 endif + 108 0.000512 return empty(a:text) ? '' : a:text.s:spc.g:airline_right_alt_sep.s:spc + +FUNCTION 6_on_cursor_moved() + Defined: ~/.local/share/nvim/lazy/vim-airline/plugin/airline.vim:87 +Called 3 times +Total time: 0.000122 + Self time: 0.000073 + +count total (s) self (s) + 3 0.000014 if winnr() != s:active_winnr || !exists('w:airline_active') + call s:on_window_changed('CursorMoved') + 3 0.000005 endif + 3 0.000070 0.000021 call airline#update_tabline() + +FUNCTION 51_CheckDefined() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/highlighter.vim:108 +Called 594 times +Total time: 0.024017 + Self time: 0.024017 + +count total (s) self (s) + " Checks, whether the definition of the colors is valid and is not empty or NONE + " e.g. if the colors would expand to this: + " hi airline_c ctermfg=NONE ctermbg=NONE + " that means to clear that highlighting group, therefore, fallback to Normal + " highlighting group for the cterm values + + " This only works, if the Normal highlighting group is actually defined, so + " return early, if it has been cleared + 594 0.002966 if !exists("g:airline#highlighter#normal_fg_hi") + let g:airline#highlighter#normal_fg_hi = synIDattr(synIDtrans(hlID('Normal')), 'fg', 'cterm') + 594 0.001226 endif + 594 0.002884 if empty(g:airline#highlighter#normal_fg_hi) || g:airline#highlighter#normal_fg_hi < 0 + 594 0.001521 return a:colors + endif + + for val in a:colors + if !empty(val) && val !=# 'NONE' + return a:colors + endif + endfor + " this adds the bold attribute to the term argument of the :hi command, + " but at least this makes sure, the group will be defined + let fg = g:airline#highlighter#normal_fg_hi + let bg = synIDattr(synIDtrans(hlID('Normal')), 'bg', 'cterm') + if empty(bg) || bg < 0 + " in case there is no background color defined for Normal + let bg = a:colors[3] + endif + return a:colors[0:1] + [fg, bg] + [a:colors[4]] + +FUNCTION 54_get_accented_line() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/builder.vim:163 +Called 30 times +Total time: 0.003196 + Self time: 0.003196 + +count total (s) self (s) + 30 0.000109 if a:self._context.active + " active window + 18 0.000057 let contents = [] + 18 0.000121 let content_parts = split(a:contents, '__accent') + 54 0.000173 for cpart in content_parts + 36 0.000187 let accent = matchstr(cpart, '_\zs[^#]*\ze') + 36 0.000170 call add(contents, cpart) + 54 0.000128 endfor + 18 0.000087 let line = join(contents, a:group) + 18 0.000114 let line = substitute(line, '__restore__', a:group, 'g') + 12 0.000025 else + " inactive window + 12 0.000169 let line = substitute(a:contents, '%#__accent[^#]*#', '', 'g') + 12 0.000087 let line = substitute(line, '%#__restore__#', '', 'g') + 30 0.000083 endif + 30 0.000102 return line + +FUNCTION airline#mode_changed() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline.vim:307 +Called 12 times +Total time: 0.000470 + Self time: 0.000283 + +count total (s) self (s) + " airline#visual_active + " Boolean: for when to get visual wordcount + " needed for the wordcount extension + 12 0.000084 let g:airline#visual_active = (mode() =~? '[vs]') + 12 0.000271 0.000084 call airline#update_tabline() + +FUNCTION airline#util#getbufvar() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/util.vim:73 +Called 9 times +Total time: 0.000078 + Self time: 0.000078 + +count total (s) self (s) + 9 0.000048 return getbufvar(a:bufnr, a:key, a:def) + +FUNCTION airline#highlighter#add_separator() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/highlighter.vim:184 +Called 24 times +Total time: 0.036203 + Self time: 0.000563 + +count total (s) self (s) + 24 0.000138 let s:separators[a:from.a:to] = [a:from, a:to, a:inverse] + 24 0.035944 0.000304 call exec_separator({}, a:from, a:to, a:inverse, '') + +FUNCTION 51_get_array() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/highlighter.vim:60 +Called 1002 times +Total time: 0.009000 + Self time: 0.009000 + +count total (s) self (s) + 1002 0.005834 return [ a:guifg, a:guibg, a:ctermfg, a:ctermbg, empty(a:opts) ? '' : join(a:opts, ',') ] + +FUNCTION airline#parts#crypt() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/parts.vim:61 +Called 9 times +Total time: 0.000123 + Self time: 0.000123 + +count total (s) self (s) + 9 0.000095 return g:airline_detect_crypt && exists("+key") && !empty(&key) ? g:airline_symbols.crypt : '' + +FUNCTION airline#update_statusline_inactive() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline.vim:179 +Called 3 times +Total time: 0.034447 + Self time: 0.000565 + +count total (s) self (s) + 3 0.000276 0.000046 if airline#util#stl_disabled(winnr()) + return + 3 0.000010 endif + 6 0.000026 for nr in a:range + 3 0.000263 0.000039 if airline#util#stl_disabled(nr) + continue + 3 0.000007 endif + 3 0.000020 call setwinvar(nr, 'airline_active', 0) + 3 0.000027 let context = { 'winnr': nr, 'active': 0, 'bufnr': winbufnr(nr) } + 3 0.000014 if get(g:, 'airline_inactive_alt_sep', 0) + call extend(context, { 'left_sep': g:airline_left_alt_sep, 'right_sep': g:airline_right_alt_sep }, 'keep') + 3 0.000007 endif + 3 0.000014 try + 3 0.033486 0.000060 call s:invoke_funcrefs(context, g:airline_inactive_funcrefs) + catch /^Vim\%((\a\+)\)\=:E48:/ + " Catch: Sandbox mode + " no-op + 3 0.000007 endtry + 6 0.000013 endfor + +FUNCTION airline#builder#new() + Defined: ~/.local/share/nvim/lazy/vim-airline/autoload/airline/builder.vim:234 +Called 6 times +Total time: 0.000324 + Self time: 0.000324 + +count total (s) self (s) + 6 0.000068 let builder = copy(s:prototype) + 6 0.000028 let builder._context = a:context + 6 0.000028 let builder._sections = [] + + 6 0.000099 call extend(builder._context, { 'left_sep': g:airline_left_sep, 'left_alt_sep': g:airline_left_alt_sep, 'right_sep': g:airline_right_sep, 'right_alt_sep': g:airline_right_alt_sep, }, 'keep') + 6 0.000021 return builder + +FUNCTIONS SORTED ON TOTAL TIME +count total (s) self (s) function + 18 0.642331 0.005906 airline#check_mode() + 12 0.624602 0.090678 airline#highlighter#highlight() + 594 0.407801 0.108453 airline#highlighter#exec() + 1002 0.372507 0.124818 airline#highlighter#get_highlight() + 186 0.284366 0.017465 51_exec_separator() + 4008 0.238689 51_get_syn() + 372 0.142274 0.005828 airline#themes#get_highlight() + 3 0.084138 0.000489 6_on_window_changed() + 3 0.083603 0.000445 airline#update_statusline() + 6 0.081832 0.000516 41_invoke_funcrefs() + 6 0.068256 0.009603 12() + 18 0.042920 0.000482 54_get_separator() + 108 0.039887 51_GetHiCmd() + 24 0.037922 0.001719 54_get_transitioned_separator() + 24 0.036203 0.000563 airline#highlighter#add_separator() + 3 0.034447 0.000565 airline#update_statusline_inactive() + 594 0.024017 51_CheckDefined() + 18 0.014281 0.000860 airline#builder#should_change_group() + 486 0.012804 51_hl_group_exists() + 6 0.012736 0.001585 airline#util#exec_funcrefs() + +FUNCTIONS SORTED ON SELF TIME +count total (s) self (s) function + 4008 0.238689 51_get_syn() + 1002 0.372507 0.124818 airline#highlighter#get_highlight() + 594 0.407801 0.108453 airline#highlighter#exec() + 12 0.624602 0.090678 airline#highlighter#highlight() + 108 0.039887 51_GetHiCmd() + 594 0.024017 51_CheckDefined() + 186 0.284366 0.017465 51_exec_separator() + 486 0.012804 51_hl_group_exists() + 498 0.011991 51_group_not_done() + 6 0.068256 0.009603 12() + 1002 0.009000 51_get_array() + 18 0.642331 0.005906 airline#check_mode() + 372 0.142274 0.005828 airline#themes#get_highlight() + 30 0.003196 54_get_accented_line() + 45 0.003597 0.002537 55_get_section() + 108 0.002083 airline#util#prepend() + 33 0.004790 0.001985 55_add_section() + 24 0.037922 0.001719 54_get_transitioned_separator() + 63 0.001614 airline#util#append() + 54 0.001597 airline#util#winwidth() + diff --git a/src/main.cc b/src/main.cc index d3cb907..ddd286f 100644 --- a/src/main.cc +++ b/src/main.cc @@ -2,11 +2,11 @@ #include "hardware/gpio.h" #include "hardware/i2c.h" -#include "pico/error.h" #include #include -#include +#include +#include #define ADDR 0x3c @@ -21,7 +21,7 @@ int main(void) { gpio_set_dir(25, GPIO_OUT); - i2c_init(i2c0, 115200); + i2c_init(i2c0, 400000); gpio_init(0); gpio_init(1); gpio_set_function(0, GPIO_FUNC_I2C); @@ -38,8 +38,12 @@ int main(void) { gpio_put(25, true); busy_wait_ms(failure ? 50 : 500); */ - disp.test(); - busy_wait_ms(10); + disp.fill(0); + disp.flush(); + busy_wait_ms(500); + disp.fill(0xFF); + disp.flush(); + busy_wait_ms(500); } return 0; @@ -47,6 +51,7 @@ int main(void) { static void write_cmd(uint8_t cmd) { uint8_t buf[2] = {0x80, cmd}; + if (i2c_write_timeout_us(i2c0, ADDR, buf, 2, false, 1000000) < 0) { failure = true; printf("TX fail\n"); @@ -55,19 +60,9 @@ static void write_cmd(uint8_t cmd) { } } -static void write_data(uint8_t *data, size_t len) { - if (i2c_write_timeout_us(i2c0, ADDR, data, len, false, 1000000) < 0) { - failure = true; - printf("data fail\n"); - } else { - printf("data succ\n"); - } -} - - ssd1306::ssd1306() { write_cmd(SET_DISP | 0x00); // Off - // + write_cmd(SET_MUX_RATIO); // The height write_cmd(63); // The height @@ -90,7 +85,7 @@ ssd1306::ssd1306() { write_cmd(0x80); write_cmd(SET_PRECHARGE); - write_cmd(0xF1); + write_cmd(0x22); write_cmd(SET_CHARGE_PUMP); write_cmd(0x14); @@ -99,19 +94,48 @@ ssd1306::ssd1306() { write_cmd(SET_DISP | 0x01); + set_coordinates(0, 127, 0, 7); + write_cmd(SET_MEM_ADDR); write_cmd(0x00); // Horizontal - write_cmd(SET_COL_ADDR); - write_cmd(0); - write_cmd(127); - write_cmd(SET_PAGE_ADDR); - write_cmd(0); - write_cmd(0x63); + for(size_t i = 0; i < (128*8); i++) { + uint8_t test_buf[] = {0x40, 0x00}; + i2c_write_timeout_us(i2c0, ADDR, test_buf, 2, false, 10000000); + } } void ssd1306::test() { static bool flip = true; - uint8_t buf[2] = {0x40, 0xFF}; - write_data(buf, 2); + fill(flip?0xFF:0x00); + flip = !flip; + flush(); +} + +void ssd1306::fill(uint8_t val) { + for(size_t i = 1; i < sizeof(m_display_buffer); i++) { + m_display_buffer[i] = val; + } +} + +void ssd1306::set_coordinates(uint8_t start_x, uint8_t end_x, uint8_t start_y, uint8_t end_y){ + write_cmd(SET_COL_ADDR); + write_cmd(start_x); + write_cmd(end_x); + write_cmd(SET_PAGE_ADDR); + write_cmd(start_y); + write_cmd(end_y); +} + +void ssd1306::flush() { + set_coordinates(0, 127, 0, 7); + write_cmd(SET_MEM_ADDR); + write_cmd(0x00); // Horizontal + + if (i2c_write_timeout_us(i2c0, ADDR, m_display_buffer, sizeof(m_display_buffer), false, 1000000) < 0) { + failure = true; + printf("data fail\n"); + } else { + printf("data succ\n"); + } } diff --git a/src/main.hh b/src/main.hh index c093401..dee4461 100644 --- a/src/main.hh +++ b/src/main.hh @@ -21,11 +21,22 @@ #define SET_VCOM_DESEL (0xDB) #define SET_CHARGE_PUMP (0x8D) +#define WIDTH 128 +#define HEIGHT 64 + class ssd1306 { +private: + uint8_t m_display_buffer[WIDTH*(HEIGHT/8)+1] = {0x40}; public: ssd1306(); void poweron(); void test(); + + void fill(uint8_t val); + + void flush(); + + void set_coordinates(uint8_t start_x, uint8_t end_x, uint8_t start_y, uint8_t end_y); };