Skip to content

Commit

Permalink
Fix keybindings, bump version.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kasper Peeters committed Oct 25, 2024
1 parent 050a51f commit b9ce745
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 15 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/tarball.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

name: Tarball

# on:
# release:
# types: [created]
on:
release:
types: [created]

on: [push]
# on: [push]

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion cmake/version.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
set(CADABRA_VERSION_MAJOR 2)
set(CADABRA_VERSION_MINOR 5)
set(CADABRA_VERSION_PATCH 6)
set(CADABRA_VERSION_PATCH 8)
set(CADABRA_VERSION_TWEAK 0)
set(CADABRA_VERSION_SEM ${CADABRA_VERSION_MAJOR}.${CADABRA_VERSION_MINOR}.${CADABRA_VERSION_PATCH})
set(COPYRIGHT_YEARS "2001-2024")
Expand Down
62 changes: 54 additions & 8 deletions frontend/gtkmm/CodeInput.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,19 @@ void CodeInput::init(const Prefs& prefs)
edit.set_left_margin(20);
// if(gtk_get_minor_version()<11 || gtk_get_minor_version()>=14)

// Determine the width of a tab.
auto layout = Pango::Layout::create(edit.get_pango_context());
Pango::Rectangle logical_rect;
layout->set_text(" ");
int space_width, space_height;
layout->get_pixel_size(space_width, space_height);

// Set 10 tab stops, each 3 spaces wide.
edit.set_monospace(true);
edit.set_accepts_tab(true);
Pango::TabArray tabs(10);
// FIXME: use character width measured, instead of '8', or at least
// understand how Pango units are supposed to work.
for(int i=0; i<10; ++i)
tabs.set_tab(i, Pango::TAB_LEFT, 4*8*i);
tabs.set_tab(i, Pango::TAB_LEFT, 3*space_width*i);
edit.set_tabs(tabs);

edit.signal_button_press_event().connect(sigc::mem_fun(this, &CodeInput::handle_button_press), false);
Expand Down Expand Up @@ -509,12 +516,14 @@ bool CodeInput::exp_input_tv::on_key_press_event(GdkEventKey* event)
bool is_shift_return = get_editable() && event->keyval==GDK_KEY_Return && (event->state&Gdk::SHIFT_MASK);
// bool is_shift_tab = get_editable() && event->keyval==GDK_KEY_Tab && (event->state&Gdk::SHIFT_MASK);
bool is_tab = get_editable() && event->keyval==GDK_KEY_Tab;
bool is_ctrl_k = get_editable() && event->keyval==GDK_KEY_k && (event->state&Gdk::CONTROL_MASK);
bool is_ctrl_a = get_editable() && event->keyval==GDK_KEY_a && (event->state&Gdk::CONTROL_MASK);
bool is_ctrl_e = get_editable() && event->keyval==GDK_KEY_e && (event->state&Gdk::CONTROL_MASK);

bool retval=false;
// std::cerr << event->keyval << ", " << event->state << " pressed, focus = " << has_focus()
// << ", editable = " << get_editable() << ", is_shift_return = " << is_shift_return << std::endl;
// std::cerr << event->keyval << ", " << event->state << " pressed, focus = " << has_focus()
// << ", editable = " << get_editable() << ", is_shift_return = " << is_shift_return << std::endl;

if(!is_shift_return && !is_tab)
retval=Gtk::TextView::on_key_press_event(event);

Glib::RefPtr<Gtk::TextBuffer> textbuf=get_buffer();

Expand All @@ -523,7 +532,7 @@ bool CodeInput::exp_input_tv::on_key_press_event(GdkEventKey* event)
content_execute(datacell);
return true;
}
if(is_tab) {
else if(is_tab) {
// Only complete if the last character is not whitespace.

Glib::RefPtr<Gtk::TextBuffer::Mark> ins = get_buffer()->get_insert();
Expand All @@ -535,6 +544,43 @@ bool CodeInput::exp_input_tv::on_key_press_event(GdkEventKey* event)
else
retval=Gtk::TextView::on_key_press_event(event);
}
else if(is_ctrl_a) {
Glib::RefPtr<Gtk::TextBuffer::Mark> ins = get_buffer()->get_insert();
Gtk::TextBuffer::iterator iter=textbuf->get_iter_at_mark(ins);
iter.set_line(iter.get_line());
textbuf->place_cursor(iter);
return true;
}
else if(is_ctrl_e) {
Glib::RefPtr<Gtk::TextBuffer::Mark> ins = get_buffer()->get_insert();
Gtk::TextBuffer::iterator iter=textbuf->get_iter_at_mark(ins);
iter.forward_to_line_end();
textbuf->place_cursor(iter);
return true;
}
else if(is_ctrl_k) {
Glib::RefPtr<Gtk::TextBuffer::Mark> ins = get_buffer()->get_insert();
Gtk::TextBuffer::iterator iter=textbuf->get_iter_at_mark(ins);
auto line = iter.get_line();
Gtk::TextBuffer::iterator line_start = iter;
Gtk::TextBuffer::iterator line_end = iter;

// Move to the start and end of the line
line_start.set_line(iter.get_line()); // Move to the beginning of the line
line_end.forward_to_line_end(); // Move to the end of the line

// Include the newline character if it exists (non-last line)
if (!line_end.is_end())
line_end.forward_char();

// Delete the text between line_start and line_end
get_buffer()->erase(line_start, line_end);
return true;
}
else {
retval=Gtk::TextView::on_key_press_event(event);
}

// else {
// // If this was a real key press (i.e. not just SHIFT or ALT or similar), emit a
// // signal so that the cell can be scrolled into view if necessary.
Expand Down
15 changes: 13 additions & 2 deletions web2/cadabra2/source/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ <h1>Change log</h1>
</p>
<a name="devel"></a>
<h3>github devel branch (2.5.7)</h3>
<ul>
</ul>

<a name="master"></a>
<h3>2.5.8 (released 25-Oct-2024)</h3>
<ul>
<li>Fix handling of spurious backslashes
(<a href="https://github.com/kpeeters/cadabra2/issues/240">#240</a>)
Expand All @@ -30,10 +35,16 @@ <h3>github devel branch (2.5.7)</h3>
build.</li>
<li>When an expression is fed through the sympy bridge, make sure to
not remove outer parent relations (so that the expression remains a
sub/superscript if it was one before entering the bridge).</li>
sub/superscript if it was one before entering the bridge).</li>
<li>Fix several bugs with the undo system, and add redo.</li>
<li>Fix split-view mode.</li>
<li>Added optional <tt>partial=False</tt> flag to <tt>zoom</tt> to
enable zooming on exact matches (Daniel).</li>
<li>Add some more standard keybindings (ctrl-k, ctrl-a, ctrl-e) to
input cells.</li>
<li>Generate source tarball asset with microtex included.</li>
</ul>

<a name="master"></a>
<h3>2.5.6 (released 29-Sep-2024)</h3>
<ul>
<li>Windows build is working again, now using MSYS2 because that's the only system that provides binary packages of our dependencies and also still carries gtkmm-3.0. An installer is now auto-generated by the CI on every release.</li>
Expand Down

0 comments on commit b9ce745

Please sign in to comment.