Index: convert_html.php
===================================================================
RCS file: /cvsroot/pukiwiki/pukiwiki/convert_html.php,v
retrieving revision 1.59
diff -u -r1.59 convert_html.php
--- convert_html.php	4 Dec 2003 03:09:27 -0000	1.59
+++ convert_html.php	4 Dec 2003 05:45:53 -0000
@@ -861,7 +861,7 @@
 		global $top,$_symbol_anchor;
 		
 		$anchor = (($id = make_heading($text,FALSE)) == '') ?
-			'' : " &aname($id,super,full)\{$_symbol_anchor};";
+			'' : " &edit(,$id); &aname($id,super,full)\{$_symbol_anchor};";
 		$text = ' '.$text;
 		$id = "content_{$this->id}_{$this->count}";
 		$this->count++;
Index: html.php
===================================================================
RCS file: /cvsroot/pukiwiki/pukiwiki/html.php,v
retrieving revision 1.96
diff -u -r1.96 html.php
--- html.php	27 Oct 2003 06:26:54 -0000	1.96
+++ html.php	4 Dec 2003 05:45:53 -0000
@@ -175,6 +175,7 @@
 	$s_digest = htmlspecialchars($digest);
 	$s_postdata = htmlspecialchars($refer.$postdata);
 	$s_original = array_key_exists('original',$vars) ? htmlspecialchars($vars['original']) : $s_postdata;
+	$s_id = array_key_exists('id',$vars) ? htmlspecialchars($vars['id']) : '';
 	$b_preview = array_key_exists('preview',$vars); // ¥×¥ì¥Ó¥å¡¼ÃæTRUE
 	$btn_preview = $b_preview ? $_btn_repreview : $_btn_preview;
 	
@@ -186,6 +187,7 @@
   <input type="hidden" name="cmd" value="edit" />
   <input type="hidden" name="page" value="$s_page" />
   <input type="hidden" name="digest" value="$s_digest" />
+  <input type="hidden" name="id" value="$s_id" />
   <textarea name="msg" rows="$rows" cols="$cols">$s_postdata</textarea>
   <br />
   <input type="submit" name="preview" value="$btn_preview" accesskey="p" />
Index: plugin/edit.inc.php
===================================================================
RCS file: /cvsroot/pukiwiki/pukiwiki/plugin/edit.inc.php,v
retrieving revision 1.11
diff -u -r1.11 edit.inc.php
--- plugin/edit.inc.php	22 Jun 2003 06:37:18 -0000	1.11
+++ plugin/edit.inc.php	4 Dec 2003 05:45:54 -0000
@@ -19,7 +19,17 @@
 		return plugin_edit_write();
 	}
 	
-	$postdata = @join('',get_source($vars['page']));
+	$source = get_source($vars['page']);
+	$postdata = $vars['original'] = join('',$source);
+	if (!empty($vars['id']))
+	{
+		$postdata = plugin_edit_parts($vars['id'],$source);
+		if ($postdata === FALSE)
+		{
+			unset($vars['id']); // ¤Ê¤«¤Ã¤¿¤³¤È¤Ë :)
+			$postdata = $vars['original'];
+		}
+	}
 	if ($postdata == '') {
 		$postdata = auto_template($vars['page']);
 	}
@@ -81,6 +91,31 @@
 	
 	return array('msg'=>$_title_preview,'body'=>$body);
 }
+function plugin_edit_inline()
+{
+	global $script,$vars;
+	static $label_img = '<img style="float:right" src="image/edit.png" alt="Edit" title="Edit" />';
+	
+	$args = func_get_args();
+	
+	$s_label = array_pop($args);
+	if ($s_label == '')
+	{
+		$s_label = $label_img;
+	}
+	
+	list($page,$id) = array_pad($args,2,'');
+	if (!is_page($page))
+	{
+		$page = $vars['page'];
+	}
+	if ($id != '')
+	{
+		$id = '&amp;id='.rawurlencode($id);
+	}
+	$r_page = rawurlencode($page);
+	return "<a class=\"anchor_super\" href=\"$script?cmd=edit&amp;page=$r_page$id\">$s_label</a>";
+}
 
 // ½ñ¤­¹þ¤ß¤â¤·¤¯¤ÏÄÉ²Ã¤â¤·¤¯¤Ï¥³¥á¥ó¥È¤ÎÁÞÆþ
 function plugin_edit_write()
@@ -109,6 +144,19 @@
 	}
 	else {
 		$postdata = $post['msg'];
+		if (!empty($post['id']))
+		{
+			$source = preg_split('/([^\n]*\n)/',$post['original'],-1,PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE);
+			if (plugin_edit_parts($post['id'],$source,$post['msg']) !== FALSE)
+			{
+				$postdata = $postdata_input = join('',$source);
+			}
+			else
+			{
+				// $post['msg']¤À¤±¤¬¥Ú¡¼¥¸¤Ë½ñ¤­¹þ¤Þ¤ì¤Æ¤·¤Þ¤¦¤Î¤òËÉ¤°¡£
+				$postdata = $postdata_input = rtrim($post['original'])."\n\n".$post['msg'];
+			}
+		}
 	}
 	
 	$oldpagesrc = join('',get_source($post['page']));
@@ -127,6 +175,7 @@
 			$retvars['body'] .= $do_update_diff_table;
 		}
 		
+		unset($vars['id']);// ¹¹¿·¤¬¾×ÆÍ¤·¤¿¤éÁ´Ê¸ÊÔ½¸¤ËÀÚ¤êÂØ¤¨
 		$retvars['body'] .= edit_form($post['page'],$postdata_input,$oldpagemd5,FALSE);
 	}
 	else {
@@ -146,4 +195,20 @@
 	return $retvars;
 }
 
+// ¥½¡¼¥¹¤Î°ìÉô¤òÃê½Ð/ÃÖ´¹¤¹¤ë
+function plugin_edit_parts($id,&$source,$postdata='')
+{
+	$postdata = rtrim($postdata)."\n";
+	$heads = preg_grep('/^\*{1,3}.+$/',$source);
+	$heads[count($source)] = ''; // sentinel
+	while (list($start,$line) = each($heads))
+	{
+		if (preg_match("/\[#$id\]/",$line))
+		{
+			list($end,$line) = each($heads);
+			return join('',array_splice($source,$start,$end - $start,$postdata));
+		}
+	}
+	return FALSE;
+}
 ?>
