git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [[TIG][PATCH v2] 0/3] Refactoring the log view
@ 2013-08-06  4:58 Kumar Appaiah
  2013-08-06  4:58 ` [[TIG][PATCH v2] 1/3] Add log_select function to find commit from context in " Kumar Appaiah
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Kumar Appaiah @ 2013-08-06  4:58 UTC (permalink / raw)
  To: fonseca, git; +Cc: Kumar Appaiah

This is a second iteration. This handles the following:

- remove unneeded comments
- remove unneeded pager_request calls
- rename update_commit_ref to recalculate_commit_context

Now, the only thing missing is the recalculation of commits when the
line number is changed. The trouble there is that using the :<n>
approach doesn't call log_request, so we need to come up with a
smarter way to communicate the line number change, I guess.

Thanks for all the feedback!

Kumar Appaiah (3):
  Add log_select function to find commit from context in log view
  Display correct diff the context in split log view
  Revert "Scroll diff with arrow keys in log view"

 NEWS  |  1 +
 tig.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 58 insertions(+), 7 deletions(-)

-- 
1.8.3.2

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [[TIG][PATCH v2] 1/3] Add log_select function to find commit from context in log view
  2013-08-06  4:58 [[TIG][PATCH v2] 0/3] Refactoring the log view Kumar Appaiah
@ 2013-08-06  4:58 ` Kumar Appaiah
  2013-08-06  4:58 ` [[TIG][PATCH v2] 2/3] Display correct diff the context in split " Kumar Appaiah
  2013-08-06  4:58 ` [[TIG][PATCH v2] 3/3] Revert "Scroll diff with arrow keys in log view" Kumar Appaiah
  2 siblings, 0 replies; 5+ messages in thread
From: Kumar Appaiah @ 2013-08-06  4:58 UTC (permalink / raw)
  To: fonseca, git; +Cc: Kumar Appaiah

This commit introduces and uses the log_select function to find the
correct commit in the unsplit log view. In the log view, if one
scrolls down across a commit line, the current commit (as displayed in
the status bar) gets updated, but not so when scrolling upward across
a commit. The log_select function handles this scenario to do the
``right thing''. In addition, it introduces the log_state structure as
the private entry of the log view to hold a flag that decides whether
to re-evaluate the current commit based on scrolling.

Signed-off-by: Kumar Appaiah <a.kumar@alumni.iitm.ac.in>
---
 tig.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 47 insertions(+), 3 deletions(-)

diff --git a/tig.c b/tig.c
index 4759f1d..845153f 100644
--- a/tig.c
+++ b/tig.c
@@ -4383,6 +4383,35 @@ pager_select(struct view *view, struct line *line)
 	}
 }
 
