← 返回日报
精读 预计 2 分钟

gap: UI text diff

摘要

gap 是一款极简原生 GUI 文本差异实用工具,源于 Handmade Essentials 2026 Jam。目标是呈现像 GitHub 或 Azure DevOps 那样的差异视图,同时作为 Fred 项目实现 Myers 算法线性变体的原型。 功能包括:自包含仓库(仅需 C++ 编译器,Linux 有依赖);支持块内差异多种视图(词级和字符级);一键交换差异顺序;按键展开 / 折叠上下文窗口(负数表示无限);支持目录差异匹配;完整 Fred 风格配置探索器(行号、颜色、动画开关);帮助面板(快捷键重绑);Windows 多渲染器(DX11 默认或 OpenGL);启用子像素字体渲染;支持 Windows 与 Linux(无 OSX)。 用法:直接拖拽文件到面板或目录对比;可与 Git 集成作为 git difftool;Linux 路径需转义。支持 VS2022 及 gcc 13.3.0 构建。

荐读理由

拖拽文件或目录到面板即可展示与GitHub/Azure DevOps相同的文本差异视图,还支持一键切换差异顺序、展开/折叠上下文窗口、目录级对比,以及git difftool集成;Windows下可直接用DX11渲染器

原文

gap - GUI Text Diff.

gap

This is a very simple text GUI diffing utility started during the Handmade Essentials 2026 Jam.

The goal of gap is to provide a very simple native utility which presents diffs in a way that you might see them on popular source control sites such as Github or Azure DevOps.

The secondary goal of gap is to serve as a proof-of-concept for implementing the linear variant of the Myers diff algorithm for use in fred.

Features

  • Self-contained repo. There are no dependencies outside of a C++ compiler (some Linux caveats).

  • Multiple options for viewing inner-diffs within similar blocks (word-based and character-based).

  • Easily swap the order of diffs with a single button.

  • Expand/collapse context window at the push of a button (anything below 0 indicates 'infinite' context, implying there is no window).

  • Supports directory diffing where each file in the corresponding directory is matched to files in the opposite directory.

  • Full configuration explorer just like in fred from which you can change settings such as viewing line numbers, changing colors, or disabling animations.

  • Help panel which provides hotkey rebinding.

  • Multiple renderer options on Windows (DX11 and OpenGL with DX11 being default).

  • Supports subpixel font rendering (on by default).

  • Supports both Windows and Linux (no OSX).

Usage

$ gap a.txt b.txt # file diffing.
$ gap .\A .\B     # directory diffing.

Or simply open gap and drag-and-drop files onto each panel side for diffing. You can overwrite a file by dragging and dropping a new file onto that panel. You can also open the directory diffing panel via the default of CTRL+O and drag directories onto each side for a directory comparison.

Another way of using gap is to tie it into git for viewing local diffs:

$ git config difftool.gap.path "D:/git_projects/gap/build/gap.exe"
$ git config difftool.gap.cmd "D:/git_projects/gap/build/gap.exe """$LOCAL""" """$REMOTE""""
$ git config diff.tool gap

Which you can then use git difftool instead of git diff to view diffs locally.

Additionally, you may want to consider invoking git difftool as git difftool -d to take advantage of the directory diffing in gap.

On Linux you would simply escape the quotes differently and alter paths.

Screenshots

screenshot-1 screenshot-2

Building

Windows:

  1. Open up an VS2022 (or later) x64 Developer Command Prompt
$ build

Or for release:

$ build release

Linux:

  1. Ensure you have a recent-ish version of gcc. I used 13.3.0.

  2. Have the following system dependencies installed:

  • OpenGL (I used libglx-dev)

  • X11 (I used libx11-dev)

  • X11-ext (I used libxext-dev)

  • Xrandr (I used libxrandr-dev)

$ ./build.sh

Or for release:

$ ./build.sh release

License

MIT

Lobsters · 2 赞 · 0 评 讨论 → 阅读原文 →

这条对你有帮助吗?