You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. /*
  2. *
  3. * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6. * of this software and associated documentation files (the "Software"), to deal
  7. * in the Software without restriction, including without limitation the rights
  8. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. * copies of the Software, and to permit persons to whom the Software is
  10. * furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be included in
  13. * all copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21. * SOFTWARE.
  22. */
  23. package com.dmdirc.addons.ui_swing.components;
  24. import com.dmdirc.Channel;
  25. import com.dmdirc.addons.ui_swing.SwingController;
  26. import com.dmdirc.addons.ui_swing.UIUtilities;
  27. import com.dmdirc.addons.ui_swing.actions.NoNewlinesPasteAction;
  28. import com.dmdirc.addons.ui_swing.components.frames.ChannelFrame;
  29. import com.dmdirc.config.IdentityManager;
  30. import com.dmdirc.interfaces.ConfigChangeListener;
  31. import com.dmdirc.parser.interfaces.ChannelInfo;
  32. import com.dmdirc.parser.interfaces.Parser;
  33. import com.dmdirc.parser.interfaces.callbacks.ChannelTopicListener;
  34. import com.dmdirc.ui.IconManager;
  35. import com.dmdirc.ui.messages.ColourManager;
  36. import com.dmdirc.ui.messages.Styliser;
  37. import com.dmdirc.util.URLHandler;
  38. import java.awt.Color;
  39. import java.awt.event.ActionEvent;
  40. import java.awt.event.ActionListener;
  41. import java.awt.event.MouseEvent;
  42. import java.awt.event.MouseListener;
  43. import javax.swing.AbstractAction;
  44. import javax.swing.JButton;
  45. import javax.swing.JComponent;
  46. import javax.swing.JLabel;
  47. import javax.swing.JScrollPane;
  48. import javax.swing.KeyStroke;
  49. import javax.swing.SwingUtilities;
  50. import javax.swing.event.DocumentEvent;
  51. import javax.swing.event.DocumentListener;
  52. import javax.swing.event.HyperlinkEvent;
  53. import javax.swing.event.HyperlinkListener;
  54. import javax.swing.text.AbstractDocument;
  55. import javax.swing.text.BadLocationException;
  56. import javax.swing.text.BoxView;
  57. import javax.swing.text.ComponentView;
  58. import javax.swing.text.DefaultStyledDocument;
  59. import javax.swing.text.Element;
  60. import javax.swing.text.GlyphView;
  61. import javax.swing.text.IconView;
  62. import javax.swing.text.LabelView;
  63. import javax.swing.text.ParagraphView;
  64. import javax.swing.text.SimpleAttributeSet;
  65. import javax.swing.text.StyleConstants;
  66. import javax.swing.text.StyledDocument;
  67. import javax.swing.text.StyledEditorKit;
  68. import javax.swing.text.View;
  69. import javax.swing.text.ViewFactory;
  70. import net.miginfocom.swing.MigLayout;
  71. /**
  72. * Component to show and edit topics for a channel.
  73. */
  74. public class TopicBar extends JComponent implements ActionListener,
  75. ConfigChangeListener, ChannelTopicListener, HyperlinkListener,
  76. MouseListener, DocumentListener {
  77. /**
  78. * A version number for this class. It should be changed whenever the class
  79. * structure is changed (or anything else that would prevent serialized
  80. * objects being unserialized with the new class).
  81. */
  82. private static final long serialVersionUID = 1;
  83. /** Topic text. */
  84. private final TextPaneInputField topicText;
  85. /** Edit button. */
  86. private final JButton topicEdit;
  87. /** Cancel button. */
  88. private final JButton topicCancel;
  89. /** Associated channel. */
  90. private Channel channel;
  91. /** Controller. */
  92. private SwingController controller;
  93. /** Empty Attrib set. */
  94. private SimpleAttributeSet as;
  95. /** Foreground Colour. */
  96. private Color foregroundColour;
  97. /** Background Colour. */
  98. private Color backgroundColour;
  99. /** the maximum length allowed for a topic. */
  100. private int topicLengthMax;
  101. /** Error icon. */
  102. private final JLabel errorIcon;
  103. /**
  104. * Instantiates a new topic bar.
  105. *
  106. * @param channelFrame Parent channel frame
  107. */
  108. public TopicBar(final ChannelFrame channelFrame) {
  109. this.channel = channelFrame.getChannel();
  110. controller = channelFrame.getController();
  111. topicText = new TextPaneInputField();
  112. topicLengthMax = channel.getServer().getParser().getMaxTopicLength();
  113. errorIcon =
  114. new JLabel(IconManager.getIconManager().getIcon("input-error"));
  115. //TODO issue 3251
  116. //if (channelFrame.getConfigManager().getOptionBool(controller.
  117. // getDomain(), "showfulltopic")) {
  118. // topicText.setEditorKit(new StyledEditorKit());
  119. //} else {
  120. topicText.setEditorKit(new WrapEditorKit());
  121. //}
  122. ((DefaultStyledDocument) topicText.getDocument()).setDocumentFilter(
  123. new NewlinesDocumentFilter());
  124. topicText.getActionMap().put("paste-from-clipboard",
  125. new NoNewlinesPasteAction());
  126. topicEdit = new ImageButton("edit", IconManager.getIconManager().
  127. getIcon("edit-inactive"), IconManager.getIconManager().
  128. getIcon("edit"));
  129. topicCancel = new ImageButton("cancel", IconManager.getIconManager().
  130. getIcon("close"), IconManager.getIconManager().
  131. getIcon("close-active"));
  132. new SwingInputHandler(topicText, channelFrame.getCommandParser(),
  133. channelFrame).setTypes(false, false, true, false);
  134. final JScrollPane sp = new JScrollPane(topicText);
  135. sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
  136. sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
  137. setLayout(new MigLayout("fillx, ins 0, hidemode 3"));
  138. add(sp, "growx, pushx");
  139. add(errorIcon, "");
  140. add(topicCancel, "");
  141. add(topicEdit, "");
  142. channel.getChannelInfo().getParser().getCallbackManager().addCallback(
  143. ChannelTopicListener.class, this, channel.getChannelInfo().
  144. getName());
  145. topicText.addActionListener(this);
  146. topicEdit.addActionListener(this);
  147. topicCancel.addActionListener(this);
  148. topicText.getInputMap().put(KeyStroke.getKeyStroke("ENTER"),
  149. "enterButton");
  150. topicText.getActionMap().put("enterButton", new AbstractAction(
  151. "enterButton") {
  152. private static final long serialVersionUID = 1;
  153. /** {@inheritDoc} */
  154. @Override
  155. public void actionPerformed(ActionEvent e) {
  156. TopicBar.this.actionPerformed(e);
  157. }
  158. });
  159. topicText.getInputMap().put(KeyStroke.getKeyStroke("ESCAPE"),
  160. "escapeButton");
  161. topicText.getActionMap().put("escapeButton", new AbstractAction(
  162. "escapeButton") {
  163. private static final long serialVersionUID = 1;
  164. /** {@inheritDoc} */
  165. @Override
  166. public void actionPerformed(ActionEvent e) {
  167. e.setSource(topicCancel);
  168. TopicBar.this.actionPerformed(e);
  169. }
  170. });
  171. topicText.addHyperlinkListener(this);
  172. topicText.addMouseListener(this);
  173. topicText.getDocument().addDocumentListener(this);
  174. IdentityManager.getGlobalConfig().addChangeListener(
  175. "ui", "backgroundcolour", this);
  176. IdentityManager.getGlobalConfig().addChangeListener(
  177. "ui", "foregroundcolour", this);
  178. IdentityManager.getGlobalConfig().addChangeListener(
  179. "ui", "inputbackgroundcolour", this);
  180. IdentityManager.getGlobalConfig().addChangeListener(
  181. "ui", "inputforegroundcolour", this);
  182. IdentityManager.getGlobalConfig().addChangeListener(
  183. controller.getDomain(), "showfulltopic", this);
  184. IdentityManager.getGlobalConfig().addChangeListener(
  185. controller.getDomain(), "hideEmptyTopicBar", this);
  186. topicText.setFocusable(false);
  187. topicText.setEditable(false);
  188. topicCancel.setVisible(false);
  189. setColours();
  190. }
  191. /** {@inheritDoc} */
  192. @Override
  193. public void onChannelTopic(final Parser tParser, ChannelInfo cChannel,
  194. boolean bIsJoinTopic) {
  195. topicChanged();
  196. }
  197. /**
  198. * Topic has changed, update topic.
  199. */
  200. private void topicChanged() {
  201. if (topicText.isEditable()) {
  202. return;
  203. }
  204. topicText.setText("");
  205. if (channel.getCurrentTopic() != null) {
  206. Styliser.addStyledString((StyledDocument) topicText.getDocument(),
  207. new String[]{Styliser.CODE_HEXCOLOUR + ColourManager.getHex(
  208. foregroundColour) + channel.getCurrentTopic().getTopic(),},
  209. as);
  210. }
  211. if (channel.getConfigManager().getOptionBool(controller.getDomain(),
  212. "hideEmptyTopicBar")) {
  213. setVisible(topicText.getDocument().getLength() != 0);
  214. }
  215. topicText.setCaretPosition(0);
  216. validateTopic();
  217. }
  218. /**
  219. * {@inheritDoc}
  220. *
  221. * @param e Action event
  222. */
  223. @Override
  224. public void actionPerformed(final ActionEvent e) {
  225. if (e.getSource() == topicEdit || e.getSource() == topicText) {
  226. if (topicText.isEditable()) {
  227. channel.setTopic(topicText.getText());
  228. ((ChannelFrame) channel.getFrame()).getInputField().
  229. requestFocusInWindow();
  230. topicChanged();
  231. topicText.setFocusable(false);
  232. topicText.setEditable(false);
  233. topicCancel.setVisible(false);
  234. } else {
  235. topicText.setVisible(false);
  236. topicText.setText("");
  237. if (channel.getCurrentTopic() != null) {
  238. topicText.setText(channel.getCurrentTopic().getTopic());
  239. }
  240. applyAttributes();
  241. topicText.setCaretPosition(0);
  242. topicText.setFocusable(true);
  243. topicText.setEditable(true);
  244. topicText.setVisible(true);
  245. topicText.requestFocusInWindow();
  246. topicCancel.setVisible(true);
  247. }
  248. } else if (e.getSource() == topicCancel) {
  249. topicText.setFocusable(false);
  250. topicText.setEditable(false);
  251. topicCancel.setVisible(false);
  252. ((ChannelFrame) channel.getFrame()).getInputField().
  253. requestFocusInWindow();
  254. topicChanged();
  255. }
  256. }
  257. /** {@inheritDoc} */
  258. @Override
  259. public void hyperlinkUpdate(final HyperlinkEvent e) {
  260. if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
  261. URLHandler.getURLHander().launchApp(e.getURL());
  262. }
  263. }
  264. private void setColours() {
  265. backgroundColour = channel.getConfigManager().getOptionColour(
  266. "ui", "inputbackgroundcolour", "ui", "backgroundcolour");
  267. foregroundColour = channel.getConfigManager().getOptionColour(
  268. "ui", "inputforegroundcolour", "ui", "foregroundcolour");
  269. setBackground(backgroundColour);
  270. setForeground(foregroundColour);
  271. setDisabledTextColour(foregroundColour);
  272. setCaretColor(foregroundColour);
  273. setAttributes();
  274. }
  275. private void setAttributes() {
  276. as = new SimpleAttributeSet();
  277. StyleConstants.setFontFamily(as, topicText.getFont().getFamily());
  278. StyleConstants.setFontSize(as, topicText.getFont().getSize());
  279. StyleConstants.setBackground(as, backgroundColour);
  280. StyleConstants.setForeground(as, foregroundColour);
  281. StyleConstants.setUnderline(as, false);
  282. StyleConstants.setBold(as, false);
  283. StyleConstants.setItalic(as, false);
  284. }
  285. private void applyAttributes() {
  286. setAttributes();
  287. ((DefaultStyledDocument) topicText.getDocument()).setCharacterAttributes(
  288. 0, Integer.MAX_VALUE, as, true);
  289. }
  290. /**
  291. * Sets the caret position in this topic bar.
  292. *
  293. * @param position New position
  294. */
  295. public void setCaretPosition(final int position) {
  296. UIUtilities.invokeLater(new Runnable() {
  297. /** {@inheritDoc} */
  298. @Override
  299. public void run() {
  300. topicText.setCaretPosition(position);
  301. }
  302. });
  303. }
  304. /**
  305. * Sets the caret colour to the specified coloour.
  306. *
  307. * @param optionColour Colour for the caret
  308. */
  309. public void setCaretColor(final Color optionColour) {
  310. UIUtilities.invokeLater(new Runnable() {
  311. /** {@inheritDoc} */
  312. @Override
  313. public void run() {
  314. topicText.setCaretColor(optionColour);
  315. }
  316. });
  317. }
  318. /**
  319. * Sets the foreground colour to the specified coloour.
  320. *
  321. * @param optionColour Colour for the foreground
  322. */
  323. @Override
  324. public void setForeground(final Color optionColour) {
  325. UIUtilities.invokeLater(new Runnable() {
  326. /** {@inheritDoc} */
  327. @Override
  328. public void run() {
  329. topicText.setForeground(optionColour);
  330. }
  331. });
  332. }
  333. /**
  334. * Sets the disabled text colour to the specified coloour.
  335. *
  336. * @param optionColour Colour for the disabled text
  337. */
  338. public void setDisabledTextColour(final Color optionColour) {
  339. UIUtilities.invokeLater(new Runnable() {
  340. /** {@inheritDoc} */
  341. @Override
  342. public void run() {
  343. topicText.setDisabledTextColor(optionColour);
  344. }
  345. });
  346. }
  347. /**
  348. * Sets the background colour to the specified coloour.
  349. *
  350. * @param optionColour Colour for the caret
  351. */
  352. @Override
  353. public void setBackground(final Color optionColour) {
  354. UIUtilities.invokeLater(new Runnable() {
  355. /** {@inheritDoc} */
  356. @Override
  357. public void run() {
  358. topicText.setBackground(optionColour);
  359. }
  360. });
  361. }
  362. /** {@inheritDoc} */
  363. @Override
  364. public void configChanged(String domain, String key) {
  365. //TODO issue 3251
  366. //if ("showfulltopic".equals(key)) {
  367. // if (channel.getConfigManager().getOptionBool(controller.getDomain(),
  368. // "showfulltopic")) {
  369. // topicText.setEditorKit(new StyledEditorKit());
  370. // } else {
  371. // topicText.setEditorKit(new WrapEditorKit());
  372. // }
  373. // ((DefaultStyledDocument) topicText.getDocument()).setDocumentFilter(
  374. // new NewlinesDocumentFilter());
  375. //}
  376. setColours();
  377. if ("hideEmptyTopicBar".equals(key)) {
  378. setVisible(true);
  379. if (channel.getConfigManager().getOptionBool(controller.getDomain(),
  380. "hideEmptyTopicBar")) {
  381. setVisible(topicText.getDocument().getLength() != 0);
  382. }
  383. }
  384. }
  385. /**
  386. * Closes this topic bar.
  387. */
  388. public void close() {
  389. channel.getChannelInfo().getParser().getCallbackManager().delCallback(
  390. ChannelTopicListener.class, this);
  391. }
  392. /**
  393. * Validates the topic text and shows errors as appropriate.
  394. */
  395. public void validateTopic() {
  396. UIUtilities.invokeLater(new Runnable() {
  397. /** {@inheritDoc} */
  398. @Override
  399. public void run() {
  400. if (topicText.isEditable()) {
  401. final int charsLeft = topicLengthMax - topicText.getText().
  402. length();
  403. if (charsLeft < 0) {
  404. errorIcon.setVisible(true);
  405. errorIcon.setToolTipText("Topic too long: " + topicText.
  406. getText().length() + " of " + topicLengthMax);
  407. } else {
  408. errorIcon.setVisible(false);
  409. errorIcon.setToolTipText(null);
  410. }
  411. } else {
  412. errorIcon.setVisible(false);
  413. }
  414. }
  415. });
  416. }
  417. /**
  418. * {@inheritDoc}
  419. *
  420. * @param e Mouse event
  421. */
  422. @Override
  423. public void mouseClicked(MouseEvent e) {
  424. if (e.getClickCount() == 2) {
  425. topicEdit.doClick();
  426. }
  427. }
  428. /**
  429. * {@inheritDoc}
  430. *
  431. * @param e Mouse event
  432. */
  433. @Override
  434. public void mousePressed(final MouseEvent e) {
  435. //Ignore
  436. }
  437. /**
  438. * {@inheritDoc}
  439. *
  440. * @param e Mouse event
  441. */
  442. @Override
  443. public void mouseReleased(final MouseEvent e) {
  444. //Ignore
  445. }
  446. /**
  447. * {@inheritDoc}
  448. *
  449. * @param e Mouse event
  450. */
  451. @Override
  452. public void mouseEntered(final MouseEvent e) {
  453. //Ignore
  454. }
  455. /**
  456. * {@inheritDoc}
  457. *
  458. * @param e Mouse event
  459. */
  460. @Override
  461. public void mouseExited(final MouseEvent e) {
  462. //Ignore
  463. }
  464. /** {@inheritDoc} */
  465. @Override
  466. public void insertUpdate(final DocumentEvent e) {
  467. validateTopic();
  468. if (topicText.isEditable()) {
  469. SwingUtilities.invokeLater(new Runnable() {
  470. @Override
  471. public void run() {
  472. applyAttributes();
  473. }
  474. });
  475. }
  476. }
  477. /** {@inheritDoc} */
  478. @Override
  479. public void removeUpdate(final DocumentEvent e) {
  480. validateTopic();
  481. }
  482. /** {@inheritDoc} */
  483. @Override
  484. public void changedUpdate(final DocumentEvent e) {
  485. validateTopic();
  486. }
  487. }
  488. /**
  489. * @author Stanislav Lapitsky
  490. * @version 1.0
  491. */
  492. class WrapEditorKit extends StyledEditorKit {
  493. private static final long serialVersionUID = 1;
  494. private ViewFactory defaultFactory = new WrapColumnFactory();
  495. /** {@inheritDoc} */
  496. @Override
  497. public ViewFactory getViewFactory() {
  498. return defaultFactory;
  499. }
  500. }
  501. /**
  502. * @author Stanislav Lapitsky
  503. * @version 1.0
  504. */
  505. class WrapColumnFactory implements ViewFactory {
  506. /** {@inheritDoc} */
  507. @Override
  508. public View create(final Element elem) {
  509. String kind = elem.getName();
  510. if (kind != null) {
  511. if (kind.equals(AbstractDocument.ContentElementName)) {
  512. return new WrapLabelView(elem);
  513. } else if (kind.equals(AbstractDocument.ParagraphElementName)) {
  514. return new NoWrapParagraphView(elem);
  515. } else if (kind.equals(AbstractDocument.SectionElementName)) {
  516. return new BoxView(elem, View.Y_AXIS);
  517. } else if (kind.equals(StyleConstants.ComponentElementName)) {
  518. return new ComponentView(elem);
  519. } else if (kind.equals(StyleConstants.IconElementName)) {
  520. return new IconView(elem);
  521. }
  522. }
  523. // default to text display
  524. return new LabelView(elem);
  525. }
  526. }
  527. /**
  528. * @author Stanislav Lapitsky
  529. * @version 1.0
  530. */
  531. class NoWrapParagraphView extends ParagraphView {
  532. /**
  533. * Creates a new no wrap paragraph view.
  534. *
  535. * @param elem Element to view
  536. */
  537. public NoWrapParagraphView(final Element elem) {
  538. super(elem);
  539. }
  540. /** {@inheritDoc} */
  541. @Override
  542. public void layout(final int width, final int height) {
  543. super.layout(Short.MAX_VALUE, height);
  544. }
  545. /** {@inheritDoc} */
  546. @Override
  547. public float getMinimumSpan(final int axis) {
  548. return super.getPreferredSpan(axis);
  549. }
  550. }
  551. /**
  552. * @author Stanislav Lapitsky
  553. * @version 1.0
  554. */
  555. class WrapLabelView extends LabelView {
  556. /**
  557. * Creates a new wrap label view.
  558. *
  559. * @param elem Element to view
  560. */
  561. public WrapLabelView(final Element elem) {
  562. super(elem);
  563. }
  564. /** {@inheritDoc} */
  565. @Override
  566. public int getBreakWeight(final int axis, final float pos, final float len) {
  567. if (axis == View.X_AXIS) {
  568. checkPainter();
  569. int p0 = getStartOffset();
  570. int p1 = getGlyphPainter().getBoundedPosition(this, p0, pos, len);
  571. if (p1 == p0) {
  572. // can't even fit a single character
  573. return View.BadBreakWeight;
  574. }
  575. try {
  576. //if the view contains line break char return forced break
  577. if (getDocument().getText(p0, p1 - p0).indexOf("\r") >= 0) {
  578. return View.ForcedBreakWeight;
  579. }
  580. } catch (BadLocationException ex) {
  581. //should never happen
  582. }
  583. }
  584. return super.getBreakWeight(axis, pos, len);
  585. }
  586. /** {@inheritDoc} */
  587. @Override
  588. public View breakView(final int axis, final int p0, final float pos,
  589. final float len) {
  590. if (axis == View.X_AXIS) {
  591. checkPainter();
  592. int p1 = getGlyphPainter().getBoundedPosition(this, p0, pos, len);
  593. try {
  594. //if the view contains line break char break the view
  595. int index = getDocument().getText(p0, p1 - p0).indexOf("\r");
  596. if (index >= 0) {
  597. GlyphView v = (GlyphView) createFragment(p0, p0 + index + 1);
  598. return v;
  599. }
  600. } catch (BadLocationException ex) {
  601. //should never happen
  602. }
  603. }
  604. return super.breakView(axis, p0, pos, len);
  605. }
  606. }