fixed some small bugs
This commit is contained in:
parent
f0795ceb75
commit
3e387af21a
218
.vimrc
218
.vimrc
@ -1,218 +0,0 @@
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => General
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Map leader
|
||||
let mapleader=","
|
||||
" Automatic reloading
|
||||
autocmd! bufwritepost .vimrc source %
|
||||
set autoread
|
||||
|
||||
" Copy & Paste
|
||||
set pastetoggle=<F2>
|
||||
set clipboard=unnamedplus
|
||||
set mouse=a "(alt + click)
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Config
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
set so=7
|
||||
set cmdheight=2
|
||||
set hid
|
||||
set backspace=eol,start,indent
|
||||
set whichwrap+=<,>,h,l
|
||||
set ignorecase
|
||||
set hlsearch
|
||||
set incsearch
|
||||
set lazyredraw
|
||||
set magic
|
||||
set showmatch
|
||||
set mat=2
|
||||
set splitbelow " new splits are down
|
||||
set splitright " new vsplits are to the right
|
||||
set history=700
|
||||
"
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Text
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
set list
|
||||
set listchars=tab:>-,trail:- " show tabs and trailing
|
||||
set smartcase
|
||||
set smartindent
|
||||
set smarttab
|
||||
set expandtab
|
||||
set showcmd
|
||||
set number
|
||||
set linebreak
|
||||
set textwidth=80
|
||||
set cindent
|
||||
set shiftwidth=4
|
||||
set softtabstop=4
|
||||
set autoread
|
||||
set tabstop=4
|
||||
set columns=80
|
||||
set ai "Auto indent
|
||||
set si "Smart indent
|
||||
set wrap "Wrap lines
|
||||
set colorcolumn=80
|
||||
|
||||
filetype plugin indent on
|
||||
|
||||
inoremap { {}<Left>
|
||||
inoremap {<CR> {<CR>}<Esc>O
|
||||
inoremap {{ {
|
||||
inoremap {} {}
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Colors and Fonts
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
filetype indent on
|
||||
filetype plugin indent on
|
||||
filetype on
|
||||
filetype plugin on
|
||||
syntax on
|
||||
set grepprg=grep\ -nH\ $*
|
||||
|
||||
syntax on
|
||||
set t_Co=256
|
||||
colorscheme mustang
|
||||
set encoding=utf8
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Folding
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
set foldenable " Turn on folding
|
||||
set foldmethod=marker
|
||||
autocmd FileType c setlocal foldmethod=syntax
|
||||
set foldlevel=1
|
||||
set foldlevel=100 " Don't autofold anything (but I can still fold manually)
|
||||
set foldnestmax=1 " I only like to fold outer functions
|
||||
set foldopen=block,hor,mark,percent,quickfix,tag " what movements open folds
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Menu
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
set wildmenu
|
||||
set wildmode=list:longest,full
|
||||
set wildignore=*.o,*~,*.pyc
|
||||
set wildignore+=*.pdf,*.pyo,*.pyc,*.zip,*.so,*.swp,*.dll,*.o,*.DS_Store,*.obj,*.bak,*.exe,*.pyc,*.jpg,*.gif,*.png,*.a
|
||||
set wildignore+=.git\*,.hg\*,.svn\*.o,*~,*pyc
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Backup
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
set nobackup
|
||||
set nowb
|
||||
set noswapfile
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Mapping
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Remove arrow keys
|
||||
noremap <Up> <NOP>
|
||||
noremap <Down> <NOP>
|
||||
noremap <Left> <NOP>
|
||||
noremap <Right> <NOP>
|
||||
|
||||
" move by visual line
|
||||
nnoremap j gj
|
||||
nnoremap k gk
|
||||
xnoremap j gj
|
||||
xnoremap k gk
|
||||
|
||||
nnoremap J 5j
|
||||
nnoremap K 5k
|
||||
xnoremap J 5j
|
||||
xnoremap K 5k
|
||||
|
||||
" copy/paste replaced
|
||||
map <Leader>f c<C-r>0<ESC>
|
||||
vmap <Leader>y "+y
|
||||
vmap <Leader>d "+d
|
||||
vmap <Leader>P "+p
|
||||
|
||||
" use shell with ctrl-z
|
||||
map <C-Z> :shell<CR>
|
||||
|
||||
" Open/Close fold
|
||||
nnoremap <space> za
|
||||
|
||||
" Remove highlight after search
|
||||
noremap <Leader>D :nohl<CR>
|
||||
|
||||
"Quit & Save
|
||||
noremap <Leader>w :w!<CR>
|
||||
noremap <Leader>q :wq<CR>
|
||||
noremap <Leader>Q :q!<CR>
|
||||
nnoremap <leader>s :mksession<CR>
|
||||
|
||||
" Building
|
||||
map <Leader>c :make<Return> :copen<Return>
|
||||
map <Leader>d :make debug<Return> :copen<Return>
|
||||
map <Leader>p :w !python<Return> :copen<Return>
|
||||
map <Leader>cn :cn <CR>
|
||||
map <Leader>cq :ccl <CR>
|
||||
|
||||
" Tabs
|
||||
map <Leader>n <esc>:tabprevious<CR>
|
||||
map <Leader>m <esc>:tabnext<CR>
|
||||
map <Leader>b <esc>:tabnew<CR>
|
||||
|
||||
" Shifting
|
||||
vnoremap < <gv
|
||||
vnoremap > >gv
|
||||
|
||||
" Remapping Esc
|
||||
inoremap jj <Esc>
|
||||
|
||||
"Whitespaces
|
||||
nnoremap <Leader>r :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar>:nohl<CR>
|
||||
|
||||
""""""""""""""""""""""""""""""
|
||||
" => Status line
|
||||
""""""""""""""""""""""""""""""
|
||||
set laststatus=2
|
||||
set statusline+=%F\ [%lL\:%cC]
|
||||
|
||||
""""""""""""""""""""""""""""""
|
||||
" => Plugin
|
||||
""""""""""""""""""""""""""""""
|
||||
execute pathogen#infect()
|
||||
let g:ctrlp_max_height = 30
|
||||
|
||||
" CtrlP
|
||||
let g:ctrlp_map = '<c-p>'
|
||||
let g:ctrlp_cmd = 'CtrlP'
|
||||
let g:ctrlp_follow_symlinks = 1
|
||||
let g:ctrlp_match_window_bottom = 1
|
||||
let g:ctrlp_match_window_reversed = 1
|
||||
let g:ctrlp_max_depth = 100
|
||||
let g:ctrlp_max_files = 100000
|
||||
let g:ctrlp_max_height = 30
|
||||
let g:ctrlp_working_path_mode = 'ra'
|
||||
let g:ctrlp_use_caching = 1
|
||||
let g:ctrlp_show_hidden = 1
|
||||
let g:ctrlp_switch_buffer = 0 "new tab
|
||||
|
||||
" go
|
||||
let g:go_disable_autoinstall = 1
|
||||
|
||||
"Rainbow
|
||||
nnoremap <Leader>t :RainbowParenthesesToggle<CR>
|
||||
|
||||
" Syntastic
|
||||
let g:syntastic_check_on_open=1
|
||||
let g:syntastic_enable_signs=1
|
||||
let g:syntastic_c_check_header = 1
|
||||
let g:syntastic_c_auto_refresh_includes = 1
|
||||
let g:syntastic_c_include_dirs = ['includes']
|
||||
let g:syntastic_c_checkers=['make','gcc']
|
||||
|
||||
" Multiple cursor
|
||||
let g:multi_cursor_next_key='<C-n>'
|
||||
let g:multi_cursor_prev_key='<C-m>'
|
||||
let g:multi_cursor_skip_key='<C-x>'
|
||||
let g:multi_cursor_quit_key='<Esc>'
|
||||
|
||||
" Switch
|
||||
nnoremap - :Switch<CR>
|
||||
|
97
demo/xlib.c
97
demo/xlib.c
@ -11,6 +11,7 @@
|
||||
#include "../gui.h"
|
||||
|
||||
/* macros */
|
||||
#define MAX_BUFFER 64
|
||||
#define MAX_MEMORY (8 * 1024)
|
||||
#define MAX_DEPTH 8
|
||||
#define MAX_PANEL 4
|
||||
@ -60,6 +61,26 @@ struct XWindow {
|
||||
XSurface surface;
|
||||
};
|
||||
|
||||
struct demo {
|
||||
gui_char in_buf[MAX_BUFFER];
|
||||
gui_size in_len;
|
||||
gui_bool in_act;
|
||||
gui_char cmd_buf[MAX_BUFFER];
|
||||
gui_size cmd_len;
|
||||
gui_bool cmd_act;
|
||||
gui_bool check;
|
||||
gui_int option;
|
||||
gui_float slider;
|
||||
gui_size prog;
|
||||
gui_int spinner;
|
||||
gui_bool spin_act;
|
||||
gui_size item_cur;
|
||||
gui_tab tab;
|
||||
gui_group group;
|
||||
gui_shelf shelf;
|
||||
gui_size current;
|
||||
};
|
||||
|
||||
static void
|
||||
die(const char *fmt, ...)
|
||||
{
|
||||
@ -171,6 +192,8 @@ surface_draw_circle(XSurface *surf, int x, int y, unsigned int radius, unsigned
|
||||
{
|
||||
unsigned int d = radius * 2;
|
||||
XSetForeground(surf->dpy, surf->gc, c);
|
||||
x -= (int)radius;
|
||||
y -= (int)radius;
|
||||
XFillArc(surf->dpy, surf->drawable, surf->gc, x, y, d, d, 0, 360 * 64);
|
||||
}
|
||||
|
||||
@ -389,6 +412,54 @@ gui_draw(XSurface *surf, const struct gui_output *out)
|
||||
execute(surf, out->list[i]);
|
||||
}
|
||||
|
||||
static gui_bool
|
||||
demo_panel(struct gui_context *ctx, struct gui_panel *panel, struct demo *demo)
|
||||
{
|
||||
enum {PLOT, HISTO};
|
||||
const char *shelfs[] = {"Histogram", "Lines"};
|
||||
const gui_float values[] = {8.0f, 15.0f, 20.0f, 12.0f, 30.0f};
|
||||
const char *items[] = {"Fist", "Pistol", "Shotgun", "Railgun", "BFG"};
|
||||
gui_bool running;
|
||||
|
||||
running = gui_begin_panel(ctx, panel, "Demo",
|
||||
GUI_PANEL_CLOSEABLE|GUI_PANEL_MINIMIZABLE|GUI_PANEL_SCALEABLE|
|
||||
GUI_PANEL_MOVEABLE|GUI_PANEL_BORDER);
|
||||
|
||||
/* Tabs */
|
||||
gui_panel_layout(panel, 100, 1);
|
||||
gui_panel_tab_begin(panel, &demo->tab, "Difficulty");
|
||||
gui_panel_layout(&demo->tab, 30, 2);
|
||||
if (gui_panel_option(&demo->tab, "easy", demo->option == 0)) demo->option = 0;
|
||||
if (gui_panel_option(&demo->tab, "hard", demo->option == 1)) demo->option = 1;
|
||||
if (gui_panel_option(&demo->tab, "normal", demo->option == 2)) demo->option = 2;
|
||||
if (gui_panel_option(&demo->tab, "godlike", demo->option == 3)) demo->option = 3;
|
||||
gui_panel_tab_end(panel, &demo->tab);
|
||||
|
||||
/* Shelf */
|
||||
gui_panel_layout(panel, 200, 2);
|
||||
demo->current = gui_panel_shelf_begin(panel, &demo->shelf, shelfs, LEN(shelfs), demo->current);
|
||||
gui_panel_layout(&demo->shelf, 100, 1);
|
||||
if (demo->current == PLOT) {
|
||||
gui_panel_histo(&demo->shelf, values, LEN(values));
|
||||
} else {
|
||||
gui_panel_plot(&demo->shelf, values, LEN(values));
|
||||
}
|
||||
gui_panel_shelf_end(panel, &demo->shelf);
|
||||
|
||||
/* Group */
|
||||
gui_panel_group_begin(panel, &demo->group, "Options");
|
||||
gui_panel_layout(&demo->group, 30, 1);
|
||||
if (gui_panel_button_text(&demo->group, "button", GUI_BUTTON_DEFAULT))
|
||||
fprintf(stdout, "button pressed!\n");
|
||||
demo->check = gui_panel_check(&demo->group, "advanced", demo->check);
|
||||
demo->slider = gui_panel_slider(&demo->group, 0, demo->slider, 10, 1.0f);
|
||||
demo->prog = gui_panel_progress(&demo->group, demo->prog, 100, gui_true);
|
||||
gui_panel_group_end(panel, &demo->group);
|
||||
|
||||
gui_end_panel(ctx, panel, NULL);
|
||||
return running;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
@ -396,10 +467,8 @@ main(int argc, char *argv[])
|
||||
long started;
|
||||
gui_bool running = gui_true;
|
||||
|
||||
XWindow xw;
|
||||
XSurface *surf;
|
||||
XFont *xfont;
|
||||
|
||||
/* GUI */
|
||||
struct demo demo;
|
||||
struct gui_input in;
|
||||
struct gui_config config;
|
||||
struct gui_memory memory;
|
||||
@ -409,6 +478,10 @@ main(int argc, char *argv[])
|
||||
struct gui_output output;
|
||||
|
||||
/* Window */
|
||||
XWindow xw;
|
||||
XSurface *surf;
|
||||
XFont *xfont;
|
||||
|
||||
UNUSED(argc); UNUSED(argv);
|
||||
memset(&xw, 0, sizeof xw);
|
||||
xw.dpy = XOpenDisplay(NULL);
|
||||
@ -442,7 +515,13 @@ main(int argc, char *argv[])
|
||||
font.height = (gui_float)xfont->height;
|
||||
font.width = font_get_text_width;
|
||||
gui_default_config(&config);
|
||||
panel = gui_new_panel(ctx, 50, 50, 200, 400, &config, &font);
|
||||
panel = gui_new_panel(ctx, 50, 50, 500, 320, &config, &font);
|
||||
|
||||
memset(&demo, 0, sizeof(demo));
|
||||
demo.tab.minimized = gui_true;
|
||||
demo.spinner = 250;
|
||||
demo.slider = 2.0f;
|
||||
demo.prog = 60;
|
||||
|
||||
while (running) {
|
||||
/* Input */
|
||||
@ -462,13 +541,7 @@ main(int argc, char *argv[])
|
||||
|
||||
/* GUI */
|
||||
gui_begin(ctx, (gui_float)xw.width, (gui_float)xw.height);
|
||||
running = gui_begin_panel(ctx, panel, "Demo",
|
||||
GUI_PANEL_CLOSEABLE|GUI_PANEL_MINIMIZABLE|GUI_PANEL_SCALEABLE|
|
||||
GUI_PANEL_MOVEABLE|GUI_PANEL_BORDER);
|
||||
gui_panel_layout(panel, 30, 1);
|
||||
if (gui_panel_button_text(panel, "button", GUI_BUTTON_DEFAULT))
|
||||
fprintf(stdout, "button pressed!\n");
|
||||
gui_end_panel(ctx, panel, NULL);
|
||||
running = demo_panel(ctx, panel, &demo);
|
||||
gui_end(ctx, &output, NULL);
|
||||
|
||||
/* Draw */
|
||||
|
15
gui.c
15
gui.c
@ -738,12 +738,12 @@ gui_widget_toggle(struct gui_command_buffer *buffer, const struct gui_toggle *to
|
||||
|
||||
select_x = toggle->x + toggle->pad_x;
|
||||
select_y = toggle->y + toggle->pad_y;
|
||||
select_size = toggle->h - 2 * toggle->pad_y;
|
||||
select_size = font->height + 2 * toggle->pad_y;
|
||||
|
||||
cursor_pad = select_size / 8;
|
||||
cursor_size = select_size - 2 * cursor_pad;
|
||||
cursor_x = select_x + cursor_pad;
|
||||
cursor_y = select_y + cursor_pad;
|
||||
cursor_size = select_size - 2 * cursor_pad;
|
||||
|
||||
if (in && !in->mouse_down && in->mouse_clicked)
|
||||
if (INBOX(in->mouse_clicked_pos.x, in->mouse_clicked_pos.y,
|
||||
@ -757,9 +757,14 @@ gui_widget_toggle(struct gui_command_buffer *buffer, const struct gui_toggle *to
|
||||
gui_buffer_push_rect(buffer, cursor_x, cursor_y, cursor_size, cursor_size,
|
||||
toggle->foreground);
|
||||
} else {
|
||||
select_x += select_size/2;
|
||||
select_y += select_size/2;
|
||||
gui_buffer_push_circle(buffer, select_x, select_y, select_size/2, toggle->background);
|
||||
if (toggle_active)
|
||||
if (toggle_active) {
|
||||
cursor_x += cursor_size / 2;
|
||||
cursor_y += cursor_size / 2;
|
||||
gui_buffer_push_circle(buffer, cursor_x, cursor_y, cursor_size/2, toggle->foreground);
|
||||
}
|
||||
}
|
||||
|
||||
if (font && toggle->text && toggle->length) {
|
||||
@ -773,7 +778,7 @@ gui_widget_toggle(struct gui_command_buffer *buffer, const struct gui_toggle *to
|
||||
text.length = toggle->length;
|
||||
text.align = GUI_TEXT_LEFT;
|
||||
text.font = font->user;
|
||||
text.background = toggle->background;
|
||||
text.background = toggle->foreground;
|
||||
text.foreground = toggle->font;
|
||||
gui_widget_text(buffer, &text, font);
|
||||
}
|
||||
@ -2099,7 +2104,6 @@ gui_panel_plot(struct gui_panel *panel, const gui_float *values, gui_size count)
|
||||
plot.pad_y = config->item_padding.y;
|
||||
plot.value_count = count;
|
||||
plot.values = values;
|
||||
|
||||
plot.background = config->colors[GUI_COLOR_PLOT];
|
||||
plot.foreground = config->colors[GUI_COLOR_PLOT_LINES];
|
||||
plot.highlight = config->colors[GUI_COLOR_PLOT_HIGHLIGHT];
|
||||
@ -2132,7 +2136,6 @@ gui_panel_histo(struct gui_panel *panel, const gui_float *values, gui_size count
|
||||
histo.pad_y = config->item_padding.y;
|
||||
histo.values = values;
|
||||
histo.value_count = count;
|
||||
|
||||
histo.background = config->colors[GUI_COLOR_HISTO];
|
||||
histo.foreground = config->colors[GUI_COLOR_HISTO_BARS];
|
||||
histo.negative = config->colors[GUI_COLOR_HISTO_NEGATIVE];
|
||||
|
11
gui.h
11
gui.h
@ -53,7 +53,6 @@ enum {gui_false, gui_true};
|
||||
enum gui_heading {GUI_UP, GUI_RIGHT, GUI_DOWN, GUI_LEFT};
|
||||
struct gui_color {gui_byte r,g,b,a;};
|
||||
struct gui_colorf {gui_float r,g,b,a;};
|
||||
struct gui_texCoord {gui_float u,v;};
|
||||
struct gui_vec2 {gui_float x,y;};
|
||||
struct gui_rect {gui_float x,y,w,h;};
|
||||
struct gui_key {gui_bool down, clicked;};
|
||||
@ -211,7 +210,6 @@ struct gui_image {
|
||||
gui_float w, h;
|
||||
gui_float pad_x, pad_y;
|
||||
struct gui_color color;
|
||||
struct gui_texCoord uv[2];
|
||||
gui_texture texture;
|
||||
struct gui_color background;
|
||||
};
|
||||
@ -432,8 +430,7 @@ gui_bool gui_widget_button_text(struct gui_command_buffer*, const struct gui_but
|
||||
gui_bool gui_widget_button_triangle(struct gui_command_buffer*, struct gui_button*,
|
||||
enum gui_heading, const struct gui_input*);
|
||||
gui_bool gui_widget_button_icon(struct gui_command_buffer*, struct gui_button*,
|
||||
gui_texture, struct gui_texCoord from, struct gui_texCoord to,
|
||||
const struct gui_input*);
|
||||
gui_texture, struct gui_rect *source, const struct gui_input*);
|
||||
gui_bool gui_widget_toggle(struct gui_command_buffer*, const struct gui_toggle*,
|
||||
gui_bool active, const struct gui_font*, const struct gui_input*);
|
||||
gui_float gui_widget_slider(struct gui_command_buffer*, const struct gui_slider*,
|
||||
@ -469,8 +466,8 @@ gui_bool gui_panel_button_text(struct gui_panel*, const char*, enum gui_button_b
|
||||
gui_bool gui_panel_button_color(struct gui_panel*, const struct gui_color, enum gui_button_behavior);
|
||||
gui_bool gui_panel_button_triangle(struct gui_panel*, enum gui_heading, enum gui_button_behavior);
|
||||
gui_bool gui_panel_button_toggle(struct gui_panel*, const char*, gui_bool value);
|
||||
gui_bool gui_panel_button_icon(struct gui_panel*, gui_texture, struct gui_texCoord from,
|
||||
struct gui_texCoord to, enum gui_button_behavior);
|
||||
gui_bool gui_panel_button_icon(struct gui_panel*, gui_texture, const struct gui_rect*,
|
||||
enum gui_button_behavior);
|
||||
gui_float gui_panel_slider(struct gui_panel*, gui_float min, gui_float val,
|
||||
gui_float max, gui_float step);
|
||||
gui_size gui_panel_progress(struct gui_panel*, gui_size cur, gui_size max,
|
||||
@ -491,7 +488,7 @@ void gui_panel_group_begin(gui_group*, gui_group*, const char *title);
|
||||
void gui_panel_group_end(gui_group*, gui_group* tab);
|
||||
gui_size gui_panel_shelf_begin(gui_shelf*, gui_shelf *shelf, const char *tabs[],
|
||||
gui_size size, gui_size active);
|
||||
void gui_panel_shelf_end(gui_shelf*, gui_shelf *shelf);
|
||||
void gui_panel_shelf_end(struct gui_panel*, gui_shelf *shelf);
|
||||
|
||||
/* Context */
|
||||
struct gui_context;
|
||||
|
Loading…
Reference in New Issue
Block a user