怎样理解下面的手段? [英] How do I understand what the following means?

查看:144
本文介绍了怎样理解下面的手段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里报价:

  if (to_end) 
  { 
    /* If we want to scroll to the end, including horizontal scrolling, 
     * then we just create a mark with right gravity at the end of the  
     * buffer. It will stay at the end unless explicitely moved with  
     * gtk_text_buffer_move_mark. 
     */ 
    gtk_text_buffer_create_mark (buffer, "end", &iter, FALSE); 

    /* Add scrolling timeout. */ 
    return g_timeout_add (50, (GSourceFunc) scroll_to_end, textview); 
  } 
  else 
  { 
    /* If we want to scroll to the bottom, but not scroll horizontally,  
     * then an end mark won't do the job. Just create a mark so we can  
     * use it with gtk_text_view_scroll_mark_onscreen, we'll position it 
     * explicitely when needed. Use left gravity so the mark stays where  
     * we put it after inserting new text. 
     */ 
    gtk_text_buffer_create_mark (buffer, "scroll", &iter, TRUE); 

    /* Add scrolling timeout. */ 
    return g_timeout_add (100, (GSourceFunc) scroll_to_bottom, textview); 
  } 

虽然有评论颇有几行,我还是不明白的逻辑在里面,特别是,什么是的标记的之间的关系的滚动条的位置

更新

看来,我这个评论误导:

It seems that I'm mislead by this comment:

  /* and place the mark at iter. the mark will stay there after we
   * insert some text at the end because it has right gravity.
   */

说了,滚动标记具有的离开重力,没有重力,是这样吗?

Say, the scroll mark has left gravity,not right gravity,is that right?

推荐答案

标记具有的毫无关系的滚动条的位置。

Marks have no relation whatsoever to the position of the scroll bar.

他们使用商标在code,因为它的方便功能 gtk_text_view_scroll_mark_onscreen()这是计算标记的位置,然后再移动快捷方式滚动条到该位置。

They use marks in that code, because it's convenient for the function gtk_text_view_scroll_mark_onscreen() which is a shortcut for calculating the position of a mark, and then moving the scroll bars to that position.

结束标记是一个正确的重力标志,所以当他们文本添加到缓冲区的末尾,标记停留在末端。这样,当它们 scroll_mark_onscreen ,垂直和水平滚动条移动,以显示的最后一行的末尾。

The "end" mark is a right-gravity mark, so when they add text to the end of the buffer, the mark stays at the end. That way, when they scroll_mark_onscreen, both the vertical and horizontal scroll bars move, to display the end of the last line.

滚动标记已经离开地心引力。每当他们添加文字,给的开始的最后一行,他们不关心,哪里就有奇迹时,他们将文本添加到缓冲区的末尾,因为他们将它自己。这样,当他们 scroll_mark_onscreen ,只有垂直滚动条移动,显示的开始的最后一行。

The "scroll" mark has left gravity. They don't care about where it goes when they add text to the end of the buffer, because they move it themselves whenever they add text, to the beginning of the last line. That way, when they scroll_mark_onscreen, only the vertical scroll bars move, to display the beginning of the last line.

他们也可以同样有两个标志权重,因为他们不关心滚动标记去哪里。

They could just as well have had right gravity for both marks, because they don't care about where the "scroll" mark goes.

他们可能也无妨有左比重为标志,并手动移动结束标记到最后一行的末尾时,他们添加的文本,但他们没有,因为他们可以通过给结束标记权重自动获得同样的效果。

They could also just as well have had left gravity for both marks, and manually moved the "end" mark to the end of the last line whenever they added text, but they didn't, because they could get the same effect automatically by giving the "end" mark right gravity.

这篇关于怎样理解下面的手段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