+struct log_state {
+	/* We need to recalculate the previous commit, when the user
+	 * scrolls up or uses the page up/down in the log
+	 * view. recalculate_commit_context is used as a flag to
+	 * indicate this. */
+	bool recalculate_commit_context;
+};
+
+static void
+log_select(struct view *view, struct line *line)
+{
+	struct log_state *state = view->private;
+
+	if (state->recalculate_commit_context && line->lineno > 1) {
+		const struct line *commit_line = find_prev_line_by_type(view, line, LINE_COMMIT);
+
+		if (commit_line)
+			string_copy_rev(view->ref, (char *) (commit_line->data + STRING_SIZE("commit ")));
+	}
+	if (line->type == LINE_COMMIT) {
+		char *text = (char *)line->data + STRING_SIZE("commit ");
+
+		if (!view_has_flags(view, VIEW_NO_REF))
+			string_copy_rev(view->ref, text);
+	}
+	string_copy_rev(ref_commit, view->ref);
+	state->recalculate_commit_context = FALSE;
+}
+
 static bool
 pager_open(struct view *view, enum open_flags flags)
 {
@@ -4426,11 +4455,26 @@ log_open(struct view *view, enum open_flags flags)
 static enum request
 log_request(struct view *view, enum request request, struct line *line)
 {
+	struct log_state *state = (struct log_state *) view->private;
+
 	switch (request) {
 	case REQ_REFRESH:
 		load_refs();
 		refresh_view(view);
-		return REQ_NONE;
+		return request;
+
+	case REQ_MOVE_UP:
+	case REQ_PREVIOUS:
+		if (line->type == LINE_COMMIT && line->lineno > 1) {
+			state->recalculate_commit_context = TRUE;
+		}
+		return request;
+
+	case REQ_MOVE_PAGE_UP:
+	case REQ_MOVE_PAGE_DOWN:
+		state->recalculate_commit_context = TRUE;
+		return request;
+
 	default:
 		return pager_request(view, request, line);
 	}
@@ -4440,13 +4484,13 @@ static struct view_ops log_ops = {
 	"line",
 	{ "log" },
 	VIEW_ADD_PAGER_REFS | VIEW_OPEN_DIFF | VIEW_SEND_CHILD_ENTER | VIEW_NO_PARENT_NAV,
-	0,
+	sizeof(struct log_state),
 	log_open,
 	pager_read,
 	pager_draw,
 	log_request,
 	pager_grep,
-	pager_select,
+	log_select,
 };
 
 struct diff_state {
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [[TIG][PATCH v2] 2/3] Display correct diff the context in split log view
  2013-08-06  4:58 [[TIG][PATCH v2] 0/3] Refactoring the log view Kumar Appaiah
  2013-08-06  4:58 ` [[TIG][PATCH v2] 1/3] Add log_select function to find commit from context in " Kumar Appaiah
@ 2013-08-06  4:58 ` Kumar Appaiah
  2013-08-06 23:05   ` Kumar Appaiah
  2013-08-06  4:58 ` [[TIG][PATCH v2] 3/3] Revert "Scroll diff with arrow keys in log view" Kumar Appaiah
  2 siblings, 1 reply; 5+ messages in thread
From: Kumar Appaiah @ 2013-08-06  4:58 UTC (permalink / raw)
  To: fonseca, git; +Cc: Kumar Appaiah

In the log view, when scrolling across a commit, the diff view should
automatically switch to the commit whose context the cursor is on in
the log view. This commit changes things to catch the REQ_ENTER in the
log view and handle recalculation of the commit and diff display from
log_request, rather than delegating it to pager_request. In addition,
it also gets rid of unexpected upward scrolling of the log view.

Fixes GH #155

Signed-Off-By: Kumar Appaiah <a.kumar@alumni.iitm.ac.in>
---
 NEWS  | 1 +
 tig.c | 9 ++++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index 076ac9d..1b0f737 100644
--- a/NEWS
+++ b/NEWS
@@ -49,6 +49,7 @@ Bug fixes:
  - Ignore unrepresentable characters when transliterating text for rendering.
  - Transliterate text to output encoding before trimming it to avoid
    misalignment. (GH #86)
+ - Introduce a more natural context-sensitive log display. (GH #155)
 
 tig-1.1
 -------
diff --git a/tig.c b/tig.c
index 845153f..256b589 100644
--- a/tig.c
+++ b/tig.c
@@ -4475,8 +4475,15 @@ log_request(struct view *view, enum request request, struct line *line)
 		state->recalculate_commit_context = TRUE;
 		return request;
 
+	case REQ_ENTER:
+		state->recalculate_commit_context = TRUE;
+		if (VIEW(REQ_VIEW_DIFF)->ref != ref_commit)
+			open_view(view, REQ_VIEW_DIFF, OPEN_SPLIT);
+		update_view_title(view);
+		return request;
+
 	default:
-		return pager_request(view, request, line);
+		return request;
 	}
 }
 
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [[TIG][PATCH v2] 3/3] Revert "Scroll diff with arrow keys in log view"
  2013-08-06  4:58 [[TIG][PATCH v2] 0/3] Refactoring the log view Kumar Appaiah
  2013-08-06  4:58 ` [[TIG][PATCH v2] 1/3] Add log_select function to find commit from context in " Kumar Appaiah
  2013-08-06  4:58 ` [[TIG][PATCH v2] 2/3] Display correct diff the context in split " Kumar Appaiah
@ 2013-08-06  4:58 ` Kumar Appaiah
  2 siblings, 0 replies; 5+ messages in thread
From: Kumar Appaiah @ 2013-08-06  4:58 UTC (permalink / raw)
  To: fonseca, git; +Cc: Kumar Appaiah

This reverts commit 888611dd5d407775245d574a3dc5c01b5963a5ba. This is
because, in the re-engineered log view, scrolling the log with the
arrows now updates the diff in the diff view when the screen is
split. This resembles the earlier behaviour, and is also what users of
software like Mutt (which uses the pager view concept) would expect.

Signed-Off-By: Kumar Appaiah <a.kumar@alumni.iitm.ac.in>

Conflicts:
	tig.c
---
 tig.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tig.c b/tig.c
index 256b589..5f564a5 100644
--- a/tig.c
+++ b/tig.c
@@ -1905,7 +1905,6 @@ enum view_flag {
 	VIEW_STDIN		= 1 << 8,
 	VIEW_SEND_CHILD_ENTER	= 1 << 9,
 	VIEW_FILE_FILTER	= 1 << 10,
-	VIEW_NO_PARENT_NAV	= 1 << 11,
 };
 
 #define view_has_flags(view, flag)	((view)->ops->flags & (flag))
@@ -3773,7 +3772,7 @@ view_driver(struct view *view, enum request request)
 
 	case REQ_NEXT:
 	case REQ_PREVIOUS:
-		if (view->parent && !view_has_flags(view->parent, VIEW_NO_PARENT_NAV)) {
+		if (view->parent) {
 			int line;
 
 			view = view->parent;
@@ -4490,7 +4489,7 @@ log_request(struct view *view, enum request request, struct line *line)
 static struct view_ops log_ops = {
 	"line",
 	{ "log" },
-	VIEW_ADD_PAGER_REFS | VIEW_OPEN_DIFF | VIEW_SEND_CHILD_ENTER | VIEW_NO_PARENT_NAV,
+	VIEW_ADD_PAGER_REFS | VIEW_OPEN_DIFF | VIEW_SEND_CHILD_ENTER,
 	sizeof(struct log_state),
 	log_open,
 	pager_read,
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [[TIG][PATCH v2] 2/3] Display correct diff the context in split log view
  2013-08-06  4:58 ` [[TIG][PATCH v2] 2/3] Display correct diff the context in split " Kumar Appaiah
@ 2013-08-06 23:05   ` Kumar Appaiah
  0 siblings, 0 replies; 5+ messages in thread
From: Kumar Appaiah @ 2013-08-06 23:05 UTC (permalink / raw)
  To: fonseca, git

On Tue, Aug 06, 2013 at 12:58:20AM -0400, Kumar Appaiah wrote:
>  tig-1.1
>  -------
> diff --git a/tig.c b/tig.c
> index 845153f..256b589 100644
> --- a/tig.c
> +++ b/tig.c
> @@ -4475,8 +4475,15 @@ log_request(struct view *view, enum request request, struct line *line)
>  		state->recalculate_commit_context = TRUE;
>  		return request;
>  
> +	case REQ_ENTER:
> +		state->recalculate_commit_context = TRUE;
> +		if (VIEW(REQ_VIEW_DIFF)->ref != ref_commit)
> +			open_view(view, REQ_VIEW_DIFF, OPEN_SPLIT);
> +		update_view_title(view);
  		^^^^^^^^^^^^^^^^^^^^^^^

I missed removing update_view_title. I've done it locally, though.

Thanks.

Kumar

> +		return request;
> +
>  	default:
> -		return pager_request(view, request, line);
> +		return request;
>  	}
>  }
>  
> -- 
> 1.8.3.2

-- 
Kumar Appaiah

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-08-06 23:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-06  4:58 [[TIG][PATCH v2] 0/3] Refactoring the log view Kumar Appaiah
2013-08-06  4:58 ` [[TIG][PATCH v2] 1/3] Add log_select function to find commit from context in " Kumar Appaiah
2013-08-06  4:58 ` [[TIG][PATCH v2] 2/3] Display correct diff the context in split " Kumar Appaiah
2013-08-06 23:05   ` Kumar Appaiah
2013-08-06  4:58 ` [[TIG][PATCH v2] 3/3] Revert "Scroll diff with arrow keys in log view" Kumar Appaiah

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).