zoukankan      html  css  js  c++  java
  • Code::Blocks项目配置基础

    File 菜单

    New :新建( Empty file/file 、 class 、 project 、 build target ) 。

    Recent projects/files :近期打开的项目 文件 。

    Import projects : Dev-C++ Project 、 VC6 dsw/dsp 、 VC8 vcproj/sln 

    Ctrl+Shift+S : Save all files 

    Save workspace (as) :将多个项目组织成一个工作空间。类似 VC  dsw/sln 

    Properties :文件信息 。

    Ctrl+W : close current file (关闭当前文件) 。

    Ctrl+Shift+W : close all files (关闭全部打开的文件) 。

    Ctrl+Q : 退出 Code::Blocks 

     

    View 菜单

    Shift+F2 :显示 / 隐藏左側的 Management 

    F2 : 显示 / 隐藏底端的 Logs & Others 

     

    Edit 菜单

    File encoding :在状态栏有当前文件的编码格式信息。

    End of line mode :注意默觉得 LF  '/n' )。在 MS 中打开须要先用相关工具( UE  VS2005 )转换成 CRLF (“ /r/n” )。

     

    F11  swap header/source (切换头文件和实现文件)。

     

    Ctrl+Shift+C/Toggle Comment  Comment (凝视, C++ 风格: // )。

    Ctrl+Shift+X : Uncomment (取消凝视)。

    Stream Comment : 块凝视, C 风格: /**/ 

     

    Ctrl+J  Auto-Complete (自己主动补齐keyword代码框架,比如 while (); )。

    Ctrl+Shift+B : 括号匹配(类似 VC 的 Ctrl+] ) 。

     

    Ctrl+Space : Complete code (完毕单词) , 该快捷键提供输入仅仅能提示 。 Ctrl+Space 与 SCIM 冲突。

    Ctrl+Shift+Space : Show call tip (调用提示) 。

     

    Search 菜单

    查找替换编辑功能

    Ctrl+F : Find (当前文件查找)。

    Ctrl+Shift+F  Find in files (支持 Workspace/Project/Directory 级别查找)。

    F3/Shift+F3 : Find Next/Previous (上下查找)。

     

    Ctrl+R : Replace (当前文件替换)。

    Ctrl +Shift +R  Replace in files (支持 Workspace/Project/Directory 级别替换)。

     

    Goto : 定位导航功能( line  function  declaration/implementation )。

    Ctrl+. : Goto implementation ,类似 VC  F12 

    Ctrl+Shift+.  Goto declaration ,类似 VC  Shift+F12 

    Ctrl+ Al t+. : Goto include file 。配合 F11 使用。

     

    Project 菜单

    直接在側边栏 Management 右击项目名称,重点关注项目的“ properties” 和“ build options” 

     1  Project properties

    Project settings→Pre compiled headers :指定是否使用预编译处理器生成 PCH 

    Project settings→Project dependencies :指定对工作空间内其它项目的依赖关系。

     2  Project build options :编译链接选项。

    Compiler settings→ Compiler flags :编译链接命令开关   -p ,- g (要求编译器生成调试信息 ) 

    Compiler settings→ Other options :一般为 pkg-config  --cflags 头文件 位置。

    Compiler settings→#define  预处理器 preprocessor ,比如 _UNIX  _POSIX 等。

    Linker settings→ L ink libraries  附加包括库 

    Linker settings→ Other l ink er libraries  一般为 pkg-config 的— clibs 库文件 位置。

    Search directories  附加 头文件( Compiler  包括文件夹  附加 库文件( linker  包括文件夹  相对 *.cbp 路径 

    Pre/post build steps  生成事件前 / 后处理 

    Custom variables :用户自己定义宏变量 

    Make” commands 

    Build targets :可指定 platform (平台)、 type (项目类型)、 output filename (输出文件,相对 *.cbp 路径)、 execution working dir (工作文件夹,相对 *.cbp 路径)、 objects output dir (目标文件输出文件夹,相对 *.cbp 路径)。

    Add new virtual folder :加入虚拟目录分类管理源码文件。

    Project Notes :加入项目说明。

    Project tree :调整项目在工作空间中的树结构。

    Ctrl+Shift+ 上 下:调整顺序。

    Alt+F5/F6 :调整当前 激活 项目, Alt+F5 与 ubuntu 系统恢复窗体快捷键冲突。

     

    Build 菜单

    Ctrl +Shift+F9  compile current file (编译当前文件,类似 VC  Ctrl+F7 )。

    Ctrl+F9 : build (编译链接,类似 VC  F7 )。

    F9 : buiid and run (编译链接执行。类似 VC  Ctrl+F5 )。

    Ctrl+F 10 : run (执行)。

    Ctrl+F11 : rebuild (又一次编译链接)。

     

    Clean 菜单: 清理项目。

    Errors 菜单: Alt+F1/Alt+F2 (查看错误)。

    Select Target 菜单: Debug/Release 版本号选择。

    Build workspace/Rebuild workspace/Clean workspace

     

    Debug 菜单

    F8 : Start (开启调试,类似 VC  F5 )。

    F5 : Toggle breakpoint (插入断点,类似 VC  F9 )。

    F4 : run to cursor (运行到鼠标所在处),可跳过循环。

    F7 : run nextline (单步调试,类似 VC  F10 )。

    Shift+F7 : step into (进入函数内部调试,类似 VC  F11 )。

    Ctrl+Shift+F7  step out (跳出函数。类似 VC  Shift+F11 )。

     

    Debug→Debugging windows 

    Breakpoints : 查看全部断点

    Call stack : 调用堆栈

    CPU registers : 寄存器

    Disassembly : 反汇编代码

    Examine memory : 查看内存

    Running threads :查看线程

     

    Tools 菜单

    Configuration Tools →A dd ,把外部工具集成到 CodeBlocks 开发环境中。

     1 )配置 nautilus (相当于 Windows  explorer )打开 CB 当前项目( *.cbp )所在目录的命令到 Tools 菜单:

    Name : nautilus project dir

    Executable  /usr/bin/nautilus

    Parameters  ${PROJECT_DIR}

    Launching options  the last

     2 )配置 gedit 打开 CB 当前活动项目配置文件( *.cbp )的命令到 Tools 菜单:

    Name : gedit project file

    Executable  /usr/bin/gedit

    Parameters  ${PROJECT_FILENAME}

    Launching options  the last

     3 )配置 gedit 打开 CB 当前活动文件的命令到 Tools 菜单:

    Name : gedit current file

    Executable  /usr/bin/gedit

    Parameters  ${ACTIVE_EDITOR_FILENAME}

    Launching options  the last

    利用 gedit 打开头文件。側边栏文件浏览器中能够查看头文件的位置。

     

    Plugins 菜单

    AStyle : 运行高速格式化 

     

    Settings 菜单

     1  .Settings→Enviorment

    1.1 General settings

    Terminal to launch console programs :控制台界面,默认使用不支持中文的 Xterm 。 我们能够把 gnome-terminal(Gnome 桌面环境自带的控制台 )作为默认控制台 ,将“ xterm -T $TITLE -e ” 改动为“ gnome-terminal -t $TITLE -x” 

    1. AutoSave

    Automatically save source files every 5 minutes;

    Automatically save projects every 1 0 minutes;

    Save to original file.

     2  .Settings→Editor

    2. 1 General Settings

    2.1.1 Font

    默认字体为等宽字体 Monospace/Regular/8 。可将字体调整为 10 

    2.1.2 Encoding

    use encoding when opening files: UTF-8 

    2.1.3 Other options

    Word warp : 激活自己主动换行模式。

    Show line numbers :显示行号。

    Highlight line under caret :高亮光标所在行。

    2. 2 Folding (代码折叠)

    Fold preprocessor commands :折叠预编译处理宏。

    2.3 Margins and caret

    2.3.1 Left Margin

    2.3.2 Right Margin

    Right Margin Hint 

    Visible line( 一行最多 81 个字符,右边有切割线 )

    Highlight text beyond margin (一旦超过 81 个字符,即高亮警示)。

    Hint colour :警示色。

    Hint column :一行代码最多输入字符数。

    2. 4 Syntax highlight

    Background 可设置背景色。

    keyword语法高亮配色。在 Syntax highlight 中的 “ keywords” 中能够自己定义keyword集的特定高亮配色方 案 。

    眼下 尚不支持变量名、函数名和类名的特定显示。

    2. 5 Abbreviations

    keyword宏块、 if  for  while  struct/class 的框架代码片段自己主动生成: Ctrl+J 

    特殊的有 ifb  if {block} )、 ife  if...else )、 ifei  if...else if...else ); forb  for() {block} ); guard (防止反复包括的保护宏块)、 today (今天的日期)、 now (如今的时间)。

    依照 AStyle 标准,可将 class  public/protected/private 删除一个 TAB 缩进。

    下面加入 C++ 经常使用的 namespace 

    namespace $(namespace name)|

    {

    |

    }//$(namespace name)

    这样。输入 namespace 。再按 Ctrl + J ,弹出对话框中输入命名空间的名字,就能够生成固定格式的代码,编辑光标停留在 {} 中。

    2. 6 Default code

    代码风格: Allman(ANSI)

    default code 为提前定义内容,当新建 C/C++ 文件时这些内容会自己主动加入到文件的開始处。

    2. 7 Source Formatter

    代码风格: Allman(ANSI)

    2. 8 Code-completion and symbols browser

    代码自己主动完毕和函数、类视图向导。

    Automatically launch when typed # letter 中的 4 改成 2 。这样打两个字母就会出现智能候选项提示。

    Keyword sets to additionally include 为keyword集合,在 Syntax highlight 中的 “ keywords” 中能够自己定义keyword集的特定高亮配色方 案 。

     3  .Settings→Compiler and Debugger

    3 . 1 Global compiler S ettings

    IDE 全局配置。

    Compiler settings :编译选项。

    Linker settings :链接选项。

    Search directories :包括文件夹。

    Toolchain executables :生成策略,包含 Program files 的编译器、链接器、调试器等和 Additional paths 

    当中 “ Compiler's intallation directory” 为编译器的路径。 Ubuntu 下的 gcc/ g++/ make/ gdb 默认 安装 路径是在 /usr/bin 下,这里显示的是 /usr ,红色文字提示编译器自己主动去其下的 bin 文件夹查找。

    Custom variables :自己定义宏值。以 $ 开头。

    Other settings 

    3 . 2 Batch Builds

    3 . 3 Debugging Settings

     

    项目类型

    File→New→Project

    (1)Console application :控制台( CUI )项目。

    (2)Static library :静态库项目( static library  .a /类似 VC  LIB )。

    (3)Shared library :动态库项目 (dynamic library  .so /类似 VC  DLL) 

    (4)Qt4 Project  QT GUI 项目。

    (5)GTK+ Project  GTK+ GUI 项目。

    (6)wxWidgets  wxWidgets GUI 项目。

     

    编译器的选择配置

    成功安装之后。主菜单 -→ 编程 -→Code::Blocks IDE 进入 IDE ,第一次打开软件的时候会自己主动检測系统中存在的 C 编译器, Linux 下一般都是自己主动检測到 GNU G C C Compiler 。此 时,就可以编译链接第一个 HelloWorld.c  Console application  gcc 也可编译 HelloWorld.cpp  Console application 。但链接须要 g cc -lstdc++  由于 gcc 命令不能自己主动和 C ++程序使用的库联接,所以通常使用 g++ 来完毕联接。

    点击菜单条的 Settings-→Compiler and debugger... 进入编译器和调试器的设定对话框。看 Selected compiler 是不是你想要使用的编译器。因为我们默认是 GNU C ,所以这里显示的是 GNU GCC Compiler 

     

    快捷键

    日常操作:

    Ctrl+Shift+L :删除行

    Ctrl+Shift+T :复制行

    Ctrl+L: 剪切行

    Ctrl+D : 复制当前行,并粘贴到下一行。

     

    Ctrl+[/Ctrl+] :上 / 下段落定位

    Ctrl+Shift+[/Ctrl+Shift+] :上 / 下段落块选

     

    Ctrl+ 滚轮: 改变代码字体大小

    Ctrl+Tab : 标签页切换

    Tab/Shift+Tab :缩进 / 取消缩进

     

    Ctrl+Backspace/Ctrl+Del :删除光标前 / 后一个单词

    Ctrl+Shift+Backspace/Ctrl+Shift+Del :删除光标到行首 / 

     

    右键上下文菜单:

    Insert→All class methods without implementation... :插入你还没定义的方法的定义

    Insert→Class Method declaration/implementation... :插入一个方法的声明或定义

    Folding→Fold all/Unfold all :开长代码时所有折叠或所有展开

    Split view :对当前代码文件进行分屏浏览

    Format this file  AStyle ):高速格式化当前代码文件

    Add todo item... 

     

    安全起见,可备份 CB 的配置方案 ~/.codeblocks/Default.conf 

     

    參考:

     Code::Blocks 手册 

  • 相关阅读:
    css3渐变色
    css3背景
    css3边框
    css3弹性盒子
    计算机概论
    中断和异常的处理与抢占式多任务
    分页机制和动态页面分配
    任务切换
    任务的隔离和特权级保护
    程序的动态加载和执行
  • 原文地址:https://www.cnblogs.com/bhlsheji/p/5050901.html
Copyright © 2011-2022 走看看